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.

April 4th, 2008 at 6:59 pm - Edit
Tks! I was able to get it running following your wonderful instructions.
But I can´t access things like mysql.agrofloresta.net (which would take me to phpmyadmin before). I get a 404 error (http://www.agrofloresta.net/dh_phpmyadmin/mysql.agrofloresta.net is where it redirects).
Any clue?
April 5th, 2008 at 7:43 am - Edit
@Decio, I have the same problem. As a workaround, I installed my own version of phpMyAdmin on my web server, located here. It takes a little bit of time, but I didn’t mind since it’s a one-time thing.
April 6th, 2008 at 6:43 pm - Edit
@hl, Antonio (www.dreamhostpstools.com) suggested I use some other not used domain do still gain access to mysql.notuseddomain.com. He even suggested I try a free domain.dreamhosters.com domain to do it.
Tks.
April 6th, 2008 at 6:44 pm - Edit
@hl, Antonio from dreamhostpstools suggested I use some other not used domain do still gain access to mysql.notuseddomain.com. He even suggested I try a free domain.dreamhosters.com domain to do it.
Tks.
April 8th, 2008 at 1:58 am - Edit
That sounds like a pretty good idea!
April 8th, 2008 at 9:21 pm - Edit
Hi! Me again,
One of my scripts needs zend optimizer, I tried installing it but it says I need root access. Any thoughts?
April 9th, 2008 at 10:02 am - Edit
SOLVED!
I just had to add this line:
zend_extension=”/usr/local/dh/apache/template/phpext/zend_optimizer5/ZendOptimizer.so”
to my new php.ini file, borrowed from DH php.ini´s.
Tks!
June 2nd, 2008 at 5:40 pm - Edit
I’ve followed your instructions (but changing them slightly as I have multiple websites on my DS account) and I’m getting the following error when I try to complie the PHP:
buildconf: autoconf not found.
You need autoconf version 2.13 or newer installed
to build PHP from CVS.
make: *** [buildmk.stamp] Error 1
I see my lsws folder and the autoconf-2.61 folders in my home (root) directory, is this the correct relationship between them? I also see bin and share folders were created in the home dir.
June 16th, 2008 at 4:08 pm - Edit
@Timothy,
LSWS and autoconf-2.61 are in the right place. Make sure that the autoconf binary file is located in /home/username/bin/, and make sure that the PATH has been exported to $HOME/bin. If that still doesn’t work, try manually specifying the path to autoconf with ‘export AUTOCONF=/home/username/bin/autoconf’.
June 22nd, 2008 at 7:00 pm - Edit
How do I export the path to $HOME/bin ? I have the same autoconf issue and managed to install autoconf but I still get the same error. Any help?
July 18th, 2008 at 6:40 pm - Edit
Jose,
“export PATH=$PATH:$HOME/bin” should do it.
October 24th, 2008 at 7:35 pm - Edit
I’m on Dreamhost.
I have gotten past the autoconf error by exporting path to $HOME/bin but the next error I receive is: ERROR Could not retrieve LSAPI archive
/home/.plumber/myusername/lsws/phpbuild/phpbuild.1224891724.2.sh: line 22: curl: command not found
I went through and installed curl to ~/bin but I am still getting this error.
Any ideas?
November 11th, 2008 at 10:35 pm - Edit
I got PHP5 compiled with curl support.
1) Downloaded curl source
2) Compiled curl
3) Compiled PHP with correct location newly compiled curl
or:
wget http://curl.haxx.se/download/curl-7.19.1.tar.bz2
tar xjf curl-7.19.1.tar.bz2
cd curl-7.19.1
./configure –prefix=$HOME
make
make install
Compile PHP with:
–with-curl=/home/username/bin
I’m still have a few problems, but not related to curl anyway. I don’t know if that helps Jack, but someone might find it useful.
–
Thanks for the great guide btw!
November 29th, 2008 at 9:57 pm - Edit
how do we uninstall all of this stuff? my site is screwed.. it doesn’t even function right after all this.. i think all this info is outdated already.. because not everything is the same
December 3rd, 2008 at 7:29 am - Edit
@peter
Undo the following line and reboot your server to move your site back to Dreamhost’s configuration:
“If it works, we move on to Dreamhost’s control panel to finalize the configuration. In the Domains “Mongrel and Proxy” page, proxy your entire domain to port 8088.”
December 21st, 2008 at 4:41 am - Edit
Thanks for the great post!
I’m curious about the size differences between lsphp and lsphp5 in $SERVER_ROOT/fcgi-bin/ folder. Mine is 2M and 20MB respectively. Is it normal? Or it’s because i compile it with unoptimized compile options?
December 22nd, 2008 at 7:23 pm - Edit
@Dida,
lsphp is php4, which accounts for the size difference
December 30th, 2008 at 7:56 am - Edit
Hey
I have all this running on my Dreamhost PS. Thanks a lot. I just have two small issues that I can’t solve and I wondered if you could point me in the right direction.
1. Google Docs. I was using the Inline Google Docs plugin to import a few things into my Wordpress install. Since moving to Litespeed it’s stopped working. I suspect it’s something to do with my Litespeed running on port 8080 and that’s confusing the hell out of something but I don’t know what. The plugin has an option to input proxy settings but I have tried many combinations of localhost/80, localhost/8080 IP/80 IP/8080 etc etc but with no luck. Any ideas?
2. Mcrypt. I’ve installed my own phpmyadmin running on its own sub-domain. All works well apart from when I get to the login screen I’m told that “Cannot load mcrypt extension”. I see you too set up your own phpmyadmin so did you come across this issue and solve it?
None of the above are desperate problems but you know, it’s fun to solve things
December 31st, 2008 at 4:49 am - Edit
@Caramboo,
1. If a blank proxy setting does not work, I do not know what is wrong. If you use a Wordpress cache, maybe it needs to be reset?
2. According to the documentation, mcrypt is not really required. But if you must solve it, recompile PHP5 with the addition of –with-mcrypt.
“When using the “cookie” authentication method, the mcrypt extension is strongly suggested for most users and is required for 64–bit machines. Not using mcrypt will cause phpMyAdmin to load pages significantly slower.”