Default Virtual Host in Apache

If you have multiple domains installed in a virtual host configuration with one IP address in Apache, the IP address may not resolve to the domain you prefer. Let me explain.

For example, you have the following domains running on an Ubuntu Server with one IP address.

abc.com
cde.com
klm.com
xyz.com

All the domains are resolving as expected on the browser.

However, if you type the IP address on the browser, it only defaults to the first domain found in the /etc/apache2/sites-available directory, which is most likely abc.com.

If you want the IP address to default to another domain, such as klm.com for example, you will need to edit the /etc/apache2/httpd.conf file and add the following entries.

<VirtualHost *:80>
ServerName www.klm.com
ServerAlias klm.com
DocumentRoot /var/www/klm.com/www
</VirtualHost>

Those are the only entries you’ll need. Typing the IP address on the browser will now default to the contents of klm.com. All the other domains are still accessible via domain names on the browser.

Apache mod_spdy

Are you looking for ways to increase the speed of your website? Apache has a new module called mod_spdy which is a new networking protocol spawned by Google. Howtoforge has the install tutorial. It requires that you have access to your own web server, like a VPS or a home server.

SPDY (pronounced “SPeeDY”) is a new networking protocol whose goal is to speed up the web. It is Google’s alternative to the HTTP protocol and a candidate for HTTP/2.0. SPDY augments HTTP with several speed-related features such as stream multiplexing and header compression.

To use SPDY, you need a web server and a browser (like Google Chrome and upcoming versions of Firefox) that both support SPDY. mod_spdy is an open-source Apache module that adds support for the SPDY protocol to the Apache HTTPD server. This tutorial explains how to use mod_spdy with Apache2 on Ubuntu 12.04.

The instructions looks fairly easy.

More proof? Here’s a video showcasing mod_spdy.

Five Watt Web Server

Calxeda has 5 watt web server based on the EnergyCore ECX-1000 1.1GHz processor. Compared to Intel’s 3.3GHz Xeon E3-1240, the results were surprising according to ZDNet.

This makes the Calxeda SOC (Server on a chip) ARM hardware 15 times more power-efficient that Intel’s hardware. According to Calxeda, this translates into a 77 percent reduction of overall total cost of ownership over three years.

And CPU performance is quite acceptable.

While the EnergyCore ECX-1000 is not as powerful as the Xeon E3-1240 — with it only able to handle 5,500 requests per second compared to 6,950 for the Intel hardware — it manages this performance while consuming a little over 5 watts, compared to over 100 watts for the Intel processor.

Multiply a thousand times, you see the potential savings.

Apache Error: Fully Qualified Domain Name

I recently installed Ubuntu and the Apache web server on another desktop computer. If you like to know how to install Apache, please read my previous post about installing LAMP. In this instance, installing Ubuntu and Apache was a success. There is one minor issue however. Every time I restart the Apache web server, I would get this annoying message: “Could not reliably determine the server’s fully qualified domain name.” The error is more of a warning. It does not really affect the way Apache display web pages. It’s more of annoyance more than anything.

So, how do you get rid of this minor Apache error?

First things first, one of the things I would like to do when I install a new instance of Ubuntu is to assign the desktop’s hostname to “localhost.” In this case, I don’t have to worry about the hostname resolving to itself, since localhost is already bound to 127.0.0.1. You can change your hostname to localhost by typing this command on the Terminal:

sudo hostname localhost

You don’t have to do this if you prefer another hostname.

Now, to fixing the minor nuisance.

Edit the Apache config: /etc/apache2/apache2.conf.

You will need to edit the Apache configuration and add your hostname as ServerName. You can edit the file via the Terminal and using either vi or Gedit. I prefer to work vi for minor changes. Gedit is probably easier for most.

sudo vi /etc/apache2/apache2.conf

or

sudo gedit /etc/apache2/apache2.conf

If you haven’t done anything previously to the Apache configuration, it will probably be an empty file. In my case, it was. Just add the following:

ServerName localhost

If you are going to use a different hostname, you will need to add the fully qualified domain name or FQDN in this format.

ServerName hostname.domain.com

After saving your changes, you will need to restart Apache to see if that minor annoyance is gone.

To restart Apache, type:

sudo /etc/init.d/apache2 restart