Files
download/panel/php_exts/Zend OPcache.sh
耗子 a65d23f05b
Some checks failed
Generate Checksums / checksums (push) Has been cancelled
feat: 移除协议
2025-08-22 06:19:40 +08:00

56 lines
2.0 KiB (Stored with Git LFS)
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.cdn.haozi.net/panel/public.sh)
if [ $? -ne 0 ]; then
echo "下载 public.sh 失败,请检查网络或稍后重试。"
echo "Download public.sh failed, please check the network or try again later."
exit 1
fi
action=${1}
version=${2}
php_path="${setup_path}/server/php/${version}"
Install() {
# 检查是否已经安装
is_install=$(cat ${php_path}/etc/php.ini | grep '^zend_extension=opcache$')
if [ "${is_install}" != "" ]; then
error "PHP-${version} 已安装 Zend OPcache"
fi
if [ ${version} -ge "80" ]; then
sed -i '/;panel/a\zend_extension=opcache\nopcache.enable = 1\nopcache.enable_cli=1\nopcache.memory_consumption=128\nopcache.interned_strings_buffer=32\nopcache.max_accelerated_files=100000\nopcache.revalidate_freq=3\nopcache.save_comments=0\nopcache.jit_buffer_size=128m\nopcache.jit=1205' ${php_path}/etc/php.ini
else
sed -i '/;panel/a\zend_extension=opcache\nopcache.enable = 1\nopcache.enable_cli=1\nopcache.memory_consumption=128\nopcache.interned_strings_buffer=32\nopcache.max_accelerated_files=100000\nopcache.revalidate_freq=3\nopcache.save_comments=0' ${php_path}/etc/php.ini
fi
# 重载PHP
systemctl reload php-fpm-${version}.service
echo -e $HR
echo "PHP-${version}Zend OPcache 安装成功"
}
Uninstall() {
# 检查是否已经安装
is_install=$(cat ${php_path}/etc/php.ini | grep '^zend_extension=opcache$')
if [ "${is_install}" == "" ]; then
error "PHP-${version} 未安装 Zend OPcache"
fi
sed -i '/^opcache.*$/d' ${php_path}/etc/php.ini
sed -i '/zend_extension=opcache/d' ${php_path}/etc/php.ini
# 重载PHP
systemctl reload php-fpm-${version}.service
echo -e $HR
echo "PHP-${version} Zend OPcache 卸载成功"
}
if [ "$action" == 'install' ]; then
Install
fi
if [ "$action" == 'uninstall' ]; then
Uninstall
fi