PHP7.4编译安装

一、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
相关推荐
寰宇软件23 分钟前
PHP校园助手系统小程序
小程序·vue·php·uniapp
ac-er888813 小时前
Yii框架优化Web应用程序性能
开发语言·前端·php
寰宇软件17 小时前
PHP同城配送小程序
微信小程序·vue·php·uniapp
寰宇软件19 小时前
PHP企业IM客服系统
微信小程序·vue·php·uniapp
嵌入式小强工作室1 天前
esp32实现联网控制
开发语言·php
希望奇迹很安静1 天前
[极客大挑战 2019]PHP
开发语言·学习·web安全·php·ctf·buuctf
很酷的站长1 天前
怎么创建一个能在线测试php的html5网页?
开发语言·php·html5
Aimin20221 天前
Debian 上安装PHP
linux·debian·php
vortex51 天前
正则表达式基础与应用
正则表达式·php
互联网动态分析1 天前
PHP:从入门到进阶的全方位指南
php