Opcache Preload
CloudPanel v1 is obsolete
CloudPanel v1 is obsolete; check out the CloudPanel v2 Docs.
With >= PHP 7.4, support for opcache preloading was added, a feature that improves the application start performance up to 60%.
caution
Keep in mind that it's a very new feature that might not be bug-free.
Configuration
Some frameworks like Symfony are already providing scripts for preloading the entire code base to improve the performance.
- Open the
php.iniof your PHP Version:
- Search for
opcache.preload_userandopcache.preloadand adjust the values:
By default, all PHP Versions on CloudPanel have a default PHP-FPM Pool running as user clp and group clp.
If you are using a custom PHP-FPM Pool, change the opcache.preload_user.
- Restart PHP-FPM to apply the changes.
Applications
Symfony
You may also want to stay up to date with the Symfony Performance recommendations.
Laravel 7 & 8
Download the preload.php for Laravel 7 & 8 from our Github Repository.
Set the opcache.preload path:
Magento 2
Download the preload.php for Magento 2 from our Github Repository.
Set the opcache.preload path:
Other PHP Apps
You can use the generic preload script and configure it to your needs.
In the bottom of the script, you can add paths to add and ignore.
Testing
To test if the opcache preloading is working as expected we can check the output of opcache_get_status().
- Create a file like
t.phpin your document root:
- Add the lines of php code:
- Restart the PHP-FPM service to clear and preload the opcode cache:
- Open the file in the browser. The output will look like this:
As expected, we see all classes and functions are preloaded into the opcache.