php8.3.0安装及扩展安装
部署环境及版本
系统版本:CentOS Linux release 7.9.2009
php版本:8.3.0
部署前准备
1、关闭自带防火墙,安装iptables
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
systemctl stop firewalld
systemctl disable firewalld
yum install -y iptables-services
systemctl start iptables
systemctl enable iptables.service
2、时间同步
yum -y install ntp
systemctl enable ntpd
systemctl start ntpd
timedatectl set-timezone Asia/Shanghai
ntpdate -u time.nist.gov
date
一、安装php8.3.0
1、安装依赖
yum -y install epel-release
yum -y update
yum install -y gcc gcc-c++ freetype-devel bzip2-devel curl-devel autoconf libxml2-devel libjpeg-devel libpng-devel libxslt-devel libzip-devel libmcrypt mhash wget sqlite-devel oniguruma oniguruma-devel
useradd work
2、创建安装目录并解压
mkdir -pv /server/tools
cd /server/tools
wget https://www.php.net/distributions/php-8.3.0.tar.gz
tar xvf php-8.3.0.tar.gz
3、升级openssl
yum remove openssl-1.0.2k-26.el7_9.x86_64
cd /server/tools
wget https://www.openssl.org/source/openssl-1.1.1i.tar.gz
tar xvf openssl-1.1.1i.tar.gz
./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl --shared zlib
make && make install
cd /usr/local/openssl/bin && ./openssl version
ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/lib64/
ln -s /usr/local/openssl/lib/libcrypto.so.1.1 /usr/lib64/
3、编译安装php8.3.0
cd /server/tools/php-8.3.0
./configure --prefix=/data/php --with-fpm-user=work --with-fpm-group=work --with-curl --with-gettext --with-kerberos --with-libdir=lib64 --with-mysqli --with-openssl=/usr/local/openssl --with-pdo-mysql --with-pdo-sqlite --with-pear --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-fpm --enable-ctype
yum install krb5-devel krb5-libs krb5-workstation -y
升级openssl,重新检测还是不行的话
mkdir -pv /usr/local/lib/pkgconfig
ln -s /usr/local/openssl/lib/pkgconfig/openssl.pc /usr/local/lib/pkgconfig
ln -s /usr/local/openssl/lib/pkgconfig/libcrypto.pc /usr/local/lib/pkgconfig
ln -s /usr/local/openssl/lib/pkgconfig/libssl.pc /usr/local/lib/pkgconfig
vim ~/.bash_profile
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
source ~/.bash_profile
pkg-config --list-all
./configure --prefix=/data/php --with-fpm-user=work --with-fpm-group=work --with-curl --with-gettext --with-kerberos --with-libdir=lib64 --with-mysqli --with-openssl=/usr/local/openssl --with-pdo-mysql --with-pdo-sqlite --with-pear --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-fpm --enable-ctype
make && make install
4、配置环境变量
sed -i 's/PATH=.*/&:\/data\/php\/bin/g' ~/.bash_profile
source ~/.bash_profile
5、修改配置文件
cp /server/tools/php-8.3.0/php.ini-production /data/php/lib/php.ini
cp /data/php/etc/php-fpm.conf.default /data/php/etc/php-fpm.conf
ln -s /data/php/sbin/php-fpm /usr/local/bin/php
cp /data/php/etc/php-fpm.d/www.conf.default /data/php/etc/php-fpm.d/www.conf
sed -i 's/;listen.mode = 0660/listen.mode = 0660/g' /data/php/etc/php-fpm.d/www.conf
sed -i '/^pm.max_children/s/5/25/' /data/php/etc/php-fpm.d/www.conf
sed -i '/^pm.start_servers/s/2/5/' /data/php/etc/php-fpm.d/www.conf
sed -i '/^pm.min_spare_servers/s/1/2/' /data/php/etc/php-fpm.d/www.conf
sed -i '/^pm.max_spare_servers/s/3/10/' /data/php/etc/php-fpm.d/www.conf
sed -i '/pm.max_requests/s/;pm.max_requests = 500/pm.max_requests = 10000/' /data/php/etc/php-fpm.d/www.conf
sed -i 's/;rlimit_files = 1024/rlimit_files = 1024/g' /data/php/etc/php-fpm.d/www.conf
sed -i 's/;slowlog = log\/$pool.log.slow/slowlog = log\/$pool.log.slow/g' /data/php/etc/php-fpm.d/www.conf
6、配置systemctl启动php
cd /usr/lib/systemd/system/
cat>php-fpm.service<<EOF
[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target
[Service]
Type=forking
#PIDFile=/var/run/php-fpm.pid
ExecStart=/data/php/sbin/php-fpm
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl start php-fpm
systemctl enable php-fpm
二、安装amqp扩展
1、安装rabbitmq-c
1)安装cmake
1、安装必备依赖库
yum install -y gcc gcc-c++ make automake wget
2、下载安装包
cd /server/tools
wget https://cmake.org/files/v3.26/cmake-3.26.3.tar.gz
3、解压并安装
tar xvf cmake-3.26.3.tar.gz
cd cmake-3.26.3
./bootstrap
gmake
gmake install
4、检测是否安装成功
cmake --version
2)安装rabbitmq-c
wget https://github.com/alanxz/rabbitmq-c/archive/v0.14.0.tar.gz
tar zxvf v0.14.0.tar.gz
cd rabbitmq-c-0.14.0
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/rabbitmq-c ..
cmake --build . --target install
3)安装amqp
wget https://pecl.php.net/get/amqp-2.1.2.tgz
tar zxvf amqp-2.1.2.tgz
cd /server/tools/amqp-2.1.2
/data/php/bin/phpize
./configure --with-php-config=/data/php/bin/php-config --with-amqp --with-librabbitmq-dir=/usr/local/rabbitmq-c
make && make install
yum install -y librabbitmq-devel
make && make install
vim /data/php/lib/php.ini
extension=amqp.so
systemctl restart php-fpm
php -m
2、安装gd扩展
1)安装zlib
cd /server/tools
wget https://www.zlib.net/fossils/zlib-1.2.11.tar.gz
tar xzvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make && make install
2)安装freetype
cd /server/tools
wget https://download.savannah.gnu.org/releases/freetype/freetype-2.9.tar.gz
tar -xzvf freetype-2.9.tar.gz
cd freetype-2.9
./configure --prefix=/usr/local/lib/freetype
make && make install
3)安装libpng
cd /server/tools
wget https://nchc.dl.sourceforge.net/project/libpng/libpng16/1.6.43/libpng-1.6.43.tar.gz
tar -xzvf libpng-1.6.43.tar.gz
cd libpng-1.6.43
./configure --prefix=/usr/local/lib/libpng
make && make install
4)安装libjpeg
cd /server/tools
wget https://www.ijg.org/files/jpegsrc.v9f.tar.gz
tar -xzvf jpegsrc.v9f.tar.gz
cd jpeg-9f
./configure --prefix=/usr/local/lib/libjpeg --enable-shared
make && make install
5)安装GD
cd /server/tools/php-8.3.0/ext/gd
/data/php/bin/phpize
./configure --with-php-config=/data/php/bin/php-config --with-jpeg --with-freetype
make && make install
vim /data/php/lib/php.ini
extension=gd.so
systemctl restart php-fpm
php -m
3、安装redis扩展
cd /server/tools
wget https://pecl.php.net/get/redis-5.3.4.tgz
tar xvf redis-5.3.4.tgz
cd /server/tools/redis-5.3.4
/data/php/bin/phpize
./configure --with-php-config=/data/php/bin/php-config
make && make install
vim /data/php/lib/php.ini
extension=redis
systemctl restart php-fpm
php -m
部署问题总结
./configure --prefix=/data/php --with-fpm-user=work --with-fpm-group=work --with-curl --with-gettext --with-kerberos --with-libdir=lib64 --with-mysqli --with-openssl --with-pdo-mysql --with-pdo-sqlite --with-pear --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-fpm --enable-ctype
yum install krb5-devel krb5-libs krb5-workstation -y
升级openssl,重新检测还是不行的话
mkdir -pv /usr/local/lib/pkgconfig
ln -s /usr/local/openssl/lib/pkgconfig/openssl.pc /usr/local/lib/pkgconfig
ln -s /usr/local/openssl/lib/pkgconfig/libcrypto.pc /usr/local/lib/pkgconfig
ln -s /usr/local/openssl/lib/pkgconfig/libssl.pc /usr/local/lib/pkgconfig
vim ~/.bash_profile
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
source ~/.bash_profile
pkg-config --list-all
ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/lib64/
ln -s /usr/local/openssl/lib/libcrypto.so.1.1 /usr/lib64/
安装cmake
yum install -y librabbitmq-devel