一、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