Sections

 

 
Newsletter
Email:

 
RESOURCE SITES






Home | Reviews | Why a new web server? LiteSpeed Review

Why a new web server? LiteSpeed Review


Today it’s quite hard for a web host to stay up-to-date with all the latest programming languages.  There is a demand to have PHP version 4 and PHP version 5 (did you know that PHP version 4 goes end-of-life at the end of 2007) as well as Ruby on Rails (RoR).  Trying to implement all of these with Apache can get quite troublesome.  You can run one version of PHP as an Apache module but the other has to run as a CGI.  That can cause quite a performance hit.  Apache also does not handle RoR.  You’d have to setup something like Mongrel or fastcgi and that just introduces more issues and complexity.  Besides all of that complexity you’d also like this to work with your existing control panel (right)?
This is where we make the leap from old tried-and-true Apache to LiteSpeed Web Server (LSWS).  You may not have heard a lot about LSWS but hopefully this article will change that.  LSWS was developed to be a high-speed web server and remove a lot of the bottlenecks associated with Apache.  Let’s start out with a simple pro’s vs. cons for LSWS.

Pro’s
Can read existing Apache configuration files
Can process most mod_rewrite rules
Supports cPanel, DirectAdmin, Plesk and Ensim control panels
Supports .htaccess configuration files
Supports mod_secuirty rules
Can run PHP V4 and V5 side by side on the same server
Built in DoS protection (bandwidth throttling, per IP connection limits and per IP request throttling)
Real time reports of server status
Lets you quickly revert to previous versions after upgrade
Integrated RoR support
Reloads automatically when Apache configuration file is changed

Con’s
Expensive (licensed per CPU)
Yearly maintenance fee
Optional email support / free community support

Installation and Configuration
One of the really nice things about LSWS is that you can easily configure it to run on an alternate port and test it out without having to change Apache or modify your Apache configuration.  For an example of the installation we’re going to assume you are running a cPanel server.  This is  going to be a very slimmed down install and you can read the full installation documentation on the LiteSpeed Wiki.

1.Download the LSWS software
2.Upload the software to your server / untar the file
3.Copy your trial license per the information in the trial license email
4.Run the install.sh script

At this point the install script is going to ask you a lot of questions.  The key ones are:
Choose an admin user-id/password
Run LSWS as (user/group) nobody/nobody
Run LSWS on port 2080
Choose PHP support
Choose .php for the PHP suffix
Don’t turn on PHP opcache
Don’t turn on AWStats
Don’t import Apache configuration (at this time)
Let LSWS start on system restart
Start LSWS

That’s it and LSWS is installed.  You can now access the LSWS admin console at http://youripaddress:7080 (make sure that both port 7080 (admin interface) and 1080 (temp web address) are open on your firewall.

Next we’ll walk through a brief configuration and then you’ll be able to test out LSWS while Apache is still running.

Choose “Configuration / Server / General” from the administrative console menu.  We’ll set the following options:
Load Apache Configuration => Yes
Auto Reload On Changes => Yes
Apache Configuration File => /usr/local/apache/conf/httpd.conf
Apache Port Offset => 1000
Apache IP Offset => 0
PHP suExec => this should be “no” if you are currently not running php-suexec and “yes” if you are running php-suexec.
PHP suExec Max Conn => 5 (only has meaning if you have php-suexec set to “yes”)
Next you can go to the “HT access” section.  Check Limit, Auth, FileInfo, Indexes, Options and uncheck none (this will match the default cpanel .htaccess privileges).
You can then restart LSWS from the administrative console or from command line by executing “service lsws restart”.  Once you have restarted LSWS choose “General” from the administrative menus and you should see a list of the virtual hosts for that server.  You can now begin your preliminary testing by accessing an existing site on the server as http://www.domain.tld:1080 or secure site via https://www.domain.tld:1443/

Rebuilding PHP the next step
One of the reasons that I said you would be performing preliminary testing is that LSWS ships with a pre-built PHP module.  That PHP module may not have all the options you want or need built in so you’re going to have to build your own PHP.  While this process may seem scary it’s pretty well documented on the LiteSpeed Wiki.  Before we dive into building PHP I need to touch on LSAPI or the LiteSpeed Server Application Programming Interface.  The LSAPI is simply an interface that sits between the LSWS and PHP or Ruby.  The LSAPI allows PHP to basically run as fast as an Apache module when in fact it runs much more like a CGI/php-suexec process.  Here is a high level overview on how to build PHP with the LSAPI (again check the LiteSpeed Wiki for the gory details):
Download whatever PHP version you want to your server
Extract the tarball
cd to the sapi directory
download and then extract the PHP lsapi
move back up a directory (i.e. cd ..)
run “touch ac*”
run “./buildconf –force”

At this point you are ready to perform the traditional “configure, make, make install” of just about every Open Source “c” program.  There are 3 key configure options you’ll want to set:

-- prefix=/some/directory
This is going to be the directory where PHP libraries, PEAR etc. get installed.  You have a choice here as to where you want PHP installed.  LiteSpeed support suggests installing PHP in the same directory as cPanel installs PHP (if you have a cPanel server).  This gives you the most compatibility with cPanel.  I prefer to install it in a totally separate directory and then using the php.ini file to bring in the cPanel compiled libraries (like PEAR etc.).

-- with-litespeed

This tells the configuration process that you want to use the LSAPI

--with-config-file-path=

This is the full path (or a relative path) to your php.ini file

You’ll then want to add on all the other configure options that you are currently running.  There are several methods to extract this information from command line php or you can simply create a phpinfo() page and look at the configuration options there.
Once the build completes, you will want to copy your new php module (which will be called php under the sapi/litespeed directory) over to the LSWS fcgi-bin directory (it’s called lsphp in that directory by default).  Restart LSWS and you will now be running your custom compiled PHP.

LSWS can’t do everything (yet)
One thing that LSWS can’t handle is Server Side Includes (SSI).  This can be easily handled with LSWS by simply proxying the request back to your existing Apache web server (yes, if you have SSI you’ll have to keep Apache around).  The configuration is done via the administrative web console by specifying the extensions (normally .shmtl) to proxy back to Apache.
Currently the LSAPI can’t handle .phps (PHP pages that show the source code) so you’ll have to proxy those pages back also (again by the extension).  We’re told that a future version of the LSAPI will handle .phps pages but the proxying will work for now.
While keeping the existing Apache server around may sound bad, it’s really necessary.  The biggest reason is that cPanel (and many other control panels) simply expect it to be there.  When you add a new site to cPanel (or any other control panel that I know of) it will attempt to restart Apache (because that is what it believes is serving up the web pages).  If Apache is not there the control panel is going to complain loudly that it can’t restart Apache.  The good news here is that since Apache is not serving up many pages (most likely just SSI pages) it won’t take much memory or resources.

LiteSpeed Costs
As previously mentioned in this article LSWS is not free software.  There are both purchase and lease options available.  The following table is a summary of the pricing (as of this article):

Version  Owned  Yearly Lease Monthly Lease
VPS  $249  $150  $14
1 CPU-Core $449  $349  $32
2 CPU-Core $799  $449  $46
4 CPU-Core $1299  $699  $65

Maintenance is $99 / year and $50 per additional CPU-Core (so a 2 CPU-Core maintenance would be $149).  Maintenance is strictly for software updates and does not include email support.

As a note, you don’t actually have to match the license to your physical hardware specification.  In other words if you have a 4 CPU-Core server you can buy a 2 CPU-Core license.  The 2 CPU-Core license is optimized for a 2 CPU-Core server and it will simply ignore the extra CPU-Cores and other processes (like PHP) can use the extra 2 cores.

Conclusion
While the price tag on LSWS may be a bit hard to swallow from the authors experience, the cost has justified itself:
We are now running PHP V4/V5 on the same server and clients are very happy
We’ve reduced memory utilization
Server load has been lowered
We’re able to run more sites on the same hardware avoiding new hardware costs.




Comments (0 posted):

Post your comment comment
Please enter the code you see in the image:
  • email Email to a friend
  • print Print version
  • Plain text Plain text

 
Tags
No tags for this article

 
Rate this article
0

 
Featured author