CentOS7 编译安装PHP7.2
1、安装编译依赖,下载源码包
[root@localhost ~]# yum install -y gcc gcc-c++ recode-devel gmp-devel libxml2 libxml2-devel openssl openssl-devel curl-devel freetype-devel libxslt libxslt-devel libjpeg-devel unixODBC-devel libicu-devel libmcrypt-devel autoconf ImageMagick-devel libzip-devel
[root@localhost ~]# wget https://www.php.net/distributions/php-7.2.34.tar.gz
2、配置编译参数
[root@localhost php-7.2.34]# ./configure --prefix=/usr/local/php72 \
--with-config-file-path=/usr/local/php72/etc \
--with-config-file-scan-dir=/usr/local/php72/etc/conf.d \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--with-pear \
--with-curl \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-zlib \
--with-iconv-dir \
--with-mhash \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-openssl \
--with-xsl \
--with-recode \
--with-libxml-dir \
--with-xmlrpc \
--with-gettext \
--enable-mysqlnd \
--enable-mysqlnd-compression-support \
--enable-sockets \
--enable-soap \
--enable-mbstring \
--enable-gd-jis-conv \
--enable-zip \
--enable-xml \
--enable-bcmath \
--enable-calendar \
--enable-shmop \
--enable-dba \
--enable-wddx \
--enable-sysvsem \
--enable-sysvshm \
--enable-sysvmsg \
--enable-opcache \
--enable-pcntl \
--enable-maintainer-zts
4、编译安装
[root@localhost php-7.2.34]# make -j4 && make -j4 install
5、拷贝配置文件及脚本
[root@localhost php-7.2.34]# cp -r php.ini-production /usr/local/php72/etc/php.ini
[root@localhost php-7.2.34]# cp -r sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm72
[root@localhost php-7.2.34]# cp -r sapi/fpm/php-fpm.conf /usr/local/php72/etc/php-fpm.conf
[root@localhost php-7.2.34]# cp sapi/fpm/www.conf /usr/local/php72/etc/php-fpm.d/
6、新建服务启动用户,并启动服务
[root@localhost php-7.2.34]# useradd www -M -d / -s /sbin/nologin
[root@localhost php-7.2.34]# chmod +x /etc/init.d/php72-fpm
[root@localhost php-7.2.34]# /etc/init.d/php72-fpm start