SERVER : Install eAccelerator so that PHP pages load faster
Thursday, 25. January 2007, 14:28:10
So, first of all, we need to get eAccelerator, for that you can go do the eAccelerator site and download the latest build in some folder you'll be able to access (just make shore you get the tar.bz2 file).
I assume the folder you used is /mnt/local/install, if its not then modify the following commands to reflect that.
So, first we need to extract the archive, for that do
cd /mnt/local/install tar xvjf eaccelerator-0.9.5.tar.bz2(of course, the filename might be different if you're using a newer version).
Now we need to install the development packages, because we need to compile eAccelerator. For that do this :
sudo apt-get install build-essentials php5-dev
After it finished installing we need to run the following commands :
cd eaccelerator-0.9.5 /usr/bin/phpize sudo ./configure --enable-eaccelerator --enable-shared --with-php-config=/usr/bin/php-configthis will configure PHP and the eAccelerator. If you didn't get any errors you can go on and biuld the eAccelerator module, for that do this :
sudo make sudo make install
After the compilation finishes, we need to configure Apache to use this module too. For that, run this
sudo editor /etc/php5/apache2/php.iniand add the following lines to the end of the file
# eAccelerator #zend_extension="/usr/lib/php5/20051025/eaccelerator.so" extension="eaccelerator.so" eaccelerator.shm_size="0" eaccelerator.cache_dir="/var/local/eaccelerator" eaccelerator.enable="1" eaccelerator.optimizer="1" eaccelerator.check_mtime="1" eaccelerator.debug="0" eaccelerator.shm_only="0" eaccelerator.compress="1" eaccelerator.compress_level="9" eaccelerator.allowed_admin_path="/var/www/apache2-default/control.php"
now, for safety, add the same lines to the PHP-CGI too, for that run
sudo editor /etc/php5/cgi/php.ini.
Now we need to create the temporary folders that will be used by eAccelerator, for that do the following :
sudo mkdir /var/local/eaccelerator sudo chown root:www-data /var/local/eaccelerator sudo chmod u=rwx,g=rwx,o= /var/local/eaccelerator
The last thing left to to is to chec if the configuration is OK, so run
apache2ctl configtestif it says Syntax OK then restart apache2, for that do this
/etc/init.d/apache2 restart
If you want to see if eAccelerator is working, you might do this :
sudo editor /var/www/apache2-default/php_test.phpand enter in that page the following text
<?php phpinfo(); ?>Now load up the http://your_server_ip/apache2-default/php_test.php page, and you should see the PHPInfo page, in there search for eAccelerator, and you should see something similar to this
To modify eAccelerator's settings, you need to copy the control panel. For that do the following
cp control.php /var/www/apache2-default, now edit the file and change the user-name and password to something you can remember, this is needed so that nobody else can run the eAccelerator configuration utility. For that, run this
sudo editor /var/www/apache2-default/control.phpnow scroll down to the /** config **/ part, and modify it to your liking, for example
/** config **/ $user = "my_user"; $pw = "my_password"; /** /config **/
After you've saved the file, it's time to check out the configuration page, for that, go to http://your_server_ip/apache2-default/control.php and log in with the user-name and password you've just set. From this page you ca n enable/disable the caching and optimization, you can also clear the cache, that's not really needed unless you get a PHP page that doesn't want to update (it rarely happens, but who knows, you might need it).
Performance tuning
Since eAccelerator first stores compiled PHP pages in shared memory, then on disk when that runs out, the size of the shared memory pool will likely have the largest impact on performance.
By default, eAccelerator uses the maximum shared memory available which on Ubuntu 6.10 seems to be around 33 MB, regardless of installed memory. That may be too large for a server with limited RAM… in low memory situations it’s better to leave more memory for applications and the Linux disk cache. You can reduce shared memory usage by setting eaccelerator.shm_size to something other than zero.
Conversely, if your server is dedicated to serving PHP pages and has lots of installed memory, increasing shared memory might improve performance. See the eAccelerator release notes for info on increasing available shared memory in the Linux kernel.
On a very busy server where PHP code doesn’t change often, performance might be improved by setting eaccelerator.check_mtime="0" to disable checking of source files for changes. Beware if you do this then when php files change you’ll have to clear the eAccelerator cache (via the control panel or using ‘apache2ctl graceful‘ at the command line) for changes to become visible.


























































