In this post we will learn, how to clear apc cache by using php script. A few days back, one of the reader of our blog asked a question. It was about how to clear php APC cache.The question was asked on our previous post on PHP APC error.
Follow the given below steps to clear apc cache
Here in this section we will create a php script called clear_apc.php . With this script , it will clear the APC cache.
Basically we are using apc_clear_cache()
function in PHP script. (Reference: apc_clear_cache )
Step 1: Login to your server. And create a file inside web root directory on your server.
On my server the Web root is at /var/www/html/sharadchhetri_blog . It may be different on your server.
Create a file called clear_apc.php
Replace 192.168.56.101 with your server ip address in below given script’s content.
vi clear_apc.php
And paste below given contents.
true)); } else { die('No valid IP'); } ?>
Step 2: Change the permission of script . Make the file clear_apc.php executable
chmod 700 clear_apc.php
Step 3: Now execute the script by using below wget command .
Replace https://sharadchhetri.com with your website URL
Example. from our site
wget -O - -q https://sharadchhetri.com/clear_apc.php
This will clear the php apc cache.
Note: If wget command not found then install it. (RHEL/CentOS: yum install wget
, Ubuntu/Debian : sudo apt-get install wget
)
Hey,
I just want to say you’re a god send 🙂
Regards,
Cole