Web Hosting and Internet Server

The term web server can refer to either the hardware (the computer) or the software (the computer application) that helps to deliver web content that can be accessed through the Internet. A web server is simply a system that's configured to answer HTTP requests  To convert Linux systems into a web hosting platform, install a daemon that listens for connections on TCP port 80, accepts requests for documents and transmitting them to the requesting user. 
The primary function of a web server is to deliver web pages to clients. The communication between client and server takes place using the Hypertext Transfer Protocol (HTTP). Hyper Text Transfer protocol is a simple TCP-based protocol for transmitting documents that contain a variety of media types, including text, pictures, sound, animation and video. HTTP is an extremely basic, stateless, client/server protocol. In the HTTP paradigm, the initiator of a connection is always the client (a browser). The client asks the server for the contents of a specific URL. The server responds with either a spurt of data or with some type of error message.  

Uniform Resource Locators (URL) is a pointer to an object or service on the internet. It describes how to access an object by means of five  basic components;
  1. Protocol or Application.
  2. Host name.
  3. TCP/IP port.
  4. Directory.
  5. File name.
If there is a query from a client, the client actually asking for some files
  • index.html
  • index.htm
  • index.igi
  • index.shtml
  • index.php
The location of the above files normally in /var/www

Load Balancing

A server's capacity depends on the system's hardware architecture, including subsystems, the operating system it is running and the construction of the sites being served. Load balancing adds both performance and redundancy. Several different load balancing approaches are available: round robin DNS, load balancing hardware and software based load balancing.

HTTP Server Installation.

Installing and maintaining a web server is easy. Web servers rank far below email and DNS in complexity and difficulty of administration. Several HTTP servers are available, but here discuss about Apache Server, which is well known in the industry for its fexibility and performance.
root@debian:~# gzip -d httpd-2.2.25.tar.gz
root@debian:~# tar xvf httpd-2.2.25.tar
  • Go to that extracted file.
root@debian:~# cd httpd-2.2.25
  • Configure the source tree
root@debian:/httpd-2.2.25# ./configure
or
root@debian:/httpd-2.2.25# ./configure --prefix={where to install)
 If Prefix is not specified, it defaults to /usr/local/apache2.
  • Compile
root@debian:/httpd-2.2.25#make
Install
root@debian://httpd-2.2.25# make install

Website works on basis of three things;
  • Server Name (The Website Name).
  • Document Root (The path to Directory Index)
  • Directory Index (A file written by the user, typically called index.html)
Website Servers can be set in three types;
  1. Single IP + Single Domain.
  2. Multiple IP + Multiple Domain.
  3. Single IP + Multiple Domain.
Here we discuss three types of above;

Single IP + Single Domain
#nano /usr/local/apache2/conf/httpd.conf

Give Ctrl + W and search 'ServerName', will reach a location where;
#ServerName www.example.com:80
Uncomment and Change to
ServerName www.growwithlinux.com:80

Again, give Ctrl + W and Search 'DocumentRoot', will reach a location where
DocumentRoot "/usr/local/apache2/htdocs"
Change to
DocumentRoot "/usr/local/apache2/htdocs/growwithlinux"
In a real filed a software programer who create the website using .php or .html or whatever programming language, the files must be dumped in a location and give that location in Document Root

Restart the apache by #/etc/init.d/apache2 restart


We have to set an IP in Ethernet. Either a Public IP or a Private IP which will forward to Public IP setted router. More details please visit the NETWORKING section in this blog.

Multiple IP + Multiple Domain
#nano /usr/local/apache2/conf/extra/httpd-vhosts.conf

NameVirtualHost *:80

Comment it and also comment wahtever we done in Single IP + Multiple Domain.
#NameVirtualHost *:80

On last part we can see;

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/usr/local/apache2/docs/dummy-host.example.com"
    ServerName dummy-host.example.com
    ServerAlias www.dummy-host.example.com
    ErrorLog "logs/dummy-host.example.com-error_log"
    CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>

Change it to;
<VirtualHost 128.0.0.111:80>
    ServerAdmin webmaster@growwithlinux.com
    DocumentRoot "/usr/local/apache2/docs/growwithlinux"
    ServerName www.growwithlinux.com
    ServerAlias growwithlinux.com
   #ErrorLog "logs/dummy-host.example.com-error_log"
   #CustomLog "logs/dummy-host.example.com-access_log" common

</VirtualHost>

<VirtualHost 128.0.0.222:80>

    ServerAdmin webmaster@growwithlinux.com
    DocumentRoot "/usr/local/apache2/docs/networkinggrowwithlinux"
    ServerName networking.growwithlinux.com
    ServerAlias networking.growwithlinux.com
   #ErrorLog "logs/dummy-host.example.com-error_log"
   #CustomLog "logs/dummy-host.example.com-access_log" common

</VirtualHost>

If got more address and IP address copy the above section and past last part of the file and change it. Theoretically infinite numbers of address and IP address we can give here.


Restart the apache by #/etc/init.d/apache2 restart


Give virtual Ethernet address for each IP ie eth0:0, eth0:1 like that. More details please visit the NETWORKING section in this blog.



Single IP + Multiple Domain
#nano /usr/local/apache2/conf/extra/httpd-vhosts.conf

NameVirtualHost *:80

Comment it and also comment wahtever we done in Single IP + Multiple Domain.
#NameVirtualHost *:80

On last part we can see;

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/usr/local/apache2/docs/dummy-host.example.com"
    ServerName dummy-host.example.com
    ServerAlias www.dummy-host.example.com
    ErrorLog "logs/dummy-host.example.com-error_log"
    CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>

Change it to;
<VirtualHost 128.0.0.111:80>
    ServerAdmin webmaster@growwithlinux.com
    DocumentRoot "/usr/local/apache2/docs/growwithlinux"
    ServerName www.growwithlinux.com
    ServerAlias growwithlinux.com
   #ErrorLog "logs/dummy-host.example.com-error_log"
   #CustomLog "logs/dummy-host.example.com-access_log" common

</VirtualHost>

<VirtualHost 128.0.0.111:80>

    ServerAdmin webmaster@growwithlinux.com
    DocumentRoot "/usr/local/apache2/docs/networkinggrowwithlinux"
    ServerName networking.growwithlinux.com
    ServerAlias networking.growwithlinux.com
   #ErrorLog "logs/dummy-host.example.com-error_log"
   #CustomLog "logs/dummy-host.example.com-access_log" common

</VirtualHost>

If got more address copy the above section and past last part of the file and change it. Theoretically infinite numbers of address we can give here.


Restart the apache by #/etc/init.d/apache2 restart


Give virtual Ethernet address for each IP ie eth0:0, eth0:1 like that. More details please visit the NETWORKING section in this blog.

No comments:

Post a Comment