# cp php.ini-production /etc/php.ini # cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf # cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf # cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm # chmod +x /etc/init.d/php-fpm
由于php-fpm走的是9000端口,外网是无法访问的,我们需要在nginx的配置文件中增加代理的规则,即可让用户在访问80端口,请求php的时候,交由后端的fpm去执行。
启动php-fpm:
# /etc/init.d/php-fpm start
配置nginx虚拟机:
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;
}
将script 改为$document_root即可。
重启nginx:
# service nginx reload
然后就OK了。
CentOS 7源码编译安装PHP5.6和Nginx1.7.9及MySQL(搭建LNMP环境) https://www.linuxidc.com/Linux/2015-12/126200.htm
Ubuntu 14.04 LTS 安装 LNMP Nginx\PHP5 (PHP-FPM)\MySQL https://www.linuxidc.com/Linux/2014-05/102351.htm
CentOS 6.8 编译安装LNMP 简述 https://www.linuxidc.com/Linux/2017-05/143667.htm
Ubuntu 16.04 下源码配置LNMP开发环境 https://www.linuxidc.com/Linux/2016-09/135381.htm
CentOS 7源码编译安装PHP5.6和Nginx1.7.9及MySQL(搭建LNMP环境) https://www.linuxidc.com/Linux/2015-12/126200.htm
CentOS 7源码安装最新版LNMP环境 https://www.linuxidc.com/Linux/2015-04/116058.htm
CentOS 6.8 安装LNMP环境(Linux+Nginx+MySQL+PHP) https://www.linuxidc.com/Linux/2017-04/142880.htm
Ubuntu系统下LNMP环境的搭建 https://www.linuxidc.com/Linux/2017-04/142610.htm
编译LNMP之Nginx+php-fpm https://www.linuxidc.com/Linux/2017-10/147535.htm
Ubuntu 16.04 LTS下LNMP环境配置简述 https://www.linuxidc.com/Linux/2017-05/144252.htm