PDA

View Full Version : perl config


shyam
07-22-2005, 10:15 AM
Hi,
l have apache2 and mod_perl2 configured like this

apache2
|
+-htdocs
|
+-perl_scripts
| |
| +-MyProj
|
+-MyProj
|
+-perl_scripts


my httpd.conf looks like this


LoadModule perl_module modules/mod_perl.so
Alias /perl/ /online/apache2/htdocs/perl_scripts/
PerlModule ModPerl::Registry
<Location /perl/>
SetHandler perl-script
PerlHandler ModPerl::Registry
Options +ExecCGI
PerlSendHeader On
allow from all
</Location>


My question is while I can run my perl scripts by using the following url
http://localhost/perl/test.pl
&
http://localhost/perl/MyProj/test.pl (in which case my perl files have to be in the htdocs/perl_scripts/MyProj directory)

Instead I want to have my perl files in htdocs/MyProj/perl_scripts and access them like
http://localhost/MyProj/perl/test.pl
so that I can write new applications and deploy them by simply copying them to the htdocs folder instead copying the perl scripts to the perl_scripts dir.

That is when I use the /perl modifier anywere apache must execute the perl files from the current document root.

I'm new to perl/cgi and apache for the web...

thanks
shyam

shyam
07-24-2005, 02:39 PM
ok guyz i found that one after long hours of googling (whew !!)

the simple trick is to make apache execute all files that have extensions .cgi/.pl which is done by adding this line to httpd.conf
AddHandler cgi-script cgi pl

and give permission for our cgi-bin dir to execute cgi
<Directory /usr/local/apache/htdocs/MyProj/cgi-bin>
Options +ExecCGI
</Directory>

the only drawback i found to this method is that all the cgi/perl scripts must necessarily be executable or else apache will complain ;)