Monday, December 28, 2009

Networking with Linux : The Web Servers

Let us first discuss the very basic question, what is web server? Well, Prof. V.S.S. Sriram told me that a web server, in layman's term, is something which gives a http response to the http request. In other words a web server gives you html pages upon request.

Some popular web servers are Apache, Apache Tomcat, IIS etc. While Apache is used for PHP pages, Tomcat is used for JSP. IIS is a Microsoft server used for ASP. In this post I will show you how to install Apache and host websites on it.

First of all we need to install Apache. In Ubuntu you can do so by typing
sudo apt-get install apache2
For Fedora fire the following command as super user:-
 yum install httpd

Now to verify that you have installed apache correctly open on any browser http://localhost. A page with title "It Works!" will appear confirming the correct installation.

Now that we are done with installation let us host a website. For that you should know that document root is a folder which contains all the pages a website should have. By default index.html is opened if you simply type the address of a website. I am assuming that you want to have /web/ as document root. Follow the given steps to host your website.

  • Copy the default website to use it as a template
    sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/

  • Change the DocumentRoot by editing /etc/apache2/sites-available/ to point to the new location i.e. /web/ You will need to have root permission to do this.

  • Change the Directory directive, replace <Directory /var/www/>to <Directory /web/ >

  • Now disable the previous site and enable this new one. To do so type

    sudo a2dissite default && sudo a2ensite

And you are now a web server ready to try out a web server for real.

Tuesday, December 8, 2009

Networking with Linux : The Domain Names

Every host on network has a unique IP address. Whenever we want to request some information or service from any particular host we need to have its IP address or some other identification mark so that the request does not go to any other node on network.

But this is a problem. Think of it, you meet several people everyday. You tend to remember their name but of course you won't remember the phone numbers of most of them. Why? Because phone numbers are cryptic and difficult string to random numbers. Similarly IP addresses are somewhat impractical to remember. And another good point is that since now a days a lot of websites are hosted on a single server, providing IP will not might get you the desired service. So we give names to the nodes, like or

Now let us talk about the types of domain and categorization. Take the address of this blog as example i.e. Now com is a TLD or Top Level Domain. These type of domains are not for sale to general public. Among other TLDs are org, net, gov, edu and several others. There are also something called ccTLDs or country code TLDs. They are country specific TLDs, like USA has us, India has in and so on.

Below TLDs are second level domains or more usually we call them domains, like is a domain, is a domain or more precisely these are second level domains. They can be usually booked on yearly basis. You can book the domain from any domain name registrars, of course keeping in mind the availability of the domain. Below the second level domain is the third level domain. We call them as child domains or sub domains, like and are sub domains. Ideally we can have unlimited number of sub domains once we have the domain but the service providers sometimes restrict the number of sub domains to save the load on their servers.

Similarly we can have fourth and fifth level domains and so on. But I advise you to stick to second and third level domains only.