PHP eAccelerator on Linux.
eAccelerator is a free open-source PHP accelerator and optimizer. It speeds up the script execution by caching the compiled PHP script in shared memory or in disk and eliminating the need of compiling again on each request. By using PHP eAccelerator, the speed of PHP scripts may increase over 1-10 times. This project has been derived from PHP MMCache extension. In this article, we will go through the installation and configuration of PHP eAccelerator.
Requirements for eAccelerator:
• php4 or php5 (support for php5.4 is available).
• PHP should be compiled as either mod_php or in fastcgi mode. It can't be used in CGI or CLI because eAccelerator needs to set up shared memory and this can only be done when all PHP instances that need to access it are forks of the first process.
Here, we will go through the installation from source package.
1. Download the source package.
You can download the source packages from https://github.com/eaccelerator/eaccelerator/downloads:
2. Unpack the source package.
tar –jxzf eaccelerator-0.9.6.1.tar.bz2
3. Compile it using ‘phpize’ and install.
Use the following steps, if there is only one PHP is available in the server.
If you want to use eAccelerator with PHP which is not the default one (more than one PHP installation available, say /opt/php), then you need to mention the exact path as follows:
./configure --enable-shared --with-php-config=/opt/php/bin/php-config
After installation, it will display the folder where eaccelerator.so has been created.
4. Configuring eAccelerator.
Next, you need to edit the PHP configuration file, php.ini to load the newly installed eAccelerator module. You can find the path to php.ini file by executing the following
php –i | grep php.ini
eAccelerator can be installed both as Zend or PHP extension. Here, we will install it as a zend extension. For that, we need to add the following directives to php.ini file. Don’t forget to modify the “path_to_extension_folder” with the proper one.
5. Finally, you need to create the cache directory and set the ownership and permissions properly.
chown apache.apache /var/cache/eaccelerator
Now, you can check it using a phpinfo script and verify the loaded eAccelerator module.