当前位置: 首页> 健康> 知识 > PHP7.4编译安装

PHP7.4编译安装

时间:2025/7/9 16:35:25来源:https://blog.csdn.net/weixin_45552105/article/details/140424477 浏览次数:0次

一、PHP部署

1.1 安装依赖

[root@localhost ~]# yum install -y epel-release
[root@localhost ~]# yum -y install gcc-c++ libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel gd sqlite sqlite-devel net-snmp net-snmp-devel oniguruma oniguruma-devel

libzip

[root@localhost ~]# wget https://libzip.org/download/libzip-1.2.0.tar.gz --no-check-certificate
[root@localhost ~]# tar -zxvf libzip-1.2.0.tar.gz
[root@localhost ~]# cd libzip-1.2.0
[root@localhost libzip-1.2.0]# ./configure
[root@localhost libzip-1.2.0]# make -j4 && make -j4 install
[root@localhost libzip-1.2.0]# export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/"

1.2 下载官方包

[root@zabbixweb01 ~]# wget  https://www.php.net/distributions/php-7.4.24.tar.gz

1.3 编译安装

[root@localhost ~]# tar -xzvf  php-7.4.24.tar.gz
[root@localhost ~]# cd php-7.4.24
[root@localhost php-7.4.24]# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc -enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mysqlnd-compression-support --enable-opcache --enable-gd --with-iconv  --with-zip --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg --with-freetype --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --without-gdbm --enable-fast-install --disable-fileinfo --enable-bcmath --with-openssl
[root@localhost php-7.4.24]# make -j4 && make -j4 install

1.4 创建配置文件

[root@localhost php-7.4.24]# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
[root@localhost php-7.4.24]# cp php.ini-development /usr/local/php/etc/php.ini
[root@localhost php-7.4.24]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[root@localhost php-7.4.24]# cp sapi/fpm/php-fpm /usr/local/bin

1.5 修改配置文件

[root@localhost php-7.4.24]# vim /usr/local/php/etc/php.ini

## 修改
date.timezone = Asia/Shanghai
post_max_size = 80M
max_execution_time = 300
max_input_time = 600

[root@localhost php-7.4.24]# vim /usr/local/php/etc/php-fpm.d/www.conf

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
user = nginx
group = nginx

1.6 复制启动脚本

[root@localhost php-7.4.24]# cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
[root@localhost php-7.4.24]# chmod 744 /etc/rc.d/init.d/php-fpm

1.7 设置systemd启动文件

[root@localhost php-7.4.24]# vim /usr/lib/systemd/system/php-fpm.service

[Unit]
Description=php-fpm
After=network.target[Service]
Type=forking
ExecStart=/usr/local/php/sbin/php-fpm
ExecStop=/bin/pkill -9 php-fpm
PrivateTmp=true
TimeoutStopSec=5
KillMode=process
RestartSec=10
Restart=always[Install]
WantedBy=multi-user.target

1.8 启动服务

[root@localhost php-7.4.24]# systemctl enable --now php-fpm.service
关键字:PHP7.4编译安装

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: