CentOS7 源码编译安装PHP
准备工作:
下载PHP源码包
wget https://www.PHP.net/distributions/PHP-7.2.19.tar.gz (官网下载慢可用百度网盘下载)
下载依赖工具:
# yum -y install gcc libxml2 libxml2-devel openssl openssl-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel
配置PHP:
#./configure --prefix=/usr/local/PHP7 --with-config-file-path=/usr/local/PHP7 --enable-sockets --enable-fpm --enable-cli --enable-mbstring --enable-pcntl --enable-soap --enable-opcache --disable-fileinfo --disable-rpath --with-MysqLi --with-pdo-MysqL --with-iconv-dir --with-openssl --with-fpm-user=www --with-fpm-group=www --with-curl --with-mhash --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-zip --with-zlib --enable-simplexml --with-libxml-dir
编译安装:
#make && make install
cp PHP-7.2.19/PHP.ini-production /usr/local/PHP/PHP.ini # 复制 PHP.ini 文件到目录
vim /usr/local/Nginx/conf/Nginx.conf
http { server { location / { root html; index index.PHP index.html index.htm; } 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; } ... }
重启PHP-fpm:
# pkill -9 PHP-fpm # /usr/local/PHP7/sbin/PHP-fpm