Gawkwire: Web Hosting and Internet News Resource
©2007 Spoonlabs d.o.o.
Vivvo CMS 4.0
Why a new web server? LiteSpeed Review
Indepth review of LiteSpeed Web Server (LSWS).
<p><br />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)?<br />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.</p><p>Pro’s<br />Can read existing Apache configuration files<br />Can process most mod_rewrite rules<br />Supports cPanel, DirectAdmin, Plesk and Ensim control panels<br />Supports .htaccess configuration files<br />Supports mod_secuirty rules<br />Can run PHP V4 and V5 side by side on the same server<br />Built in DoS protection (bandwidth throttling, per IP connection limits and per IP request throttling)<br />Real time reports of server status<br />Lets you quickly revert to previous versions after upgrade<br />Integrated RoR support<br />Reloads automatically when Apache configuration file is changed</p><p>Con’s<br />Expensive (licensed per CPU)<br />Yearly maintenance fee<br />Optional email support / free community support</p><p>Installation and Configuration<br />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.</p><p>1.Download the LSWS software<br />2.Upload the software to your server / untar the file<br />3.Copy your trial license per the information in the trial license email<br />4.Run the install.sh script</p><p>At this point the install script is going to ask you a lot of questions. The key ones are:<br />Choose an admin user-id/password<br />Run LSWS as (user/group) nobody/nobody<br />Run LSWS on port 2080<br />Choose PHP support<br />Choose .php for the PHP suffix<br />Don’t turn on PHP opcache<br />Don’t turn on AWStats<br />Don’t import Apache configuration (at this time)<br />Let LSWS start on system restart<br />Start LSWS </p><p>That’s it and LSWS is installed. You can now access the LSWS admin console at <a href="http://youripaddress:7080/">http://youripaddress:7080</a> (make sure that both port 7080 (admin interface) and 1080 (temp web address) are open on your firewall.</p><p>Next we’ll walk through a brief configuration and then you’ll be able to test out LSWS while Apache is still running.</p><p>Choose “Configuration / Server / General” from the administrative console menu. We’ll set the following options:<br />Load Apache Configuration => Yes<br />Auto Reload On Changes => Yes<br />Apache Configuration File => /usr/local/apache/conf/httpd.conf<br />Apache Port Offset => 1000<br />Apache IP Offset => 0<br />PHP suExec => this should be “no” if you are currently not running php-suexec and “yes” if you are running php-suexec.<br />PHP suExec Max Conn => 5 (only has meaning if you have php-suexec set to “yes”)<br />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).<br />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 <a href="http://www.domain.tld:1080/">http://www.domain.tld:1080</a> or secure site via <a href="https://www.domain.tld:1443/">https://www.domain.tld:1443/</a></p><p>Rebuilding PHP the next step<br />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):<br />Download whatever PHP version you want to your server<br />Extract the tarball<br />cd to the sapi directory<br />download and then extract the PHP lsapi<br />move back up a directory (i.e. cd ..)<br />run “touch ac*”<br />run “./buildconf –force”</p><p>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:</p><p>-- prefix=/some/directory<br />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.).</p><p>-- with-litespeed</p><p>This tells the configuration process that you want to use the LSAPI</p><p>--with-config-file-path=</p><p>This is the full path (or a relative path) to your php.ini file</p><p>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.<br />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.</p><p>LSWS can’t do everything (yet)<br />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.<br />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.<br />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.</p><p>LiteSpeed Costs<br />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):</p><p>Version Owned Yearly Lease Monthly Lease<br />VPS $249 $150 $14<br />1 CPU-Core $449 $349 $32<br />2 CPU-Core $799 $449 $46<br />4 CPU-Core $1299 $699 $65</p><p>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.</p><p>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.</p><p>Conclusion<br />While the price tag on LSWS may be a bit hard to swallow from the authors experience, the cost has justified itself:<br />We are now running PHP V4/V5 on the same server and clients are very happy<br />We’ve reduced memory utilization<br />Server load has been lowered<br />We’re able to run more sites on the same hardware avoiding new hardware costs.</p>