1

I am trying to configure apache2 running on ubunutu 12.04 to run perl script. But the script is not running when i submit the get request from the client. Below is the default config i have made (after reading in internet):

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /home/Suresh/myFiles
 <Directory /home/Suresh/myFiles>
        Options Indexes FollowSymLinks MultiViews +ExecCGI
        AddHandler cgi-script .pl
        AllowOverride ALL
        Order allow,deny
        allow from all
        ExpiresActive On
        ExpiresDefault "access plus 6 hours"
      <FilesMatch "\.(nff)">
            Header set Cache-control "max-age=0, no-cache, proxy-revalidate"
            Header set Content-Type "application/octet-stream"
            Header set Pragma "no-cache"
            Header unset Vary
            Header set Connection "Keep-Alive"
      </FilesMatch>
   </Directory>

I have a perl script saved in the /home/Suresh/myFiles with chmod 777 permissions. Below is the perl code:

#!/usr/bin/perl
use strict;
use CGI;
#require LWP::UserAgent;
my $q = new CGI;
my @rawCookies = split /~/, $ENV{'HTTP_COOKIE'};
my $extfile = '/home/suresh/Cookies.txt';
open(FH, ">>$extfile") or die "Cannot open file";
print FH "STB Cookies: ", $ENV{'HTTP_COOKIE'}, "\n";   
close FH;

The perl works perfectly fine when run with perl command.

The script is not getting executed in default config file. Can anyone suggest me what else needs to be done ?

Suresh
  • 153
  • 2
  • 2
  • 9

1 Answers1

0

You should use this conf:

<VirtualHost *:80>  
  Alias /perl/ /home/Suresh/myFiles
  <Location /perl/>
      SetHandler perl-script
      PerlResponseHandler ModPerl::Registry
      PerlOptions +ParseHeaders
      Options +ExecCGI
      Order allow,deny
      Allow from all 
  </Location>
</VirtualHost>

Then you must make your script executable % chmod a+rx /home/Suresh/myFiles/script.pl

Make restart apacher server and go to http://localhost/perl/script.pl

That's all.

P.S. More info you may find there http://perl.apache.org/sitemap.html

edem
  • 3,222
  • 3
  • 19
  • 45