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/adityapatawari.com 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/adityapatawari.com


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

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

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


    sudo a2dissite default && sudo a2ensite adityapatawari.com

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

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.