Thursday, November 11, 2010

How to setup webserver on linux operating system

A web server is a computer program that delivers (serves) content, such as web pages, using the Hypertext Transfer Protocol (HTTP), over the World Wide Web. The term web server can also refer to the computer or virtual machine running the program.

Basic steps in installing a Web-server:

1.> Connect yourself to any possible network and determine your system’s IP- address.

2.> By typing “ ifconfig –a ” in the terminal, or right-clicking on the network icon and choosing “connection information ”.

3.> Now, in terminal type: gedit /etc/httpd/conf/httpd.conf
This will open up a configuration document in gedit.

4.> You have to make changes in this configuration file as given in one of the three methods below.

5.> Once done you should restart/start the httpd server by typing: /etc/init.d/httpd start
This will restart the server with new settings in the config file.

6.> Next you should make entries in the host file by typing: gedit /etc/hosts
This will open up a host file in gedit, where you should type for example: bvcoe.home (note that you may have to make more such entries if you are hosting more than one webserver.)

7.> Now, you have to close it and restart the web server again by typing /etc/init.d/httpd restart.
You can check for working of webserver by typing: ping

8.> Now open the web-browser and type the URL which you have defined.
You should see your page.

9.>To open you site in other computers you should switch off the fire wall of your computer by typing: /etc/init.d/iptables stop.
If you are hosting many servers you document root may be different or same for all servers.

10.> Test you webserver by typing in adderss bar of browser : 123.456.123.12:8080(your ip add) for port based hosting.
Other wise just the ip-address: 123.456.123.12
11.> To view your html page 123.456.123.12/yourpage.html

12.> To make your own directory in html directory:
Cd /var/www/html
Cd /var/www/html/

13.> Now you have to make a html page which will be stored in this folder.
By typing: gedit page1.html

This will open up a blank gedit editor where you have to type you html code for ex.

14.> Save the file and close. You html page is ready.

Experiment # 1
Web-server Installation
IP Based virtual hosting:

In IP-based virtual hosting the server is configured with multiple physical network interfaces, virtual network interfaces on the same physical interface or multiple IP addresses on one interface. IP-based virtual hosts use multiple hosts for different IP addresses but on same server. This allows running multiple websites, each with a different IP, on a single machine. This can be achieved by hosts that have multiple network connections, or by virtual interfaces.

For example, and have ip addresses and respectively and share the same web server. In this scenario, both and are registered with the standard domain name service registry as having the IP address 127.0.0100 and A user types in the URL in his browser. The user's computer resolves the name to the IP address and similarly to the IP address:
The web server can obtain the address the TCP connection was intended for using a standard API and use this to determine which website to serve. The client is not involved in this process and therefore (unlike with name based virtual hosting) there are no compatibility issues.

The main server can never catch a request, because all IP addresses of our machine are in use for IP-based virtual hosts (only localhost requests can hit the main server).

Experiment # 2 Web-server Installation

Name Based virtual hosting:

Name-based virtual hosts use multiple host names for the same webserver IP address. In name based virtual hosting multiple hosts are assigned same IP address.
Name-based virtual hosts allow multiple websites on a single IP address. This is in contrast to IP-based virtual hosts, where you need an IP address for each website. IP-based virtual hosts rely explicitly on IP addresses to determine the correct virtual host to the server. Name-based virtual hosts rely on the client to specify the hostname in the HTTP headers. Name-based virtual hosts are easy to configure, and do not require multiple IP addresses, and can, therefore, work in situations in which you are short of IPs.
For example, and have the same ip address and share the same web server. In this scenario, both and are registered with the standard domain name service registry as having the IP address 127.0.0100. A user types in the URL in his browser. The user's computer resolves the name to the IP address Server is created on the machine that has the IP address, so it receives the request. Server determines which virtual host to use by looking at the request URL.

Server configuration:

The asterisks match all addresses, so the main server serves no requests. Due to the fact that www.domain.tld is first in the configuration file, it has the highest priority and can be seen as the default or primary server.

Experiment # 3
Web-server Installation
Port- Based virtual hosting:

The default port number for HTTP is 80. However, most webservers can be configured to operate on almost any port number, provided the port number is not in use by any other program on the server.
For instance, a server may host the website However, if they wish to operate a second site, do not have access to the domain name configuration for their domain name, and/or own no other IP addresses which they could use to serve the site from, they could instead use another port number, for example, for port 81, or for port 8,000.
Setup: The server machine has one IP address ( which resolves to the name If we don't have the option to get another address or alias for our server we can use port-based virtual hosts if we need a virtual host with a different configuration.
Server configuration:

A request to on port 80 is served from the main server and a request to on port 8080 is served from the virtual host.


Post a Comment

Related Posts Plugin for WordPress, Blogger...