Pick a Free OS

User login

Navigation

Web server tutorial - Part 3

<VirtualHost 192.192.192.11>

ServerName www.chik.com

DocumentRoot /home/

</VirtualHost>

After editing /etc/httpd/conf/httpd/conf properly, start /etc/rc.d/init.d/httpd restart.


Explanation of this file

1) note means comment (if removed then it means active state)


The main macro, which should be taken in to account for activation, are:

Documentroot

Serverroot

Servername

User_dir

Access_log

Error_log

Server-alias

Script-alias

Now before we go on to explanations lets take an example to host it both, without password protection and with password protection. Lets design an html page and then communicate with the server. After this we will figure out where to put the html and the server programme, which communicates with html in all the three cases.

Normal Hosting

Lets say our machine ip is: 192.192.192.1 and the machine name is kshounish1.linux.com. And these entries are there in /etc/hosts file:


cd /home/httpd/html

vi index.html


then write


<form method=get action=/cgi-bin/a.pl>

<input type=submit>

</form>

</html>

The above code says that a form and a button of submit type are made which will call a.pl when clicked.

cd /home/httpd/cgi-bin

vi a.pl


Then write exactly whats given below if you are not aware of perl-cgi programming.

#!/usr/bin/perl

print "Content-type:text/html nn";

print "

Welcome to my site

";

print "you have accessed through $ENV{REQUEST_METHOD}";

print"

hope u visit again

";


After this comes out, the very first thing you do is chmod 755 a.pl (very important) or else the file won't be executed due to the Web server architecture restriction on this particular directory.


So what happens is, when you write lynx http://127.0.0.1/or lynx http://192.192.192.2, or http://kshounish1.linux.com
, this 127.0.0.1 or 192.192.192.1 or kshounish.linux.com is mapped with the directory /home/httpd/html/index.html by default.