安装依赖,已安装的忽略
yum groupinstall "Development Tools"
yum install libxml2-devel openssl-devel libcurl-devel gd-devel gmp-devel libicu-devel recode recode-devel libxslt libxslt-devel
cmake安装
wget https://cmake.org/files/v3.18/cmake-3.18.0-Linux-x86_64.sh
chmod 777 cmake-3.18.0-Linux-x86_64.sh
./cmake-3.18.0-Linux-x86_64.sh
ln -s /work/soft/cmake-3.18.0/bin/cmake /usr/bin/cmake
安装libzip
wget https://libzip.org/download/libzip-1.5.2.tar.gz
tar -zxvf libzip-1.5.2.tar.gz
cd libzip-1.5.2
mkdir build
cd build
cmake .. (#注意:cmake后面有两个小数点)
make && make install
安装PHP-7.3
官网手动下载php源码包 https://www.php.net/downloads.php
tar -zxvf php-7.3.27.tar.gz
cd php-7.3.27/
./configure \
--prefix=/usr/local/php73 \
--with-config-file-path=/usr/local/php73/etc \
--disable-debug \
--disable-phpdbg \
--enable-mysqlnd \
--enable-bcmath \
--with-bz2=/usr \
--enable-calendar \
--with-curl \
--enable-exif \
--enable-fpm \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--with-freetype-dir \
--enable-ftp \
--with-gd \
--with-gettext=/usr \
--with-gmp \
--with-iconv \
--with-iconv-dir=/usr/local/libiconv \
--enable-intl \
--with-jpeg-dir \
--enable-mbstring \
--with-openssl \
--with-mhash \
--enable-pcntl \
--with-pdo-mysql=mysqlnd \
--with-png-dir \
--with-recode \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--with-xmlrpc \
--with-xsl \
--with-zlib=/usr \
--enable-zip \
--with-libxml-dir=/usr \
--enable-xml \
--with-mysqli=mysqlnd \
--enable-fileinfo \
--enable-opcache \
--with-libdir=lib64
make && make install
cp php.ini-development /usr/local/php73/etc/php.ini
修改php.ini配置
vim /usr/local/php73/etc/php.ini
# 找到 ;cgi.fix_pathinfo=0 修改为
cgi.fix_pathinfo=1
# 找到 ;date.timezone = 修改为
date.timezone = PRC
查看版本
/usr/local/php73/bin/php -v
配置php-fpm
cp /usr/local/php73/etc/php-fpm.conf.default /usr/local/php73/etc/php-fpm.conf
vi /usr/local/php73/etc/php-fpm.conf
# 找到 ;pid = run/php-fpm.pid 修改为
pid = /usr/local/php73/var/run/php-fpm.pid
修改www.conf
cp /usr/local/php73/etc/php-fpm.d/www.conf.default /usr/local/php73/etc/php-fpm.d/www.conf
vi /usr/local/php73/etc/php-fpm.d/www.conf
user = nginx
group = nginx
# 找到 listen = 127.0.0.1:9000 如果启了php5 或其它 9000端口被占用的话 修改为
listen = 127.0.0.1:9002
配置 php-fpm 启动脚本 注册为系统服务 设置开机启动
cp /work/soft/php-7.3.27/sapi/fpm/php-fpm /usr/local/php73/bin
cp /work/soft/php-7.3.27/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm73
将/etc/init.d/php-fpm73开始的注释部分php-fpm改为php-fpm73 虽然是注释,但在Linux下注册系统服务要求的格式;如果你不注册为系统服务则不需要改;
vi /etc/init.d/php-fpm73
#! /bin/sh
### BEGIN INIT INFO
# Provides: php-fpm73
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts php-fpm73
# Description: starts the PHP FastCGI Process Manager daemon
### END INIT INFO
授予可执行权限
chmod +x /etc/init.d/php-fpm73
添加php-fpm73至服务列表并设置开机自启
chkconfig --add php-fpm73
chkconfig --list php-fpm73
chkconfig php-fpm73 on
创建php73命令的软连接
ln -s /usr/local/php73/bin/php /usr/bin/php73
php-fpm73 几个参数 start|stop|force-quit|restart|reload|status|configtest
service php-fpm73 start # 启动服务
service php-fpm73 stop # 停止服务
service php-fpm73 restart # 重启服务
service php-fpm73 reload # 平滑重启服务
service php-fpm73 force-quit # 强制退出服务
service php-fpm73 status # 查看服务状态
service php-fpm73 configtest # 检查配置
启动php-fpm73服务
service php-fpm73 configtest # 检查配置 显示如下 说明配置没有问题
# [07-Jun-2018 11:53:45] NOTICE: configuration file /usr/local/php73/etc/php-fpm.conf test is
successful
service php-fpm73 start # 启动
# Starting php-fpm done 启动成功
查看php-frm进程 显示php-fpm73版本 和之前的php-fpm56版本
ps -ef |grep php
root 1805 1 0 09:48 ? 00:00:00 php-fpm: master process (/usr/local/php56/etc/php-fpm.conf)
nobody 1806 1805 0 09:48 ? 00:00:00 php-fpm: pool www
nobody 1807 1805 0 09:48 ? 00:00:00 php-fpm: pool www
root 31580 1 0 11:54 ? 00:00:00 php-fpm: master process (/usr/local/php72/etc/php-fpm.conf)
www 31581 31580 0 11:54 ? 00:00:00 php-fpm: pool www
www 31582 31580 0 11:54 ? 00:00:00 php-fpm: pool www
root 31585 3311 0 11:54 pts/1 00:00:00 grep php