1.安装PHP,如下两条安装命令:
yum install epel-release -y
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
安装PHP扩展包:
普通安装:
yum -y install php72w php72w-cli php72w-fpm php72w-common php72w-devel
较全面安装:
yum -y install php72w php72w-cli php72w-fpm php72w-common php72w-devel php72w-embedded php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xm
查看版本:php -v
2.在nginx配置集成php
编辑nginx.conf添加如下配置server块:
server
{
listen 192.168.241.15:80;
server_name 192.168.241.15;
access_log /home/logs/serverphp.access.log combined;
location /
{
index index.php index.html index.htm;
}
location ~ \.php$
{
root /home/server15;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
3.重启nginx和启动php-fpm fastcgi:
/usr/nginx/sbin/nginx
php-fpm -D
在/home/server15目录新建index.php文件就可以测试了:
http://192.168.241.15/index.php