Saturday, July 4, 2015

The Easiest Way to Install APC on Amazon Linux EC2 Servers

APC or Alternative PHP Cache, is a free open-sourced "opcode cache" for PHP. It caches commonly run PHP processes into memory so that they don't have to be compiled every time. If you are running a Drupal or Wordpress site, this can really improve the performance of your website and server.
Installing the PHP APC module on Amazon Linux is this simple:
sudo yum install -y php-pecl-apc
Then go to /etc/php.d/apc.ini and make sure the process is enabled. Once you've got APC installed, you can check to see if it is running by copying the apc.php script to the webroot and navigating to it in your browser. This control panel will also give you some very useful statistics. From the PHP.net manual on APC:
Once the server is running, the apc.php script that is bundled with the extension should be copied somewhere into the docroot and viewed with a browser as it provides a detailed analysis of the internal workings of APC. If GD is enabled in PHP, it will even display some interesting graphs. The first thing to ensure, of course, is that it is actually caching files.
If APC is working, the Cache full count number (on the left) will display the number of times the cache has reached maximum capacity and has had to forcefully clean any entries that haven't been accessed in the last apc.ttl seconds. This number is minimized in a well-configured cache. If the cache is constantly being filled, and thusly forcefully freed, the resulting churning will have disparaging effects on script performance. The easiest way to minimize this number is to allocate more memory for APC.

Share/Bookmark

No comments:

Post a Comment