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
配置nginx支持:
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