三.安装PHP5
1.安装PHP5
yum install php php-fpm -y #安装php直至完成

2.安装PHP组件,是PHP5支持MySQL
yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt
#这里选择以上安装包进行安装,根据提示输入Y回车

chkconfig php-fpm on #设置php-fpm 开机启动
/etc/init.d/php-fpm start #启动php-fpm
配置篇:
一.配置nginx 支持php
cp /etc/nginx/nginx.conf /etc/nginx/nginx.confbak #备份原有的配置文件
vim /etc/nginx/nginx.conf #编辑配置文件
user nginx nginx; #修改nginx 运行账号为;nginx组的nginx用户
:wq #保存退出
cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.confbak #备份原有的配置文件
vim /etc/nginx/conf.d/default.conf #编辑配置文件
index index.php index.html index.htm;#添加index.php 如图(大概在14行左右):

#pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

#取消FastCGI server 部分location 的注释,并要注意fastcgi_param行的参数,改为$document_root$fastcgi_script_name 或者使用绝对路径
service nginx restart #重启nginx
