#安装相关包
[root@tencent-centos7 ~]#yum -y install gcc libxml2-devel bzip2-devel libmcrypt-devel sqlite-devel oniguruma-devel
#编译
[root@tencent-centos7 ~]#tar xvf php-7.4.12.tar.bz2
[root@tencent-centos7 ~]#cd php-7.4.12
[root@tencent-centos7 php-7.4.12]#./configure
--prefix=/apps/php74
--enable-mysqlnd
--with-mysqli=mysqlnd
--with-pdo-mysql=mysqlnd
--with-openssl
--with-zlib
--with-config-file-path=/etc
--with-config-file-scan-dir=/etc/php.d
--enable-mbstring
--enable-xml
--enable-sockets
--enable-fpm
--enable-maintainer-zts
--disable-fileinfo
[root@tencent-centos7 php-7.4.12]#make -j 8 && make install
#准备PATH变量
[root@tencent-centos7 php-7.4.12]#echo 'PATH=/apps/php74/bin:$PATH' > /etc/profile.d/php.sh
[root@tencent-centos7 php-7.4.12]#. /etc/profile.d/php.sh
# 查看版本信息,确认安装成功
[root@tencent-centos7 php-7.4.12]#php --version
PHP 7.4.12 (cli) (built: Nov 11 2020 21:36:08) ( ZTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
#准备php配置文件和启动文件
[root@tencent-centos7 php-7.4.12]#cp php.ini-production /etc/php.ini
[root@tencent-centos7 php-7.4.12]#cp sapi/fpm/php-fpm.service /usr/lib/systemd/system/
[root@tencent-centos7 php-7.4.12]#cd /apps/php74/etc
[root@tencent-centos7 etc]#cp php-fpm.conf.default php-fpm.conf
[root@tencent-centos7 etc]#cd php-fpm.d/
[root@tencent-centos7 php-fpm.d]#cp www.conf.default www.conf
# 修改php-fpm配置文件
[root@tencent-centos7 php-fpm.d]#vim /apps/php74/etc/php-fpm.d/www.conf
#修改进程所有者
user apache
group apache
#支持status和ping页面
pm.status_path = /status
ping.path = /ping
#开启opcache加速
[root@tencent-centos7 php-fpm.d]#mkdir /etc/php.d/
[root@tencent-centos7 php-fpm.d]#vim /etc/php.d/opcache.ini
[opcache]
zend_extension=opcache.so
opcache.enable=1
[root@tencent-centos7 php-fpm.d]#systemctl daemon-reload
[root@tencent-centos7 php-fpm.d]#systemctl enable --now php-fpm.service