Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

web server

Status
Not open for further replies.

vintl

Technical User
Jun 9, 2000
72
MY
hi,
how can i run perl scripts from a apache webserver? how to create a internal space to test the scripts.
i've downloaded the apache_1.3.22.tar.gz, does anyone can tell me how to configure it?
and set up the internal space with mysql database.
thanx
 
Hi,

On the compile/install :

tar xzvf apache_1.3.22.tar.gz
cd apache_1.3.22
./configure --prefix=/usr/local/apache
make
make install
(Obviously /usr/local/apache can be somewhere else if you wish)

To start the server....

/usr/local/apache/bin/apachectl start


Regarding cgi & perl - you probably just need to uncomment the following line in your httpd.conf file :

#AddHandler cgi-script .cgi

You then need to set-up the cgi directory (also in httpd.conf) :

ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin"

The latter means that will cause the server to look for 'test.cgi' in the physical directory /usr/local/apache/cgi-bin. Obviously it can be anywhere you like. The scripts should ordinarily be chown'd to the userid you are running the server under and have rwx permissions (especially exec). You wouldn't want anyone else to have exec access.

The following is an example cgi perl script
(in fact 'printenv' as supplied with apache)

#!/usr/local/bin/perl
##
## printenv -- demo CGI program which just prints its environment
##

print "Content-type: text/plain\n\n";
foreach $var (sort(keys(%ENV))) {
$val = $ENV{$var};
$val =~ s|\n|\\n|g;
$val =~ s|"|\\"|g;
print "${var}=\"${val}\"\n";
}

If you save that as printenv.cgi, make executable, put in your cgi-bin dircetory and then do it should run and display all the current apache environment variable values.

Hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top