In these days and times, the ability for web administrators to get the most out of their servers is important. Realizing how much power your web server truly requires can help you save money, and simplify your server configurations. There's no question that Apache's HTTP Server can be tweaked and modified to optimize its performance. However, starting out with a webserver that takes those optimizations into consideration initially can save you time and provide you with a low-cost alternative.
Enter Cherokee. Cherokee is a lightning fast open-source webserver that has one of the easiest configuration interfaces I've seen. Its speed and ease of use makes Cherokee one of the top running alternatives to Apache, not to mention the myriad of technologies it supports- from FastCGI, to PHP, to Reverse HTTP Proxy.
Now, I'm certainly a connoisseur of the Linux console. Most Linux users understand the power of the terminal, shell scripting, and the infinite efficiencies it affords. Simultaneously, I can appreciate the simplicity of a well put together web console- something that allows me to configure the features of the associated application without having to scroll through pages of configuration files using vi, nano, or pico.
So the idea here is to illustrate Cherokee's ease of use. With that in mind, let's take a look at a simple installation of the Cherokee web server using the latest version of Ubuntu Server, and how one might configure it to use PHP.
The shortest distance between two points is a straight line. The developers and maintainers of Ubuntu Linux understand this concept completely. If you really want to fully embrace the power of this webserver, let's look at how easy it is to remove Apache from Ubuntu and replace it with Cherokee.
To remove Apache, type the following at your command line terminal:
sudo update-rc.d -f apache remove
To install Cherokee, type the following at your command line terminal:
sudo apt-get install cherokee
Wasn't that easy? Were you expecting there to be more? Ubuntu Linux 10.4's repository already has Cherokee webserver cataloged as an application that can be installed from the command line.
Installing Cherokee from Launchpad
You can also download/install Cherokee directly from Canonical's Launchpad site by adding their respositories.
Edit your source.list file by opening it up in the gedit text editor:
gksudo gedit /etc/apt/sources.list
Add the following lines at the bottom of the file:
# Cherokee Launchpad Repos
deb http://ppa.launchpad.net/cherokee-webserver/ppa/ubuntu lucid main
deb-src http://ppa.launchpad.net/cherokee-webserver/ppa/ubuntu lucid main
Save and close the file.
Launchpad uses GPG to safely sign/encrypt their repository data. That means you will need their GPG key in order to install Cherokee for their repository. No worries there, just type the following at your command line terminal:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EBA7BD49
sudo apt-get update
To make this even easier for Ubuntu users, you can also bypass this process by issuing the following command that takes care of both adding the repositories and obtaining the GPG key:
sudo add-apt-repository ppa:cherokee-webserver
To install now, use:
sudo apt-get install cherokee
Now you're ready to go with Cherokee installed.
Starting up the Cherokee webserver is pretty easy to do. Type the following at your command line terminal:
sudo /etc/init.d/cherokee start
Your Cherokee webserver should now be up and running. The easiest way to check this is to open up a web browser, and hit the good old local host address at http://127.0.0.1/. If all is well, you should see the Cherokee Web Server test page.
We've verified that Cherokee is working, and now before moving further, let's go ahead and install PHP support. Again, Ubuntu Linux users know the ease of this task, it's simply done by typing the following:
sudo apt-get install php5-cgi
This will ensure that PHP is installed correctly for use with Cherokee.
Here is what I consider to be the golden nugget of Cherokee webserver- it's web administration console. To start is, type the following ath your command line terminal:
Notice that the web console runs on a different port from the normal web server, port 9090. In addition, each web console instance is issued with a temporary administrative account password. Use this password at the login screen when logging into the web console. Next, we're going to use the web console to enable the PHP.
On the Cherokee web console, select [Virtual Servers] from the left-navigation. The default virutal server configuration will be listed. Click on the [default] link, then choose the [Behavior] tab. The window will look like this:
Select the [Wizards] button underneath the Rules window. The Wizards window will now be displayed. Select [Languages] under Category. Click the [Run Wizard] link located below PHP. This will install the PHP extensions rule for Cherokee. Once this is complete, make sure that the Final checkbox is selected. If everything is done correctly, the window should look like this:
Save your configuration by pressing [Save] from left-navigation menu. This will gracefully restart the web server. Your PHP configuration is now complete. That was point and click easy right? The same is true for many of the technologies and platforms you might use with Cherokee web server. I encourage you to check out the other Wizards to see what else can be just as easy to configure for use with Cherokee.
As a sanity check, let's create the age old PHP info page as a quick test. Open up a terminal window and type the following:
sudo vi /var/www/info.php
We can create the PHP information page by entering the following code:
<?php phpinfo(); ?>
Save and close the file. Open up your favorite web browser and hit the page at this address: http://127.0.0.1/info.php . If all is well with the world, you will see the PHP Configuration Information page, confirming that PHP is appropriately installed and configured for use with Cherokee!
Even though this seems quite painless, I challenge each of the readers of this article to compare and contrast this installation of Cherokee, and evaluate its performance against the other lightweight alternatives to Apache HTTP Server. You might just find that with Cherokee, you web server will be just as fast, and much easier to deal with.