Compiling PHP on LiteSpeed for Magento

LiteSpeed is my favorite web server solution, even though it is closed source *GASPS*.

Here is how to compile php for litespeed - specifically targeted at the requirements for running a Magento storefront.

First off the free version of litespeed is not available for 64bit operating systems, which you probably are running.  So first we need to get the 32 bit os libraries. apt-get install ia32-libs

The next chunk of commands will install everything that is required to compile php5 with support for MagentoCommerce.apt-get install mysql-common mysql-client mysql-server
apt-get install autoconf
apt-get install build-essential
apt-get install libxml2 libxml2-dev
apt-get install libsqlite0 libsqlite0-dev libsqlite3-0 libsqlite3-dev
apt-get install libcurl3 libcurl3-gnutls libcurl3-dev
apt-get install libjpeg62 libjpeg62-dev
apt-get install libpng12-dev libpng12-0
apt-get install libmysqlclient15-dev
apt-get install mcrypt libmcrypt-dev libmcrypt4 libmhash-dev


Now lets get the install package for LiteSpeed.wget http://www.litespeedtech.com/packages/3.0/lsws-3.3.21-std-i386-linux.tar.gz

Now untar the package and run the litespeed installertar -xzvf lsws-3.3.21-std-i386-linux.tar.gz
cd lsws-3.3.21
./install.sh

Walking through the setup, use the defaults unless otherwise mentioned belowPath: /usr/local/lsws
User: www-data
Group: www-data
HTTP port: 80
Setup PHP: Yes

The setup PHP option will automatically setup PHP4 under FastCGI mode. Great to start off with, but will not work with Magento.

Now we need to compile PHP5 with the Litespeed API (lsapi). Log in to the administration control panel for your litespeed server. ex: http://yourip:adminport/ Go to Actions -> Compile PHP. At the top of that page will be the form for compiling PHP5 for your server. Use the following settingsversion 5.2.6 (newest)
no extra path environment
install path prefix /usr/local/lsws/lsphp5
config params
--with-mysqli --with-zlib --with-gd --enable-shmop --enable-track-vars --enable-sockets --enable-sysvsem --enable-sysvshm --enable-magic-quotes --enable-mbstring --with-iconv --with-mhash --with-mcrypt --with-mysql --with-pear --with-xml --with-simplexml --with-zlib --with-enable-inline-optimization --disable-debug --with-dom --with-dom-xslt --with-sqlite --with-curl --with-php-soap --with-soap --enable-soap --enable-pdo --with-mysql-pdo --with-pdo-mysql --with-kerberos --with-gif --with-jpeg --with-png --enable-jpg --enable-png --enable-gif --with-jpeg-dir=/usr/include/
Check Suhosin patch
Check XCache as OPcode cache
Now click Build PHP 5. This should take some time. If you receive any errors… please note them & leave me a comment.

Things to double check… The lsphp5 symbolic link in $Server_Root\fast-cgi\ should point to the new lsphp-5.2.6 executable.
the script handler in server configuration for php & php5 extensions should point to lsphp5 symbolic link.

You can now compile newest php5 every time they release, the symbolic link should automatically update, and you will have the newest version of PHP for your Magento storefront!

Leave a Reply