Compiling PHP5 and eAccelerator for Litespeed on Dreamhost PS
Posted by: hl in survivalgamesThe standard PHP4 installation that comes with Litespeed may be missing important libraries that you require for your PHP applications. Also, the bundled APC accelerator is not always enabled. Chances are that you will want to compile PHP5 and eAccelerator yourself for maximum compatibility and performance. Luckily, Litespeed has a built-in PHP compiler that simplifies this process.
First, make sure that your Dreamhost PS is temporarily set to at least 600MHz/600MB. Compiling is a CPU intensive task, and without sufficient CPU power, it will take far too long.
Next, connect to your shell account via SSH.
Download, extract, and compile autoconf and automake:
wget ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo/distfiles/autoconf-2.61.tar.gz
wget ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo/distfiles/automake-1.10.1.tar.bz2
tar xzf autoconf-2.61.tar.gz
tar xjf automake-1.10.1.tar.bz2
cd autoconf-2.61
./configure --prefix=$HOME
make
make install
export PATH=$PATH:$HOME/bin
cd $HOME/automake-1.10.1
./configure --prefix=$HOME
make
make install
Compile PHP5 from the Litespeed web administration interface. Note that the compile options and file paths in the below image differ from the defaults. Replace username with your user name. gettext is important for international language support, mysql is important for Wordpress, jpeg is important for image manipulation, and PEAR is not used very often. Each PHP web application has different PHP requirements, and not everything was included here, so please make sure to include the compile options that you need. If you are unsure, take a look at Dreamhost’s default compile options to see many other possibilities. In the interest of keeping a small PHP memory footprint, include only necessary compile options.

Next, we must compile eAccelerator manually. If you are compiling PHP 5.2.5, you can skip this and download the binary here.
wget http://bart.eaccelerator.net/source/0.9.5.2/eaccelerator-0.9.5.2.tar.bz2
tar -xjf eaccelerator-0.9.5.2.tar.bz2
cd eaccelerator-0.9.5.2
export PHP_PREFIX=$HOME/lsws/lsphp5/bin
export PATH=$PATH:$HOME/bin
$PHP_PREFIX/phpize
./configure --prefix=$HOME --enable-eaccelerator-shared --with-php-config=$PHP_PREFIX/php-config
make
cp modules/eaccelerator.so $HOME
After the compile is complete and eaccelerator.so is in your /home/username/ folder, change the Command setting in Server/External App/phpLsapi from $SERVER_ROOT/fcgi-bin/lsphp to $SERVER_ROOT/fcgi-bin/lsphp5
Make a file called php.ini in your $HOME/lsws/fcgi-bin/ directory. Add these lines to enable eAccelerator.
extension_dir = "/home/username"
extension="eaccelerator.so"
eaccelerator.allowed_admin_path="/home/username"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/home/username/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="0"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="3600"
eaccelerator.shm_prune_period="3600"
eaccelerator.shm_only="1"
eaccelerator.compress="0"
eaccelerator.compress_level="1"
eaccelerator.keys = "shm_only"
eaccelerator.sessions = "shm_only"
eaccelerator.content = "shm_only"
output_buffering = On
memory_limit = 32M
Make a directory /home/username/tmp/eaccelerator and chmod those directories 777. Keep the shm_size as large as your memory will allow. Dreamhost’s NFS file mounts are slow, and we want to avoid putting cache files there. Using /tmp as the cache_dir is faster and allows a smaller shm_size to be used, but it has a capacity of only 128MB, and the server will crash if that directory runs out of space.
Now perform a graceful restart of Litespeed. That’s it! To check if everything is running as it should, create and browse to a file called phpinfo.php with these lines of code:
< ?php
phpinfo();
?>
If all is well, you should see a page titled PHP 5.2.5 that contains this line: “with eAccelerator v0.9.5.2, Copyright (c) 2004-2006 eAccelerator, by eAccelerator.”
With the installation of PHP5 and eAccelerator, most of our speed optimizations for Litespeed are complete. Next time: final tuning of Litespeed and Dreamhost settings for lowest cost and highest stability.








