[root@potato ~]# cd /usr/local/src
安装依赖环境
[root@potato src]# yum -y install libxml2* openssl* libcurl* libjpeg* libpng* freetype* libmcrypt* gcc
下载php7.2.32安装包
[root@potato src]# wget https://www.php.net/distributions/php-7.2.32.tar.gz
解压安装包
[root@potato src]# tar -zxvf php-7.2.32.tar.gz
进入php-7.2.32目录
[root@potato src]# cd php-7.2.32
配置
[root@potato php-7.2.32]# ./configure --prefix=/usr/local/php --with-mysqli --with-pdo-mysql --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-simplexml --enable-xml --disable-rpath --enable-bcmath --enable-soap --enable-zip --with-curl --enable-fpm --enable-mbstring --enable-sockets --with-gd --with-openssl --with-mhash --enable-opcache --disable-fileinfo
编译并安装
[root@potato php-7.2.32]# make && make install (过程约10分钟, 根据自己的系统配置决定)
配置服务
[root@potato php-7.2.32]# ln /usr/local/php/sbin/php-fpm /usr/local/sbin
[root@potato php-7.2.32]# cp /usr/local/src/php-7.2.32/php.ini-development /usr/local/php/lib/php.ini
[root@potato php-7.2.32]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[root@potato php-7.2.32]# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
[root@potato php-7.2.32]# cp -R /usr/local/php/sbin/php-fpm /etc/init.d/php-fpm
[root@potato php-7.2.32]# echo 'export PATH="/usr/local/php/bin:$PATH"' >> /etc/profile
[root@potato php-7.2.32]# source /etc/profile
启动php服务
[root@potato php-7.2.32]# /etc/init.d/php-fpm 启动服务(结束服务: killall php-fpm)
修改nginx服务,使其支持php
[root@potato php-7.2.32]# vim /usr/local/nginx/conf/nginx.conf
将
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
更改为
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;
}
在nginx默认访问目录下创建phpinfo文件
[root@potato php-7.2.32]# vim /usr/local/nginx/html/phpinfo.php
<?php
phpinfo();
重启Nginx服务
[root@potato php-7.2.32]# /usr/local/nginx/sbin/nginx -s stop
[root@potato php-7.2.32]# /usr/local/nginx/sbin/nginx