Installing Eaccelerator
PHP is an interpreted language. This means that each time a PHP generated page is requested, the server must read in the various files needed and "compile" them into something the machine can understand (opcode).
Opcode cache mechanisms preserve this generated code in cache so that it only needs to be generated a single time to serve hundreds or millions of subsequent requests.
Enabling opcode cache will reduce the time it takes to generate a page by up to 90%. After enabling opcode cache on my own server, I saw page loads drop from about 1.5 seconds to as low as 300ms.
Opcode Cache Solutions
After a bit of research and a lot of asking around, I concluded that Eaccelerator was the best choice for me. It's compatible with PHP5, is arguably the most popular of its kind, and is successfully used on sites getting far more traffic than you or I are ever likely to see. Also its worth noting that Eaccelerator works wonderfull with Zend Framework.
Implementing eAccelerator
Implementing opcode cache is far easier than you might imagine. The only thing you'll need is admin (root) access to your server. If you're in a shared hosting environment, ask your service provider about implementing this feature if it is not in place already. These instructions apply to *nix environments only.
Installation Steps:
- Step 1. Compiling Eaccelerator
Go to the source directory were eAccelerator is located, and in the parent folder run the following commands:
phpize ./configure make
- Step 2. Installing
Now for the installation process run the following command:
make install
- Step 3. Configuration
For configuring your recent install of eAccelerator access your php.ini configuration file, at the end add the following lines:
extension="eaccelerator.so" eaccelerator.shm_size="16" eaccelerator.cache_dir="/tmp/eaccelerator" eaccelerator.enable="1" eaccelerator.optimizer="1" eaccelerator.check_mtime="1" eaccelerator.debug="0" eaccelerator.filter="" eaccelerator.shm_max="0" eaccelerator.shm_ttl="0" eaccelerator.shm_prune_period="0" eaccelerator.shm_only="0" eaccelerator.compress="1" eaccelerator.compress_level="9"
- Step 4. Create Cache Directory
Last but not least all you have to do is create a cache directory, if we follow the above example the cache directory should be created using the following commands:
mkdir /tmp/eaccelerator chmod 0777 /tmp/eaccelerator
Well their you have it that all you need to start serving blazing fast PHP pages. If you want to
configure the admin panel for eAccelerator all you have to do is copy the "control.php" file located inside
eAccelerators source folder into a web enabled folder which you could access via a web browser.
After copying the file edit the "control.php" file and add a username and password.
Example from Control.php file:
/*** CONFIG ***/
$auth = true; // Set to false to disable authentication
$user = "username";
$pw = "password";
piz