How To Install Alternative PHP Cache (APC) on Ubuntu 14.04

June 14, 2014 97.7k views
Can some one help me out with installing Alternative PHP Cache (APC) on Ubuntu 14.04 and configure with wordpress. I did find a tutorial here: https://www.digitalocean.com/community/tutorials/how-to-install-alternative-php-cache-apc-on-a-cloud-server-running-ubuntu-12-04 But it talks about APC on ubuntu 12, does the same steps apply for Ubuntu 14?
2 comments
3 Answers
APC is no longer needed in Ubuntu 14.04. It doesn't support PHP 5.5 which comes with its own built-in Opcache cache instead. To ensure that it is enabled, edit /etc/php5/apache2/php.ini and change:
;opcache.enable=0
to
opcache.enable=1
Next, make sure the php mod is enabled:
php5enmod opcache
Finally restart Apache:
service apache2 restart
Check out this previous question for some more configuration options: https://www.digitalocean.com/community/questions/enable-php-5-5-opcache-on-ubuntu-14-04-with-nginx-and-php-fpm
  • ;opcache.enable=0

    to

    opcache.enable=1

    did u mean i dont have to add ";" ???

  • @newbie: no -- you actually need to delete the semicolon (;). Otherwise, the line would be considered "commented" and it wouldn't take effect.

  • thx for reply bro.

    i have changed without (;) but still in w3tc compatibility Opcode cache: Not installed :(

    by the way when i run php5enmod opcache in putty nothing happens..

Just in Reply to ASB, W3 Total cache doesn't support Zend's Opcache - and isn't planning on doing so according to the author of the plugin (for some strange reason?)... So, even though APC isn't going to be supported by PHP-5 into the future (it works fine now), it is currently the only working option other than installing memcache.

  • Hello,
    so is that means i wont be able to chose cache method to Opcode: Alternative php cache (APC) in w3tc for minify, database, object etc???
    i just installed apc on my server but in w3tc still all option for APC is grayed out :(

    in compatibility check "Opcode cache: Not installed"

    and by the way, mistakenly i was applied as per ubuntu 12.04. do i have to remove all the editing i have done on that tutorial?

    for example:
    extension = apc.so
    apc.shm_size = 64

When i enter this command it gives this in reply ; SO IF THEIR IS SOLUTION THEN TELL ME

"""

root@rebuildweb-gui:~# sudo apt-get install php-apc
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package php-apc is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'php-apc' has no installation candidate

"""

Have another answer? Share your knowledge.