用php的官网,有很多源的,想要什么版本可以自己选一下

https://www.php.net/downloads.php

1.安装依赖包

yum -y install gcc gcc-c++ libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel libicu-devel freetype-devel openldap-devel openldap openldap-devel libtool sqlite-devel

cp -frp /usr/lib64/libldap* /usr/lib/

2创建用户组和用户

groupadd www
useradd -g www www

3.安装oniguruma

https://github.com/kkos/oniguruma/releases

tar -zxvf oniguruma-6.9.5.tar.gz

cd oniguruma-6.9.5

./configure --prefix=/usr --libdir=/lib64

make && make install

4.编译安装php

cd php-7.4.12

./configure --prefix=/usr/local/php --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mysqlnd-compression-support --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --with-mcrypt --with-libmbfl --enable-ftp --enable-gd-jis-conv --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache --with-pear --enable-maintainer-zts --with-ldap=shared --enable-gd --with-jpeg --with-freetype

make && make install

5.映射全局命令

ln -s /usr/local/php/sbin/* /usr/local/sbin/
ln -s /usr/local/php/bin/* /usr/local/bin/

6.配置php-fpm

cp php.ini-production /usr/local/php/lib/php.ini

cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf

7.添加环境变量

vim /etc/profile

export PATH=$PATH:/usr/local/php/bin

source /etc/profile

8.启动

php-fpm

php -v

lsof -i:9000 端口启动则为正常