Centos9安装php7.4.33

php7的最后一个版本在centos9上由于openssl以及net-snmp新版本不兼容了, 得打2个补丁才能安装

source /etc/os-release
yum -y -q --skip-broken install tcpdump iftop net-tools rsync  vim-enhanced subversion git curl nss zip unzip  wget crontabs iptables file mlocate flex diffutils   dnf dnf-plugins-core
yum  -y -q install https://rpms.remirepo.net/enterprise/remi-release-${VERSION_ID}.rpm
dnf config-manager --set-enabled remi #centos7/8
dnf config-manager --set-enable crb  #centos9
dnf config-manager --set-enabled powertools  #centos8

yum -y -q --skip-broken install gcc gcc-c++ autoconf automake imake make cmake patch libtool-libs libtool  cronie.x86_64 net-snmp.$(uname -m) net-snmp-utils fping mariadb-server mariadb MySQL-python rrdtool jwhois ipmitool graphviz ImageMagick cpp icu  re2c  bison mlocate flex diffutils
yum -y -q --skip-broken install {kernel,zlib,libevent,libxml2,freetype,gd,libjpeg,libpng,ncurses,curl,readline,openssl,glibc,glib2,bzip2,e2fsprogs,libidn,gettext,expat,libcap,libtool-ltdl,pam,libxslt,libc-client,freetds,unixODBC,libXpm,krb5,libicu,sqlite,oniguruma,libmcrypt,libsodium,rrdtool,libssh2,net-snmp,libsqlite3x,gmp,libwebp,oniguruma-, rrdtool}-devel

dnf -y install libzip-devel oniguruma-devel rrdtool-devel uw-imap-devel 

支持openssl3和net-snmp5.9的补丁

prefix="/opt/php7"
 git clone https://github.com/php/php-src.git
cd php-src
git checkout PHP-7.4
autoconf
autoheader
wget http://www.kvm.la/usr/uploads/2023/06/2573259142.patch  -O php-7.4-openssl3.0.patch
wget http://www.kvm.la/usr/uploads/2023/06/3393061476.patch -O php-7.4.26-snmp.patch
patch ext/snmp/snmp.c <php-7.4.26-snmp.patch
patch ext/openssl/openssl.c < php-7.4-openssl3.0.patch
 ./configure --quiet --prefix=$prefix/usr --with-config-file-path=$prefix/etc  --with-config-file-scan-dir=$prefix/etc/php.d  --sysconfdir=$prefix/etc --sbindir=$prefix/sbin --bindir=$prefix/bin --localstatedir=$prefix/var --enable-fpm --enable-bcmath --enable-exif --enable-ftp --enable-mbstring --enable-soap --enable-sockets  --with-curl --with-gettext --with-openssl  --with-mhash  --with-mysql-sock=/var/lib/mysql/mysql.sock  --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-snmp --with-imap --with-imap-ssl --with-kerberos --with-zlib --enable-intl=shared --enable-xml --disable-rpath --enable-shmop --enable-sysvsem --enable-mbregex  --enable-pcntl --enable-opcache --enable-exif  --with-sqlite3 --with-pdo-sqlite --enable-calendar --with-freetype --with-jpeg --enable-gd  --with-webp --with-sodium --with-zip --with-pear --with-gmp   --enable-intl  --with-libdir=lib64 2>&1 >/dev/null;
make --quiet -j `grep name /proc/cpuinfo|wc -l` 2>&1 >/dev/null
make install 2>&1 >/dev/null

 

 

MMP要简单还是直接用remi源安装吧.

dnf install -y http://rpms.remirepo.net/enterprise/remi-release-9.rpm
dnf -y --enablerepo=remi  php74 php74-php-{fpm,pdo,gd,mysqlnd,xml,pdo,snmp,imap,bcmath,exif,ftp,mbstring,soap,sockets,opcache,calendar,intl,gmp,pear,sodium}  php74-php-pecl-{mysql,ssh2,rrd,zip}  --skip-broken
ln -s /etc/opt/remi/php74/ /opt/php7
echo "zend_extension='/opt/ioncube/ioncube_loader_lin_7.4.so'">> /opt/php7/php.ini
prefix=/opt/php7
rm -f $prefix/php-fpm.d/www.conf
cat>$prefix/php-fpm.conf<<EOF
[global]
pid = run/php-fpm.pid
error_log = log/php-fpm.log
log_level = warning
emergency_restart_threshold = 30
emergency_restart_interval = 60s
process_control_timeout = 5s
daemonize = yes
include=$prefix/php-fpm.d/*.conf
EOF
cat>$prefix/php-fpm.d/default.conf<<EOF
[default]
;listen=127.0.0.1:9006
listen=/dev/shm/php7-fpm.sock
listen.mode=0666
user=nobody
group=nobody
pm=dynamic
pm.max_children=128
pm.start_servers=20
pm.min_spare_servers=5
pm.max_spare_servers=35
pm.max_requests=10000
rlimit_files=51200
slowlog=log/\$pool.log.slow
env[PATH] = /usr/local/bin:/usr/bin:/bin:$prefix/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
EOF
systemctl restart  php74-php-fpm

php目录/etc/opt/remi/php74/

php.ini目录/etc/opt/remi/php74/php.ini

php-fpm目录/etc/opt/remi/php74/php-fpm.d

php二进制地址 /usr/bin/php74  /usr/bin/php74-cgi  /usr/bin/php74-phar

添加新评论 »