98 lines
3.0 KiB
Bash
98 lines
3.0 KiB
Bash
#!/bin/bash
|
|
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH
|
|
|
|
source <(curl -f -s --connect-timeout 10 --retry 3 https://dl.acepanel.net/public.sh)
|
|
if [ $? -ne 0 ]; then
|
|
echo "Download public.sh failed, please check the network or try again later."
|
|
exit 1
|
|
fi
|
|
|
|
slug=${1}
|
|
version=${2}
|
|
php_path="${setup_path}/server/php/${slug}"
|
|
j=$(calculate_j)
|
|
|
|
# 预检查
|
|
systemctl is-active --quiet php-fpm-${slug}
|
|
if [ "$?" != "0" ]; then
|
|
error "Application is not running properly"
|
|
fi
|
|
|
|
# 准备安装目录
|
|
cd ${php_path}
|
|
rm -rf src
|
|
|
|
# 下载源码
|
|
dl "${php_path}" "/php/php-${version}.7z"
|
|
|
|
7z x php-${version}.7z
|
|
rm -f php-${version}.7z
|
|
mv php-* src
|
|
|
|
# 配置
|
|
cd src
|
|
chmod +x buildconf
|
|
chmod +x configure
|
|
chmod +x build/shtool
|
|
chmod +x build/config-stubs
|
|
chmod +x build/*.sh
|
|
|
|
# PHP <= 80 openssl3 补丁
|
|
if [ ${slug} -le "80" ]; then
|
|
dl "${php_path}/src" "/php/php-${slug}-openssl3.patch"
|
|
patch -p1 <php-${slug}-openssl3.patch
|
|
fi
|
|
|
|
# 个别系统可能没有libavif
|
|
WITH_AVIF=""
|
|
if pkg-config --exists libavif; then
|
|
WITH_AVIF="--with-avif"
|
|
fi
|
|
|
|
# EOL 补丁版本中没有附带 configure 文件
|
|
if [ ! -f "configure" ]; then
|
|
./buildconf --force
|
|
fi
|
|
|
|
# 8.5 原生支持 OPcache
|
|
WITH_OPCACHE="--enable-opcache"
|
|
[[ ${slug} -ge "85" ]] && WITH_OPCACHE=""
|
|
|
|
# 配置
|
|
if [ ${slug} -ge "81" ]; then
|
|
./configure --prefix=${php_path} --with-config-file-path=${php_path}/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-fpm-systemd --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-freetype --with-jpeg --with-zlib --enable-xml --disable-rpath --enable-bcmath --enable-shmop --with-curl --enable-mbregex --enable-mbstring --enable-pcntl --enable-ftp --enable-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --enable-soap --disable-fileinfo ${WITH_OPCACHE} --with-sodium --with-webp ${WITH_AVIF}
|
|
else
|
|
./configure --prefix=${php_path} --with-config-file-path=${php_path}/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-fpm-systemd --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-freetype --with-jpeg --with-zlib --enable-xml --disable-rpath --enable-bcmath --enable-shmop --with-curl --enable-mbregex --enable-mbstring --enable-pcntl --enable-ftp --enable-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --enable-soap --disable-fileinfo ${WITH_OPCACHE} --with-sodium --with-webp
|
|
fi
|
|
|
|
# RHEL 8 PHP 8.3+ 修复
|
|
# https://github.com/php/php-src/issues/12774
|
|
if [ ${OS} == "rhel" ] && [ $(rpm -E %{rhel}) == "8" ] && [ ${slug} -ge "83" ]; then
|
|
sed -i 's|^CC = cc|CC = cc -fPIE -pie|g' Makefile
|
|
sed -i 's|^BUILD_CC = cc|BUILD_CC = cc -fPIE -pie|g' Makefile
|
|
fi
|
|
|
|
# 编译安装
|
|
make "-j${j}"
|
|
if [ "$?" != "0" ]; then
|
|
error "Compilation failed"
|
|
fi
|
|
|
|
# 停止已有服务
|
|
systemctl stop php-fpm-${slug}
|
|
|
|
make install
|
|
if [ ! -f "${php_path}/bin/php" ]; then
|
|
error "PHP-${slug} installation failed"
|
|
fi
|
|
|
|
# 启动php
|
|
systemctl start php-fpm-${slug}
|
|
if [ "$?" != "0" ]; then
|
|
error "PHP-${slug} startup failed"
|
|
fi
|
|
|
|
echo -e $HR
|
|
echo "Upgrade successful"
|
|
echo -e $HR
|