一、依赖
# yum install -y libxml2 libxml2-devel
# yum install -y libcurl libcurl-devel
# yum install -y libpng libpng-devel
# yum install -y freetype-devel
# yum install -y libxslt-devel
# yum install -y libjpeg libjpeg-devel
二、下载
# wget http://hk2.php.net/distributions/php-7.2.34.tar.gz
三、安装
3.1 安装
# tar -zxvf php-7.2.34.tar.gz
# cd php-7.2.34
# ./configure --prefix=/usr/local/php7_2 --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysql --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip --with-jpeg-dir=/usr/lib64
# make
# make install
3.2 检测安装
# make test
四、配置php.ini
4.1 php.ini配置
# cp php.ini-development /usr/local/php7_2/lib/php.ini
4.2 php-fpm配置
# cp -R ./sapi/fpm/php-fpm.conf /usr/local/php7_2/etc/php-fpm.conf
4.3 启动
# /usr/local/php7_2/sbin/php-fpm
4.4 查看是否启动
# ps aux | grep php
root 25887 0.0 0.1 220916 5032 ? Ss 18:11 0:00 php-fpm: master process (/usr/local/php7_2/etc/php-fpm.conf)
nobody 25888 0.0 0.1 220916 4596 ? S 18:11 0:00 php-fpm: pool www
nobody 25889 0.0 0.1 220916 4596 ? S 18:11 0:00 php-fpm: pool www
root 25891 0.0 0.0 112660 968 pts/1 S+ 18:11 0:00 grep --color=auto php
4.5 重新启动
# ps aux | grep php
# kill -USR2 25887
4.6 关闭
# kill -INT 25887
五、配置Nginx支持PHP
# cd /usr/local/nginx
# vi ./conf/nginx.conf
location ~ \.php$ {
root /home/wwwroot/Shoper;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/wwwroot/Shoper$fastcgi_script_name;
include fastcgi_params;
}
六、开机自启动
在rc.local增加启动代码:
# vi /etc/rc.d/rc.local
底部增加一行:
/usr/local/php7_2/sbin/php-fpm
设置可执行权限:
# chmod755/etc/rc.local
七、服务化配置
./configure\
--prefix=/application/php\
--with-config-file-path=/application/php/etc\
--enable-fpm\
--with-fpm-user=www\
--with-fpm-group=www\
--with-iconv-dir\
--with-freetype-dir=/usr/local/freetype\
--with-jpeg-dir\
--with-png-dir\
--with-zlib\
--with-libxml-dir=/usr\
--enable-xml\
--disable-rpath\
--enable-bcmath\
--enable-shmop\
--enable-sysvsem\
--enable-inline-optimization\
--with-curl\
--enable-mbregex\
--enable-mbstring\
--with-mcrypt\
--enable-ftp\
--with-gd\
--enable-gd-native-ttf\
--with-openssl\
--with-mhash\
--enable-pcntl\
--enable-sockets\
--with-xmlrpc\
--enable-zip\
--enable-soap\
--with-gettext\
--with-iconv-dir=/usr/local/libiconv\
--disable-fileinfo