A computer that delivers (serves up) Web pages. Every Web server has an IP address and possibly a domain name.
For example, if you enter the URL http://www.redhat.com/index.html in your browser, this sends a request to the server whose domain name is redhat.com. The server then fetches the page named index.html and sends it to your browser.
Any computer can be turned into a Web server by installing server software and connecting the machine to the Internet. There are many Web server software applications, including public domain software from NCSA and Apache, and commercial packages from Microsoft, Netscape and others.
Fig : Layout of a web server
# Web Server Configuration:
NOTE: In my case 192.168.8.X is http server. I have Jack and Jill with password as password for web page access. 192.168.8.Y acting as a client to server 192.168.8.X
Task 1: To host a web site with name station8.example.com
Step 1: Install http package
# yum install http
Step 2: keep required html file with a name index.html in /var/www/html directory
# echo "This is my first web page" > /var/www/html/index.html
Step 3: start the service
# service httpd start (or)
# /etc/init.d/httpd start
Step 4: make the service persistent across reboot.
# chkconfig httpd on
Task 2: To do name based virtual hosting (to host 2 sites stationX.example.com and wwwX.example.com)
Step 1: Append this data into main configuration file.
cat >> /etc/httpd/conf/httpd.conf
NameVirtualHost 192.168.8.X
<VirtualHost 192.168.8.X>
ServerName stationX.example.com
DocumentRoot /var/www/html
</VirtualHost>
<VirtualHost 192.168.8.X>
ServerName wwwX.example.com
DocumentRoot /var/www/virtual
</VirtualHost>
NOTE: stationX.example.com and wwwX.example.com should resolve to 192.168.8.X
# mkdir /var/www/virtual
# echo "testing name based virtual hosting" > /var/www/virtual/index.html
NOTE: /var/www/html and /var/www/virtual directories must present with related index.html!!!!
Step 2: reload service
# service httpd reload
Step 3: check it
# elinks -dump http://stationX.example.com
# elinks -dump http://wwwX.example.com
Task 3: To host a CGI script.
Step 1: modify configuration file.
Now the configuration file has the below content:
<VirtualHost 192.168.8.X>
ServerName wwwX.example.com
DocumentRoot /var/www/virtual
</VirtualHost>
Modify it and now it should look like as below:
<VirtualHost 192.168.8.X>
ServerName wwwX.example.com
DocumentRoot /var/www/virtual
ScriptAlias /cgi-bin/ /var/www/virtual/wwwX.example.com/cgi-bin/
</VirtualHost>
Step 2: create the directory and keep the required cgi script and make it executable
# mkdir -p /var/www/virtual/wwwX.example.com/cgi-bin
# cd /var/www/virtual/wwwX.example.com/cgi-bin
# wget ftp://192.168.8.254/pub/gls/test.sh
# chmod 755 /var/www/virtual/wwwX.example.com/cgi-bin/test.sh
Step 3: reload service
# service httpd reload
Step 4: check it
# elinks -dump http://wwwX.example.com/cgi-bin/test.sh
It should show u by executing test.sh!!!
In case of any problem or queries or suggestions feel free to leave a comment here.. :)