Skip navigation.

SERVER : Install eAccelerator so that PHP pages load faster

, , , , ,

The latest version of the PHP cache eAccelerator has been released… one of the more popular PHP extensions that attempts to speed up PHP performance. This is first non-beta of eAccelerator that supports PHP 5.1 and PHP 5.2.

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-config
this 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.ini
and 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 configtest
if 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.php
and 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.php
now 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.

SERVER : Adding a printer to the SAMBA shareWhat else do you think i should try to run on the linux server ?

Comments

Euthenics 17. August 2007, 22:01

I really like your blog. The way you showed the tutorial with examples and explanations clearly stated. It's fantastic. I hope you will continue with a lot more in here. There are many others who have learn a lot from your blog on server, Linux and etc.

Good job and keep it up. Cheers... :cool:

albuemil 22. August 2007, 15:10

To tell you the truth, i made the tutorials so when i reinstall the server (or try to install a different one) i would know where to start from, as i'm not very good at remembering exact commands :-)

I've never tought this would be of help to anybody except me, and i'm very glad to see i've managed to help somebody else.

I have to point out that i'm not an expert (not even an average) linux user, so some of the stuff i write might be wrong, so if anybody finds any mistakes please feel free to point them out (that way i'll learn something new too :-D).

Also, the entire "Linux Server" project is a hobby project, so i'm not allocating very much time to it, that's why i post so rarely on the blog.

Anyways, if anybody has any interesting ideea of what i might try to run on the server i'm open for suggestions.

TheWoodcarver 20. May 2008, 04:57

Hey Emil

Great tutorial. Do I need to install php my admin prior to this?

Write a comment

You must be logged in to write a comment. If you're not a registered member, please sign up.

December 2009
S M T W T F S
November 2009January 2010
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31