Installing the eAccelerator module for use with your PHP applications

May 15, 2012


PHP can be very resource intensive at times. If you’re not already using some sort of PHP caching extension, like eAccelerator, APC or XCache, you’re probably well aware of the resource usage associated with PHP and web/command-line apps that rely on it. Fortunately, these extensions provide caching for increased performance and efficiency, which translates to less load on your server. In this article, we’ll focus on installing and configuring eAccelerator.


You will need a PHP version earlier than 5.4.x installed for eAccelerator to build properly. 5.2.x and 5.3.x should work with no issues. You will also need build/compilation tools and libraries installed on your server (gcc, make, etc.).

Downloading sources, building and installing

At the time of this posting, the latest version of eAccelerator is Though it doesn’t look like a new version will be released any time in the very near future, should a new version come out, you can simply modify the version numbers below and all the commands should work the same:

wget ""
cd eaccelerator-
./configure ; make ; make install

If you received no errors during the build and the install worked properly, proceed to configuration.



Now, keep in mind these settings are suggestions. They should be modified to suit your needs. 32MB of SHM (Shared Memory) should be enough for most lower-load sites, but 64MB or even more might be necessary in other places. This particular setup limits caching to memory only, which should introduce great amounts of speed. You can also enable disk caching with a slight performance decrease.

NOTE: The default maximum SHM size on most Linux distros is 32M. Do NOT increase this value without modifying the kernel sysctl (see below) unless you don’t like your webserver or PHP app to work right!

To raise the maximum SHM size on Linux, just run the following command (in bytes so assuming desired MB = M, do: M * 1024 * 1024):

sysctl -w kernel.shmmax=134217728

This assumes you want to raise it to 128MB maximum SHM size. Now, to make that change permanent, just add the following line to /etc/sysctl.conf:

kernel.shmmax = 134217728

Applying configuration

The final step in this setup is to apply your new configuration. Assuming you’re running custom-built Apache, you can run the following commands to restart it:

/usr/local/apache/bin/httpd -k stop
/usr/local/apache/bin/httpd -k start

This should conclude your setup. Once you’re done, you should notice a dramatic decrease in the amount of processing power it takes to run your intensive PHP apps. And, since everyone loves graphic proof, some images follow below.

comments powered by Disqus