1. Change the yum source to NetEase’s source to speed up
vi /etc/yum.repos.d/CentOS-Base.repo
The changes are as follows
# CentOS-Base.repo
#
# This file uses a new mirrorlist system developed by Lance Davis
for CentOS.
# The mirror system uses the connecting IP address of the client
and the
# update status of each mirror to pick mirrors that are updated
to and
# geographically close to the client. You should use this for
CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can
try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever-Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.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
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.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
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
#baseurl=http://mirror.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
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.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
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
#baseurl=http://mirror.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
Two, update yum
yum -y update
3. Use the yum command that comes with the CentOS Linux system to install and upgrade the required program library
LANG=C
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng
libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib
zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel
ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel
krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap
openldap-devel nss_ldap openldap-clients openldap-servers
4. Install php and mysql
yum -y install php mysql mysql-server mysql-devel php-mysql
php-cgi php-mbstring php-gd php-fastcgi
5. Install nginx
Since centos does not have a default nginx package, you need to enable the REHL add-on 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 progress
netstat -tulpn | grep :9000
If the following appears, everything is normal
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 4352/php-cgi
8. Configure nginx (see nginx.conf for detailed configuration)
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;
}
9. View phpinfo
Scripting
<?php
phpinfo();
?>
10. Install phpmyadmin
Modify the permissions of /var/lib/php/session to be consistent with nginx and php_cgi
chown -R www.www /var/lib/php/session