Apache versus LiteSpeed – A quick glance on performance and deployment
Apache has dominated the hosting industry as a webserver for several years. Still it is continuing but has got some strong competitors now a days. The popularity of Apache is due to the easiness in its deployment and also the performance it is giving. Also, it is relatively easy to maintain.
Apache is used as a webserver in both Linux and Windows servers and in both the performance is splendid. Also, one of the main factor for using Apache is its integration with PHP. We saw how the LAMP configuration dominates the web industry. Linux > Apache > Mysql > PHP configuration still holds its part in the hosting industry.
But as I said before, Apache has new competitors with better performance. The important one is LiteSpeed. LiteSpeed is supposed to be more than 6 times faster than apache and some organizations prefer the switch from Apache to Litespeed over a RAM upgrade!
Let us check the pros and cons of LiteSpeed and Apache in the table below.
As per the above table, you can see the advantages of Litespeed over Apache. When serving static content, LiteSpeed surpasses well-respected content accelerators including thttpd, boa and TUX. When it comes to dynamic content, LiteSpeed is 50 % more than in PHP content delivery than Apache with mod_php. Different modules that we compile separately on Apache is built-in in Lite-speed.
Also, the scalability holds a bigger difference. Apache can handle about 1000 concurrent clients while LiteSpeed can handle 20000 concurrent clients. But the major factor here is that Apache is available for free while LiteSpeed with enhanced options is payable.
One of the main features of LiteSpeed is that it fits easily to the existing infra structure.
Apache interchangeable, operate directly from Apache httpd.conf
Web hosting control panel compatible: cPanel, DirectAdmin, Plesk, etc
Migration from other web servers is quick and easy
No need to purchase extra hardware to cope with your current web server’s lack of performance
Or have LiteSpeed serve as a content accelerator, compression proxy or security guard in front of your current web/Application server, improving performance, scalability and security.
Also, the following security features forms a highlight of LiteSpeed setup.
Strictest HTTP request validation
Deny any buffer-overrun attempts
Anti-DDoS: Throttling & Connection Accounting
System overloading prevention
Chroot web server process
CGI/FCGI/LSAPI/PHP/RUBY suEXEC
Virtual host chroot
LiteSpeed comes in two packages:
Standard Edition
Enteprise Edition.
LiteSpeed Web Server Standard Edition is free for both private and commercial use. But the functionalities are limited. Standard Edition is a limited feature version and does not scale with MP servers. One of the main draw backs of standard edition over enterprise edition is that it can only handle up to 5 virtual hosts.
Another feature is that there is a separate support for standard edition which is free. But Enterprise edition provides different support plans which are payable.
In Enterprise edition, several features are incorporated. This version supports multi processor scalability while in standard version, it is absent. It can handle unlimited number of virtual hosts, has built in Ruby-Rails shared hosting, optimized performance, mod_security for apache virtual hosts etc.
A table that shows the comparison between the two LiteSpeed versions are shown below.
Installation of LiteSpeed in Linux distributions
Here we discuss the installation steps of LiteSpeed standard edition.
First of all, you have to check the server requirements. You need to have the following requirements.
Operating System:
Linux(i386): kernel 2.4 and above, glibc-2.2 and above
Solaris(Sparc): SunOS 5.8 and above
Solaris(x86): Sun0S 5.8 and above
FreeBSD(i386): 4.5 and above
MacOSX: 10.3 and above
Open Darwin: 7.0 and above
CPU:
Intel: 80486 and above
Sun: UltraSPARC and above
PowerPC: PowerPC G4
Memory:
32MB and above
Disk:
Installation: 10MB
Runtime: 20MB and above, swapping space depends on usage
Download the right package you need (according to the architecture you have on your server)
You can down load from “http://www.litespeedtech.com/litespeed-web-server-downloads.html”.
# tar -xvzf lsws-3.1.1-std-i386-linux.tar.gz
# cd lsws-3.1.1
# ./install.sh
During the installation process, you may encounter the following questions. Give the answers specified below.
* Do you agree with above license? Yes
* Destination [/opt/lsws]: /opt/lsws [ /usr/local/lsws can also be used]
* User name [admin]: admin
* Password: youradminpassword
* Retype password: youradminpassword
* User [nobody]: nobody [use a non-system user that doesn't have a shell access and home directory]
* Group [nobody]: nobody [group the webserver will be running as]
* HTTP port [8088]: 2080 [you can give any port you wish to run lsws. If any other webserver is running on this port, stop it before starting lsws]
* Admin HTTP port [7080]: 7080
* Both these ports should be enabled in the firewall
* Setup up PHP [Y/n]: Y
* Suffix for PHP script(comma separated list) [php]: php
* Would you like to change PHP opcode cache setting [y/N]? N
* Would you like to install AWStats Add-on module [y/N]? N
* Would you like to import Apache configuration [y/N]? N
* Would you like to have LiteSpeed Web Server started automatically when the machine restarts [Y/n]? Y
* Would you like to start it right now [Y/n]? Y
Do the following to replace Apache with LSWS:
Go to the Admin Area
Go to Configurations >> Server >> General
Scroll down to “Using Apache Configuration file”
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 => Yes
PHP suEXEC Max Conn => 8
LiteSpeed Web Server started successfully! Have fun!
PHP
By default, Litespeed comes with PHP 4.4.x compiled with LSAPI and hence we have to install latest stable version of PHP with LSAPI for our LiteSpeed. With PHP LiteSpeed SAPI, LiteSpeed’s PHP performance is much more efficient than Apache’s mod_php or fast_CGI.
# /opt/lsws/fcgi-bin/lsphp -v
PHP 4.4.7 (litespeed) (built: May 30 2007 05:16:33)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
Download the latest stable PHP
# wget http://in2.php.net/distributions/php-5.2.11.tar.gz
# tar -zxf php-5.2.11.tar.gz
# cd php-5.2.11
# cd sapi
Download and expand latest LSAPI for PHP into the “sapi”folder:
# wget http://www.litespeedtech.com/packages/lsapi/php-litespeed-4.0.tgz
# tar -zxf php-litespeed-4.0.tgz
Change directory to php-5.2.11 and run commands:
# cd ..
# touch ac*
# ./buildconf --force
Configure/Compile PHP:
# php -i | grep configure | sed "s/'//g" | sed "s/'//g"
# Remove the "--with-apxs=/usr/local/apache/bin/apxs"
and add '--prefix=/php5' '--with-litespeed' '--with-config-file-path=../php'
# ./configure '--prefix=/php5' '--with-litespeed'
'--with-config-file-path=../php' --with-mysql ...[options from
the command php -i | grep configure | sed "s/'//g" | sed "s/'//g" ]
# make
# make install
Note: You must compile PCRE (Perl Compatible Regular Expressions) support in
order for the default auto-index PHP script to work correctly (at least this
is true for 3.0RC2).
Replace the lsphp binary in /opt/lsws/fcgi-bin/lsphp with /php-5.2.3/sapi/litespeed/php:
# cd /opt/lsws/fcgi-bin/
# mv lsphp lsphp.old
# cp /php-5.2.11/sapi/litespeed/php lsphp
To check installation success:
# /opt/lsws/fcgi-bin/lsphp -v
PHP 5.2.11 (litespeed) (built: May 31 2007 14:05:12)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
php.ini
The php.ini file will be located at /opt/lsws/php/php.ini
If we want to use the old PHP.ini just copy it here.
# cd /opt/lsws/php
# mv php.ini php.ini.old
# cp /usr/local/ZEND/etc/php.ini .
Restart Litespeed Webserver
Finally restart LSWS and use our new PHP binary.
/opt/lsws/bin/lswsctrl restart and thats it. You are done !!!