Install Nginx on yum on CentOS

Source: Internet
Author: User
Tags php mysql openldap
& Nbsp; 1. change the yum source to NetEase's source and add speed vi/etc/yum. repos. d/CentOS-Base.repo change content as FOLLOWS # CentOS-Base.repo # thisfileusesanew?listsystemdevelopedbylancedavisforcentos. # Themirrorsyst 1. change yum source to NetEase source to increase speed

Vi/etc/yum. repos. d/CentOS-Base.repo
The changes are as follows:

# CentOS-Base.repo
#
# This file uses a new release list system developed by Lance Davis for CentOS.
# The mirror system uses the connecting IP address of the client and


# Update status of each mirror to pick mirrors that are updated to and
# Geographically close to the client. You shoshould use this for CentOS updates
# Unless you are manually picking other mirrors.
#
# If the specified list = does not work for you, as a fall back you can try
# Remarked out baseurl = line instead.
#
#

[Base]
Name = CentOS-$ releasever-Base
# Items list = http://mirrorlist.centos.org /? Release = $ releasever & arch = $ basearch & repo = OS
# Baseurl = http://developer.centos.org/centos/?releasever/ OS /?basearch/
Baseurl = http://mirrors.163.com/centos/?releasever/ OS /?basearch/
Gpgcheck = 1
Gpgkey = http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

# Released updates
[Updates]
Name = CentOS-$ releasever-Updates
# Items list = http://mirrorlist.centos.org /? Release = $ releasever & arch = $ basearch & repo = updates
# Baseurl = http://developer.centos.org/centos/?releasever/updates/?basearch/
Baseurl = http://mirrors.163.com/centos/?releasever/updates/?basearch/
Gpgcheck = 1
Gpgkey = http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

# Packages used/produced in the build but not released
[Addons]
Name = CentOS-$ releasever-Addons
# Items list = http://mirrorlist.centos.org /? Release = $ releasever & arch = $ basearch & repo = addons
# Baseurl = http://developer.centos.org/centos/?releasever/addons/?basearch/
Baseurl = http://mirrors.163.com/centos/?releasever/addons/?basearch/
Gpgcheck = 1
Gpgkey = http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

# Additional packages that may be useful
[Extras]
Name = CentOS-$ releasever-Extras
# Items list = http://mirrorlist.centos.org /? Release = $ releasever & arch = $ basearch & repo = extras
# Baseurl = http://developer.centos.org/centos/?releasever/extras/?basearch/
Baseurl = http://mirrors.163.com/centos/?releasever/extras/?basearch/
Gpgcheck = 1
Gpgkey = http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

# Additional packages that extend functionality of existing packages
[Centosplus]
Name = CentOS-$ releasever-Plus
# Items list = http://mirrorlist.centos.org /? Release = $ releasever & arch = $ basearch & repo = centosplus
# Baseurl = http://developer.centos.org/centos/?releasever/centosplus/?basearch/
Baseurl = http://mirrors.163.com/centos/?releasever/centosplus/?basearch/
Gpgcheck = 1
Enabled = 0
Gpgkey = http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5


II. update yum

Yum-y update

3. use the yum command provided by CentOS Linux to install and upgrade the required Library

LANG = C
Yum-y install gcc-c ++ autoconf libjpeg-devel libpng-devel freetype-devel libxml2 libxml2-devel zlib-devel glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses- devel curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn-devel openssl-devel openldap-devel nss_ldap openldap-clients openldap-servers

4. install php and mysql

Yum-y install php mysql-server mysql-devel php-mysql php-cgi php-mbstring php-gd php-fastcgi

5. install nginx
Because centos does not have the default nginx package, you need to enable the REHL attachment package.

Rpm-Uvh http://download.Fedora.RedHat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
Yum-y install nginx

Set startup

Chkconfig nginx on

6. install spawn-fcgi to run php-cgi


Yum install spawn-fcgi

7. download the startup script of spawn-fcgi

Wget http://bash.cyberciti.biz/dl/419.sh.zip
Unzip 419.sh.zip
Mv 419.sh/etc/init. d/php_cgi
Chmod + x/etc/init. d/php_cgi

Start php_cgi

/Etc/init. d/php_cgi start

View processes

Netstat-tulpn | grep: 9000

If the following occurs, everything is normal.

Tcp 0 0 127.0.0.1: 9000 0.0.0.0: * LISTEN 4352/php-cgi

8. Configure nginx. for detailed configuration, see nginx. conf)

Location ~ . Php $ {
Root html;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME/usr/share/nginx/html $ fastcgi_script_name;
Include fastcgi_params;
}

IX. View phpinfo
Write scripts

Phpinfo ();

10. install phpmyadmin
The permission for modifying/var/lib/php/session is the same as that for nginx and php_cgi.

Chown-R www. www/var/lib/php/session
 
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.