Mostally SSI is not initially opened so to use it you have to open it
For my Apache server i make the following changes
To permit SSI on my server, i uncomment the following lines my httpd.conf file,
Options Indexes FollowSymLinks
MultiViews.
and add the Includes after
it
Options Indexes FollowSymLinks
MultiViews Include.
This tells Apache that you want to permit files to be parsed for SSI directives.
Not just any file is parsed for SSI directives. You
have to tell Apache which files should be parsed. There are two ways to
do
this. You can tell Apache to parse any file with a particular file
extension, such as .shtml, with the following directives:
AddType text/html .shtml
AddHandler server-parsed
.shtml
One disadvantage to this approach is that if you
wanted to add SSI directives to an existing page, you would have to change
the name of that page, and all links to that page, in order to give
it a .shtml extension, so that those directives would be
executed.So one solution may be that told the server to parse .html
not .shtml but it increase load at your machine because server will parse
each and every .html file either it will have some script or not.
So i uncommented the above two lines also.If this
is not working probably Apache will not be configure with mod_include and
mod_cgi.To determine this run ./httpd -I from bin directory it will
show you all the modules which are in your server.
If these two modules are not in your server you have to recompile the
make file of Apache server with these modules.
Now you have to be restart your server.
This is my script
#!/usr/bin/perl
$file='/usr/src/apache/cgi-bin/counter';
open("fp1","$file");
$i=0;
while(<fp1>){
$count[$i]=$_;
chop($count[$i]);
$i++;
}
close(fp1);
select(STDOUT);$|=1;
print "content-type: text/html\n\n";
#For the check of user
if he is previous one or new.
if($ENV{'REMOTE_ADDR'}
ne $count[1]){
print "<i><font
color=\"33cc00\"><font size=+1>You are ",++$count[0],"th visitor of
my page </font></font>";
}else {
print "<i><font color=\"33cc00\"><font
size=+1>You are ",$count[0],"th visitor of my page </font></font>";
}
open("fp1",">$file");
select(fp1);$|=1;
print $count[0],"\n";
print $ENV{'REMOTE_ADDR'},"\n";
close(fp1);
To run this put
<!--#exec cgi="/cgi-bin/counter.cgi"-->
this into your .shtml
file .Note that file should be .shtml other wise it will not work
because you have already told to server to parse .shtml files.
So when you access your .shtml file it will show
you what is your visitor no.
SSI is very useful feature.You can give the
last modified time by its environment variable.It gives a one good
feature also you can allow to run any body any command at your machine
by web.But be carefull it's a great security risk.
for demo please click here
It will show you the following things