From a652a07f5f89f5a676d8b6971cad2f3e9c85cea5 Mon Sep 17 00:00:00 2001 From: enoch Date: Mon, 27 Jan 2025 17:45:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5JIT=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rhelphp.bash | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/rhelphp.bash b/rhelphp.bash index 8ebd290..94acf76 100644 --- a/rhelphp.bash +++ b/rhelphp.bash @@ -114,7 +114,39 @@ if [[ $? -eq 0 ]]; then if [[ "$is_china" == "yes" ]]; then composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ # 配置Composer使用阿里云镜像 fi + + #开启JIT支持 +# 检查 PHP 是否支持 JIT +PHP_BIN="/opt/remi/php${phpversion}/root/usr/bin/php" +if ! $PHP_BIN -v | grep -q "PHP 8."; then + echo "当前 PHP 版本不支持 JIT(需要 PHP 8.0 或更高版本)" + exit 1 +fi + +# 检查是否已安装 opcache 扩展 +if ! $PHP_BIN -m | grep -q "opcache"; then + echo "opcache 扩展未安装,无法启用 JIT" + exit 1 +fi + +# 配置文件路径 +OPCACHE_CONF="/etc/opt/remi/php${phpversion}/php.d/10-opcache.ini" + +# 确保配置文件存在 +if [ ! -f "$OPCACHE_CONF" ]; then + echo "配置文件 $OPCACHE_CONF 不存在,无法修改 JIT 设置" + exit 1 +fi + +# 删除旧的 JIT 配置并添加新的配置 +sudo sed -i '/opcache.jit_buffer_size/d' "$OPCACHE_CONF" +sudo sed -i '/opcache.jit=/d' "$OPCACHE_CONF" +echo -e "\nopcache.jit_buffer_size=100M\nopcache.jit=tracing" | sudo tee -a "$OPCACHE_CONF" + +# 提示完成 +echo "JIT 配置已成功写入 $OPCACHE_CONF" else echo "Failed to install PHP $phpversion. Please check the logs for details." # 安装失败信息 exit 1 -fi \ No newline at end of file +fi +