1、为确保不冲突,先卸载之前的版本
yum remove httpd* php*

2、安装epel源
yum install epel-release -y

3、yum install nginx

4、安装PHP和PHP-FPM
yum install php php-fpm

5、安装其它一些模块
yum install php-gd php-mysql php-mbstring php-xml php-mcrypt php-imap php-odbc php-pear php -xmlrpc

6、nginx配合php-fpm一起工作
打开nginx主配置文件。
vim /etc/nginx/nginx.conf
在http模块中添加配置:
location / {
root /usr/share/nginx/html;
index index.html index.htm index.php;
}
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;
}

7、启动nginx、php-fpm
systemctl start nginx php-fpm
