一、安装
PHP的安装可以很简单的使用yum命令进行安装。
#添加php7.0源(这是centos7的命令,centos6.5的命令不同,不要照搬)
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm #安装php7.0(安装的拓展内容)
yum install php70w-common php70w-fpm php70w-opcache php70w-gd php70w-mysqlnd php70w-mbstring php70w-pecl-redis php70w-pecl-memcached php70w-devel
#启动PHP
systemctl start php-pfm
#开机自启动
systemctl enable php-pfm
二、修改nginx的配置,是nginx能够将php脚本的处理转给php-pfm模块
打开nginx的配置文件nginx.conf
#我的nginx安装在/usr/local目录下
vim /usr/local/nginx/conf/nginx.conf
#找到以下字段,加入红色的代码段
location / { root /home/web; index index.html index.htm index.php; }
#再找到以下的代码段,取消注释,将/script改为/home/web
location ~ .php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /script$fastcgi_script_name;
include fastcgi_params;
}
修改完之后重启nginx
/usr/local/nginx/sbin/nginx -s reload