Enabling the PHP 8 JIT Compiler in Plesk
In this article, we explain how to enable and configure the PHP 8 JIT compiler in Plesk Obsidian.
Prerequisites
The following prerequisites must be met in order to enable the JIT compiler:
- Plesk Obsidian 18.0.33 or higher
- OPcache enabled in the Plesk PHP settings (
opcache.enable) - PHP 8.0, PHP 8.1, PHP 8.2, PHP 8.3, PHP 8.4, or PHP 8.5 installed (e.g., via the Plesk graphical interface)
- SSH root access
If PHP 8.0, PHP 8.1, PHP 8.2, or PHP 8.3 has not yet been installed on your creoline server, see the article PHP 8 Installation provides step-by-step instructions on how to install PHP 8 via the Plesk graphical interface.
Enabling the JIT Compiler
To enable this feature, an additional PHP configuration file for the PHP 8 FPM handler must be placed on the server.
Important:
The runtime configuration cannot be enabled via the PHP settings in the Plesk graphical interface.
Execute the following shell command via SSH on your creoline server:
# PHP 8.0
echo -e 'opcache.jit_buffer_size=100M\nopcache.jit=1255' > /opt/plesk/php/8.0/etc/php.d/opcache_jit.ini
# PHP 8.1
echo -e 'opcache.jit_buffer_size=100M\nopcache.jit=1255' > /opt/plesk/php/8.1/etc/php.d/opcache_jit.ini
# PHP 8.2
echo -e 'opcache.jit_buffer_size=100M\nopcache.jit=1255' > /opt/plesk/php/8.2/etc/php.d/opcache_jit.ini
# PHP 8.3
echo -e 'opcache.jit_buffer_size=100M\nopcache.jit=1255' > /opt/plesk/php/8.3/etc/php.d/opcache_jit.ini
# PHP 8.4
echo -e 'opcache.jit_buffer_size=100M\nopcache.jit=1255' > /opt/plesk/php/8.4/etc/php.d/opcache_jit.ini
# PHP 8.5
echo -e 'opcache.jit_buffer_size=100M\nopcache.jit=1255' > /opt/plesk/php/8.5/etc/php.d/opcache_jit.ini After the configuration file has been saved, PHP 8 must be reloaded for the configuration to take effect:
# PHP 8.0
systemctl reload plesk-php80-fpm
# PHP 8.1
systemctl reload plesk-php81-fpm
# PHP 8.2
systemctl reload plesk-php82-fpm
# PHP 8.3
systemctl reload plesk-php83-fpm
# PHP 8.4
systemctl reload plesk-php84-fpm
# PHP 8.5
systemctl reload plesk-php85-fpm To verify that the JIT compiler has been enabled correctly, you can run the following PHP script:
<?php
echo '<pre>';
print_r(opcache_get_status()['jit']); Sample output:
Array
(
[enabled] => 1
[on] => 1
[kind] => 5
[opt_level] => 5
[opt_flags] => 6
[buffer_size] => 104857584
[buffer_free] => 104855104
) Warning:
To test whether the JIT compiler is active, the opcache_get_status function must be explicitly enabled in Plesk. In the default Plesk installation, the function is disabled in the PHP settings under "disable_functions" for security reasons.
Configuring the JIT Compiler
The JIT compiler is configured using the opcache.jit variable. For example: opcache.jit=1255
Each digit represents a setting for a configuration parameter. A detailed explanation can be found in the official RFC (wiki.php.net).
CPU-specific optimization flags (C)
Parameter 1
0 - none
1 - enable AVX instruction generation Register Allocation (R)
Parameter 2
0 - do not perform register allocation
1 - use local linear-scan register allocator
2 - use global linear-scan register allocator JIT trigger (T)
Parameter 3
0 - JIT all functions on first script load
1 - JIT functions on first execution
2 - Profile on the first request and compile hot functions on the second request
3 - Profile on the fly and compile hot functions
4 - Compile functions with the @jit tag in doc-comments
5 - Tracing JIT Optimization level (O)
Parameter 4
0 - Do not use JIT
1 - Minimal JIT (call standard VM handlers)
2 - Selective VM handler inlining
3 - Optimized JIT based on static type inference of individual functions
4 - Optimized JIT based on static type inference and call tree
5 - Optimized JIT based on static type inference and inner procedure analysis Example Configuration
In our example configuration, we use the following settings:
opcache.jit=1255 | Parameter | Value | Description |
|---|---|---|
| CPU-specific optimization flags | 1 | Enable AVX instruction generation |
| Register Allocation | 2 | use global linear-scan register allocator |
| JIT trigger | 5 | Tracing JIT |
| Optimization level | 5 | optimized JIT based on static type inference and inner procedure analysis |