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
This entry was posted in Bash, Linux, php and tagged , , , , , , . Bookmark the permalink.

Related Posts

3 Responses to Enable APC on PHP CLI

  1. David says:

    It must be “apc.enable_cli = 1” … without the “d” in enabled but only for the cli config line.

  2. Craig says:

    David has it right. The third line should be apc.enable_cli=1

  3. lysender says:

    Sorry, took me too long to update the post. 😀

Leave a Reply

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