记录一次 php opcache 中 jit 不能配置成功的排查过程

问题症状: 在配置文件中,配置了 jit , 通过php-fpm 在网页显示一直jit未启用。 通过 php 命令查看没有问题,JIT 运行正常。

解决的方法: 认真查看日志文件

php -c /etc/php/php84.ini -i | grep -i "jit"
auto_globals_jit => On => On
PCRE JIT Support => enabled
PCRE JIT Target => x86 64bit (little endian + unaligned)
pcre.jit => On => On
JIT => On

通过 php-fpm 启动有个 警告信息

 /usr/local/php84/sbin/php-fpm --fpm-config /usr/local/php84/etc/php-fpm.conf -c /etc/php/php84.ini -i  | grep -i "jit"
[13-Apr-2025 14:34:36] NOTICE: PHP message: PHP Warning:  JIT is incompatible with third party extensions that override zend_execute_ex(). JIT disabled. in Unknown on line 0
auto_globals_jit => On => On
PCRE JIT Support => enabled
PCRE JIT Target => x86 64bit (little endian + unaligned)
pcre.jit => On => On
JIT => Disabled

通过 journalctl -u php-fpm84 --no-pager -n 50 | grep -i -E "(Fatal Error)|(PHP Warning) 查看信息

Sun Apr 13 14:28:31 2025 (3640): Fatal Error Insufficient shared memory!
NOTICE: PHP message: PHP Warning:  JIT is incompatible with third party extensions that override zend_execute_ex(). JIT disabled. in Unknown on line 0

可以到内存配置的大小是不合理的。修改配置

[opcache]
zend_extension=opcache.so

opcache.enable=1
opcache.jit = tracing
opcache.memory_consumption=32M
opcache.jit_buffer_size = 8M

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注