I just installed Opcache
and everything seems working just fine, but when I add a PHP file in opcache.preload
in php.ini
and restart the Apache server doesn't start. On the other hand, In CLI SAPI preloading works fine!
When I comment out opcache.preload
and restart, the Apache server works
Since this issue is not emitting any error I looked up Apache error_log
file and it turns out the issue was me not defining the opcahe preload user
Fatal Error "opcache.preload_user" has not been defined
But according to PHP documentation
Preloading code as root is not allowed for security reasons. This directive facilitates to let the preloading to be run as another user.
I'm working on my personal computer running Ubuntu under WSL
So please guide me what should I do? what user should I add?
The default user for web servers on Ubuntu is www-data
All you need to do is
opcache.preload_user=www-data
And if you want to check preloading
var_dump(opcache_get_status()['preload_statistics']);
It will list all preloaded files as well as the memory consumed by them
As for why Apache refuses to start when I don't define a preload user?
I actually don't know why. It might be a bug, not sure though.
While the statement from PHP documentation is not complete, but note that:
Preloading under root is not allowed by default, but explicit use of opcache.preload_user=root is allowed
- Nikic
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With