1、安装依赖在这里插入代码片
yum -y install oniguruma-devel sqlite-devel libjpeg libjpeg-devel libpng libpng-devel libpng libpng-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel curl curl-devel openssl openssl-devel
2、上传解压PHP
PHP-7.4.30文件链接:https://pan.baidu.com/s/1VFBNEMJleSDDFZ_ps7SR-Q
提取码:e8sk
进入上传PHP文件所在目录解压文件
tar -xvzf php-7.4.30.tar.gz
cd php-7.4.30
3、编译
./configure --prefix=/usr/local/php --with-mysql-sock=/usr/local/mysql/mysql.sock --with-mysqli --with-zlib --with-curl --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-openssl --enable-fpm --enable-mbstring --enable-xml --enable-session --enable-ftp --enable-pdo --enable-tokenizer --enable-zip
4、安装
make && make install
5、修改配置
cp php.ini-development /usr/local/php/lib/php.ini
vim /usr/local/php/lib/php.ini
这2行添加到/usr/local/php/lib/php.ini中
/1170行 mysqli.default_socket = /usr/local/mysql/mysql.sock
/939行 date.timezone = Asia/Shanghai
删除前面的注释
6、验证PHP安装模块
/usr/local/php/bin/php -m
7、复制主配置文件及php-fpm 配置文件
cd /usr/local/php/etc/cp php-fpm.conf.default php-fpm.confcd /usr/local/php/etc/php-fpm.d/cp www.conf.default www.conf
8、开启pid 支持(可运行) 取消注释
cd /usr/local/php/etc/vi php-fpm.confpid = run/php-fpm.pid
#启动php -c 代表 conf/usr/local/php/sbin/php-fpm -c /usr/local/php/lib/php.ininetstat -anpt | grep 9000
ln -s /usr/local/php/bin/* /usr/local/bin/
ps aux | grep -c "php-fpm" //查看php的进程
来源地址:https://blog.csdn.net/qq_40787608/article/details/128605278