1. php下载
https://secure.php.net/downloads.php
搜索china镜像站点,从这里下载
http://cn2.php.net/get/php-7.2.3.tar.gz/from/this/mirror
帮助文档
https://secure.php.net/download-docs.php
2.编译前配置
./configure --enable-fpm ;
遇到错误,缺少libxml2-devel包 ;
Redhat:
yum search libxml2
yum install -y libxml2-devel
Debian:
apt-cache search libxml2-dev
apt-get install libxml2-dev
3.编译安装
make && make install
4.复制并修改配置文件
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
sed -i ‘/^include=/ s#NONE#/usr/local#g‘ /usr/local/php/etc/php-fpm.conf
cp /usr/local/etc/php-fpm.d/www.conf.default /usr/local/etc/php-fpm.d/www.conf
在www.conf可以配置php-fpm的监听端口
5.启动php-fpm
/usr/local/sbin/php-fpm;
检查是否启动 lsof -i:9000
6. 配置Nginx支持PHP
ubuntu的nginx配置文件是/etc/nginx/sites-available/default
location ~ \.php$ {
root /var/www;
#指定php的根目录
fastcgi_pass 127.0.0.1:9002;
#php-fpm的默认端口是9000
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}