in reply to mod-perl configuration under Apache2

i have the same setup as you (Apache2 with mod_perl2 on Ubuntu 6.10) and have no problem running Perl scripts under mod_perl2.

one way to get started is by running Perl scripts using ModPerl::Registry as described in the mod_perl2 documentation. you could take these steps:

  1. (in one terminal) keep an eye on what Apache2 is doing:

    sudo tail -f /var/log/apache2/error.log
  2. (in another terminal) make sure mod_perl2 is loaded by Apache2:

    sudo a2enmod perl /etc/init.d/apache2 restart
  3. create the test directory /var/www/mp2-test and place a simple Perl CGI script there with this content (your posted test CGI script is incorrect and will produce a warning, because it doesn't print a content line):

    #!/usr/bin/perl print "Content-type: text/plain\n\n"; print "mod_perl 2.0 rocks!\n";
  4. configure Apache2 to run scripts in /var/www/mp2-test with mod_perl2:

    PerlModule ModPerl::Registry <Location "/mp2-test/"> SetHandler perl-script PerlHandler ModPerl::Registry Options +ExecCGI </Location>

also check out the freely available ModPerl Book that covers mod_perl2. and if your still having troubles post back.

. :)))))

Replies are listed 'Best First'.
Re^2: mod-perl configuration under Apache2
by TOD (Friar) on Mar 07, 2007 at 07:49 UTC
    it doesn't matter whether you chose PerlRun or Registry, they both inherit directly from ModPerl::RegistryCooker. The main difference is that PerlRun always compiles the scripts, whereas Registry caches the compiled codes and compiles only if the files change on disk.
Re^2: mod-perl configuration under Apache2
by Bruce32903 (Scribe) on Mar 07, 2007 at 17:12 UTC
    I have modified my test program as shown:

    #!/usr/bin/perl
    use warnings;
    use strict;
    print "Content-type: text/plain\n\n";
    print "\nTHIS IS A TEST\n";
    

    I have modified the end of my /etc/apache2/apache2.conf file as shown:

    
    Alias /perl/ /var/www/perl/
    
    #PerlModule ModPerl::PerlRun
    PerlModule ModPerl::Registry
    
    <Location /perl/>
       SetHandler perl-script
       PerlHandler ModPerl::Registry
       #PerlHandler ModPerl::PerlRun
       Options +ExecCGI
       #PerlSendHeader On
    </Location>
    

    When I try to access (run) the perl program I still get the "Mozilla does not know how to handle this file type" box.

    When I try to access something that does not exist I still get a "not found" screen with "Apache/2.0.55 (Ubuntu) mod_perl/2.0.2 Perl/v5.8.8 Server at 192.168.20.210 Port 80" at the bottom (note mod_perl is included).

    Any more ideas?
    Thanks,
    Bruce

      how about cleaning up you Apache2 configuration file? replace this lines:

      PerlModule ModPerl::PerlRun #Alias /perl/ /var/www/perl/ ScriptAlias /cgi-bin /var/www/cgi-bin/ ScriptAlias /perl/ /var/www/perl/ <Location /perl> allow from all SetHandler perl-script AddHandler cgi-script .cgi .pl #PerlHandler Apache::Registry #PerlHandler Apache::PerlRun PerlResponseHandler ModPerl::PerlRun Options +ExecCGI PerlSendHeader On </Location> <Directory /var/www/perl> allow from all Options +ExecCGI #AddHandler cgi-script .pl #SetHandler perl-script PerlResponseHandler ModPerl::PerlRun </Directory>

      with only this:

      PerlModule ModPerl::Registry ScriptAlias /cgi-bin /var/www/cgi-bin/ <Location "/perl"> SetHandler perl-script PerlHandler ModPerl::Registry Options +ExecCGI </Location>

      as far as i can tell, the directive shown below is telling Apache to serve content from /var/www/perl as CGI using mod_cgi and because it's written before the mod_perl settings it takes precedence over those, ignoring them:

      ScriptAlias /perl/ /var/www/perl/

      also, may i suggest that you get in the good habbit of Debian/Ubuntu W.R.T. setting up Apache2 servers? that is create a file in /etc/apache2/sites-available with your settings and enable it using this command

      a2ensite myproject && /etc/init.d/apache2 restart

      that way you can exclude parts of your configuration in case you need to debug your Apache configuration. more info is in your /etc/apache2/README file.

      :)))))
        I made the suggested changes and still get "Mozilla does not know how to handle this file type".

        The /var/log/apache2/error.log file has only the restart notice at restart time. There are no errors logged during restart.

        The display at the bottom of a non existant page and the http://x.x.x.x/server-status pages include "mod_perl", so I still assume that my "apt-get install libapache2-mod-perl2" has worked successfully.
      I was so busy looking at the code I didn't even see the download tags in the response. Thanks for the extra effort. Sorry I didn't put it to good use.

      Bruce