Thursday, August 14, 2014

Installing and Configuring LiteSpeed Web Server (LSWS) and The PHP

Installing 

The installation of LSWS is pretty straight forward. You can actually install it anywhere but for the sake of simplicity and standardization, we will always be installing it to /opt on the server. This way, if there is a problem and it needs to be checked on, we will always know where it is. Additionally, as you will see from the setup steps below, these too will be the standard install. Lastly, for standardization, please make sure that during the install LSWS is set to listen on 7080 (admin console) and 8088 (verification page).

The installation 

SSH into the box as root
chmod 0755 /usr/bin/gcc

cd /opt

Download the installation files to /opt and untar them. All available versions of LiteSpeed Web Server can be found at http://www.litespeedtech.com/products/webserver/download/. Please also note that we only provide licensing and support for Enterprise edition and not standard so when installing this for a client, you will need to use have the registration number.

wget http://www.litespeedtech.com/packages/4.0/lsws-4.0-ent-i386-linux.tar.gz

tar -zxvf lsws-4.0-ent-*

cd lsws*

Now, you need to get the serial number for the install. To do this, cd into the installation folder (the same one that contains install.sh) and from the command line, without the quotes, as root, run:

echo "SERIAL NUMBER GOES HERE" > serial.no chmod +x install.sh
./install.sh

The install should now be moving along. For the specifics on the install, please refer to the below prompts:

Installation Prompts 

Prepare PHP 

PHP is somewhat of an inconvenience on LSWS as it uses it's own "special" kind of PHP with certain CFLAGS, the most important of these CFLAGS are --prefix=/lsphp5 and --with-litespeed. If you compile PHP through EasyApache, you will not mess anything up however, you the changes will not be used by LiteSpeed and as such you need to compile PHP through LiteSpeed but thankfully this is pretty straight forward but a little more time consuming. The below addresses recompiling PHP to add something to it.

First, SSH into the box as root. Next, find out what CFLAGS the current PHP version has with php -i | less in the section, Configure Command => you will see all of the flags used to compile it originally. When we do this on a testing box, we see:


'./configure' '--prefix=/lsphp5' '--with-litespeed' '--disable-pdo' '--enable-bcmath' '--enable-calendar' '--enable-ftp' '--enable-gd-native-ttf' '--enable-libxml' '--enable-magic-quotes' '--enable-sockets' '--enable-zip' '--prefix=/usr/local' '--with-apxs2=/usr/local/apache/bin/apxs' '--with-bz2' '--with-curl=/opt/curlssl/' '--with-freetype-dir=/usr' '--with-gd' '--with-imap=/opt/php_with_imap_client/' '--with-imap-ssl=/usr' '--with-jpeg-dir=/usr' '--with-kerberos' '--with-libxml-dir=/opt/xml2/' '--with-mcrypt=/opt/libmcrypt/' '--with-mhash=/opt/mhash/' '--with-mysql=/usr' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--with-png-dir=/usr' '--with-ttf' '--with-xpm-dir=/usr/X11R6' '--with-zlib' '--with-zlib-dir=/usr'

Now that we know what CFLAGS were given by EasyApache, we need to migrate those to the LSWS PHP installation. This is kind of a crappy way to do it but it's how it will get done. Copy the CFLAGS you get from the above command and put them in notepad. On the server:

mkdir ~/phptest && cd ~/phptest
wget http://us2.php.net/get/php-5.2.9.tar.gz/from/uk.php.net/mirror (or get whatever source version they are getting)
tar -zxvf php-*
cd php-*
./buildconf --force
Now we need to do a dry run of the CFLAGS to make sure that they will be parsed properly when compiling through LSWS's PHP thing. Take the CFLAGS you will need to add, and include them to your ./configure line that you put on notepad. So, if they want to recompile PHP with TTF, you would add:

'./configure' '--prefix=/lsphp5' ... '--with-ttf'

So, from the PHP source directory, run the compile command and make sure that it exists cleanly. You will likely need to yum -y install package and package-devel for it to compile cleanly. You could always specify the EasyApache directory but I haven't tested anything other than default in LSWS's PHP installer/compiler. For example, if you ware trying to compile with the TTF as seen above, and it throws an error about not being able to find the headers, simply yum -y install ttf ttf-devel. Once you have a ./configure like that completes cleanly, you then need to port the CFLAGs to LSWS PHP compiler admin thing.

Config PHP in LSWS 


First, log into the LSWS admin console with the LSWS username and password

Then, navigate to the PHP compilation section which can be found at

We then need to put the CFLAGs into the appropriate window which is pretty easy to spot.

Note that when setting the CFLAGS you do not need to enclose them in ' ' as you do when compiling from the command line.

 ./configure --prefix=/lsphp5 --with-litespeed --disable-pdo --enable-bcmath --enable-calendar --enable-ftp --enable-gd-native-ttf --enable-libxml --enable-magic-quotes --enable-sockets --enable-zip --prefix=/usr/local --with-apxs2=/usr/local/apache/bin/apxs --with-bz2 --with-curl=/opt/curlssl/ --with-freetype-dir=/usr --with-gd --with-imap=/opt/php_with_imap_client/ --with-imap-ssl=/usr --with-jpeg-dir=/usr --with-kerberos --with-libxml-dir=/opt/xml2/ --with-mcrypt=/opt/libmcrypt/ --with-mhash=/opt/mhash/ --with-mysql=/usr --with-mysql-sock=/var/lib/mysql/mysql.sock --with-png-dir=/usr --with-ttf --with-xpm-dir=/usr/X11R6 --with-zlib --with-zlib-dir=/usr

No comments:

Post a Comment