Linux, php

Enable APC on PHP CLI

I have posted hours ago about creating cron job for php scripts via cron. Of course it was just the last resort since there are things that don’t work on regular PHP CLI scripts.

After some research and after asking some feedbacks regarding the advantage of using CURL, I prefer PHP CLI. Moreover, I can completely hide the PHP script from the publicly viewable directory into a directory not viewable by the web.

First, you need to enable PHP CLI of course. On my case, the problem was the APC not configured for CLI. I have followed the procedure written here:

Enable APC on CLI (Ubuntu)

But I’ve missed the part where the correct file was located. I edited /etc/php5/apache2/php.ini which was for Apache / Web and not for CLI. So to fix that, I finally edited: /etc/php5/cli/php.ini

sudo nano /etc/php5/cli/php.ini

and entered the following at the bottom:

extension=apc.so
apc.enabled = 1
apc.enable_cli = 1

I think there is no need to restart Apache this time since it is not Apache related, but if you really want to:

sudo /etc/init.d/apache2 restart

3 thoughts on “Enable APC on PHP CLI”

Leave a reply

Your email address will not be published. Required fields are marked *