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:
10.10.212.32 bvcoe.home www.abcd.com (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 www.abcd.com

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
Mkdir
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, www.acn1.com and www.acn2.com have ip addresses 127.0.0.100 and 127.0.0.101 respectively and share the same web server. In this scenario, both www.acn1.com and www.acn2.com are registered with the standard domain name service registry as having the IP address 127.0.0100 and 127.0.0.101. A user types in the URL http://www.acn1.com in his browser. The user's computer resolves the name www.acn1.com to the IP address 127.0.0.100 and similarly www.acn1.com to the IP address:
127.0.0.100.
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, www.acn1.com and www.acn2.com have the same ip address 127.0.0.100 and share the same web server. In this scenario, both www.acn1.com and www.acn2.com are registered with the standard domain name service registry as having the IP address 127.0.0100. A user types in the URL http://www.acn1.com in his browser. The user's computer resolves the name www.acn1.com to the IP address 127.0.0.100. Server is created on the machine that has the IP address 127.0.0.100, 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 www.example.com. 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, www.example.com:81 for port 81, or www.example.com:8000 for port 8,000.
Setup: The server machine has one IP address (111.22.33.44) which resolves to the name domain.com. 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 domain.com on port 80 is served from the main server and a request to domain2.com on port 8080 is served from the virtual host.

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...