May 8, 2007

Opps. I just checked a few of my older blog posts and quickly realized I neglected to post part 2 of my ‘Configuring Ubuntu – Part 1’ guide.

Well, here it is!

By default, Ubuntu Server installs MySQL and PHP. However, it doesn’t tweak the system for performance. If you run a WordPress blog on your server, you may not realize that your blog could run more efficiently. WordPress relies on both PHP and MySQL. PHP scripts need to be read from a server’s hard drive, parsed by the web server software and then executed. Wouldn’t it be nice if the server could just skip the first two steps and just execute PHP scripts as quickly as plain HTML?

That’s where eAccelerator comes in. eAccelerator is a free, open-source PHP accelerator and cache. I’ve been using it for nearly seven years on personal and commercial servers. In other words, it’s very stable for a free product.

Let’s get started.

First of all, you need to ensure that you have the php5-dev package installed on your server. It’s likely not installed, so let’s install it:

you@yourserver:~$ sudo apt-get install php5-dev

Next, download the latest build and extract it:

you@yourserver:~$ wget http://bart.eaccelerator.net/source/0.9.5.1/eaccelerator-0.9.5.1.tar.bz2
you@yourserver:~$ tar -xvjf eaccelerator-0.9.5.1.tar.bz2
you@yourserver:~$ cd eaccelerator-0.9.5.1

Time to compile eAcccelerator:

you@yourserver:~$ sudo find / -name phpize
/usr/bin/phpize
you@yourserver:~$ export PHP_PREFIX=”/usr/bin”
you@yourserver:~$ $PHP_PREFIX/phpize
you@yourserver:~$ ./configure –enable-eaccelerator=shared –with-php-config=$PHP_PREFIX/php-config
you@yourserver:~$ sudo apt-get install make
you@yourserver:~$ make

That was a mouthful, eh? Next, we need to install the eAccelerator module we just created:

you@yourserver:~$ cd modules
you@yourserver:~$ sudo cp eaccelerator.so /usr/lib/php5/20051025/

Edit your php.ini and paste the following block into it after the extensions block:

zend_extension=”/usr/lib/php5/20051025/eaccelerator.so”
eaccelerator.shm_size=”4″
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=”1″
eaccelerator.compress=”1″
eaccelerator.compress_level=”7″

Almost done. Create /tmp/eaccelerator:

you@yourserver:~$ mkdir /tmp/eaccelerator
you@yourserver:~$ chmod 777 /tmp/eaccelerator

One more step! We need to restart Apache for the changes to take effect:

you@yourserver:~$ sudo /etc/init.d/apache2 restart

There you have it. Your PHP-based scripts and applications should run nearly 70% faster!

Add your own comment or set a trackback

Currently no comments

  1. No comment yet

Add your own comment



Follow comments according to this article through a RSS 2.0 feed