MageHost - Flush the PHP OPcache

Gewijzigd op Di, 20 Dec, 2022 om 2:30 PM

Disclaimer: MageHost has joined forces with Savvii. Therefore, these articles are only relevant to existing MageHost customers. For more information on this, visit www.savvii.com/en/magehost.  


The PHP OPcache increases the performance of your shop by caching processed PHP source code in memory. The MageHost servers are configured to re-read a script when it is changed.

However if you use a deploy method which switches to a new version of the code by replacing a symlink to a new release, PHP does not detect the change. This will cause strange things to happen.

If you use a deployment method which changes one ore more symlinks to point to the new version of the PHP code, you will need to flush the OPcache.


Easy & Recommended: Reload PHP using SSH

Execute this line in SSH, or preferably, in a script after the deploy to flush the PHP OPcache:

$HOME/bin/reload_php.sh

Note: if you are running our mh_queue_consumer.service, this will also be restarted with above script.


Advanced: Web Script

Create a file ~/httpdocs/flush_php.php containing:

<?php 
opcache_reset(); 
clearstatcache(1); 
echo "OK";

You can call this script in a browser or you can call it in an SSH shell:

curl -Lk "https://$VHOSTDOMAIN/flush_php.php"

In case this does not work because of domain issues, you can try:

curl -Lk "http://$VHOSTIP/flush_php.php"


Was dit artikel nuttig?

Dat is fantastisch!

Hartelijk dank voor uw beoordeling

Sorry dat we u niet konden helpen

Hartelijk dank voor uw beoordeling

Laat ons weten hoe we dit artikel kunnen verbeteren!

Selecteer tenminste een van de redenen
CAPTCHA-verificatie is vereist.

Feedback verzonden

We stellen uw moeite op prijs en zullen proberen het artikel te verbeteren