yum -y install gcc gcc-c++ glibc automake autoconf libtool make
mkdir -p /usr/local/php7
yum -y install libxslt-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel
mkdir -p /usr/local/src/php7
cd /usr/local/src/php7
yum insatll -y wget
wget https://github.com/kitware/CMake/releases/download/v3.14.5/cmake-3.14.5.tar.gz
tar -zxvf cmake-3.14.5.tar.gz
cd cmake-3.14.5
./bootstrap
gmake
gmake install
cmake -version
cd /usr/local/src/php7
wget --no-check-certificate https://libzip.org/download/libzip-1.8.0.tar.gz
tar -zxvf libzip-1.8.0.tar.gz
cd libzip-1.8.0
mkdir build
cd build
cmake ..
make -j2
make test
make install
cd /usr/local/src/php7
wget https://www.php.net/distributions/php-7.3.33.tar.gz
tar -zxvf php-7.3.33.tar.gz
cd php-7.3.33
./configure --prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7 --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip
make && make install
/usr/local/php7/sbin/php-fpm #启动会报错,需要修改配置文件
cp /usr/local/src/php7/php-7.3.33/php.ini-production /usr/local/php7/etc/php.ini
cd /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
vi /usr/local/php7/etc/php-fpm.conf
搜索pid并修改成如下内容
pid = /usr/local/php7/var/run/php-fpm.pid
保存,退出
cd /usr/local/php7/etc/php-fpm.d
cp www.conf.default nginx.conf
useradd nginx
vi nginx.conf
检查用户,组是否是nginx。不是,就进行修改。
检查是否在监听本机的9000端口。
/usr/local/php7/sbin/php-fpm #启动php
lsof -i:9000 #再次检查服务是否起来
vi /etc/profile
export PHP_HOME=/usr/local/php7
export PATH=$PATH:$PHP_HOME/bin:$PHP_HOME/sbin
source /etc/profile
vi /lib/systemd/system/php-fpm.service
[Unit]
Description=php-fpm
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/php7/sbin/php-fpm
ExecStop=/bin/pkill -9 php-fpm
PrivateTmp=true
[Install]
WantedBy=multi-user.target
保存,退出
systemctl daemon-reload
pkill php-fpm
systemctl start php-fpm
systemctl enable php-fpm
systemctl list-units --type=service #查看所有已开启的服务
感谢大家,点赞,收藏,关注,评论!