-
Notifications
You must be signed in to change notification settings - Fork 8k
Description
Description
This isn't a PHP bug, but a bug caused by the interoperation of PHP 8.5 and Apache mod-php (NOT fpm),
when systemd is set to be more restrictive.
This occurs in Ubuntu 26.04 ("Resolute Raccoon") - i.e. it's going to be a default problem for a lot of people quite soon. I'm filing it here, so that others can find it (as it took me hours to figure out).
- The error message is:
Warning: preg_match(): Allocation of JIT memory failed, PCRE JIT will be disabled. This is likely caused by security restrictions. Either grant PHP permission to allocate executable memory, or set pcre.jit=0 in [MY PHP FILENAME]
-
Root cause: the way JIT works is to write to memory, then compile the Regex, then make that memory executable. This falls foul of one of the stricter protections added to systemd, namely:
MemoryDenyWriteExecute -
To fix the problem, do
sudo systemctl edit apache2and add the lines
[Service]
MemoryDenyWriteExecute=no
then save and restart apache.
-
ALTERNATIVELY, switch from mod-php to php-fpm.
-
See also: https://bugs.launchpad.net/ubuntu/+source/apache2/+bug/2144455
-
May I request a comment on whether the right thing to do is to disable PHP's JIT, or whether it is in fact safe to remove that recently added systemd restriction. Thanks.
PHP Version
PHP 8.5.2 (cli) (built: Jan 21 2026 17:35:28) (NTS)
Copyright (c) The PHP Group
Built by Ubuntu
Zend Engine v4.5.2, Copyright (c) Zend Technologies
with Xdebug v3.5.0, Copyright (c) 2002-2025, by Derick Rethans
with Zend OPcache v8.5.2, Copyright (c), by Zend Technologies
Using libapache2-mod-php8.5 .
Operating System
Ubuntu 26.04