Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I enable opcache preloading in PHP 7.4?

I'd like to enable opcache preloading (RFC) on my production servers in PHP 7.4.

I'm using Symfony 4 if it changes anything.

like image 536
emix Avatar asked Dec 12 '19 07:12

emix


People also ask

How do I use OPCache in PHP?

OPCache can only be compiled as a shared extension under this version. Firstly, you need to enable the building of default extension with –enable-opcache option to make it available. Afterwards, you can use the zend_extension configuration directive to lead the OP Cache extension into PHP.


1 Answers

First of all you should add:

opcache.preload=/path/to/project/preload.php

to your php.ini

Then in your PHP script you should pass in opcache_compile_file($file); each file you want to preloaded.

like image 77
MorganFreeFarm Avatar answered Sep 22 '22 17:09

MorganFreeFarm