Great article on how to clear the PHP opcache:
https://ma.ttias.be/how-to-clear-php-opcache/
To facilitate use on a Plesk server created script and mapped into namespace:
https://acme.com/opcache_clear
Here’s the script:
1 2 3 4 5 |
<?php echo "Clearing cache ... "; opcache_reset(); echo "DONE!"; ?> |
And here’s the Apache config to map into a virtual host:
1 2 3 4 5 6 7 8 9 10 |
Alias /opcache_clear /var/www/vhosts/acme.com/scripts/opcache_clear.php <Directory /var/www/vhosts/acme.com/scripts> <Files ~ (\.php$)> SetHandler proxy:unix:///var/www/vhosts/system/acme.com/php-fpm.sock|fcgi://127.0.0.1:9000 </Files> AuthType Basic AuthName " " AuthUserFile "/var/www/vhosts/system/acme.com/pd/d..httpdocs@opcache_clear" require valid-user </Directory> |
This above config should be placed in the “Apache & nginx setting” screen in the “Additional directives for https” field. In addition to setting the alias path we’re also setting the PHP handler.
Additionally under “Password protected directories” added password protection for “/opcache_clear”. This is just a placeholder for the password file which is referenced in the above config.