Find the answer to your Linux question:
Results 1 to 5 of 5
Hiya. I'm currently running a HTTP web-server on my Ubuntu (10.04) machine at the minute - mainly for practising PHP scripts as well as Perl CGI scripts and PHP works ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2008
    Posts
    35

    Perl refuses to work in Ubuntu server (lamp-server)


    Hiya.

    I'm currently running a HTTP web-server on my Ubuntu (10.04) machine at the minute - mainly for practising PHP scripts as well as Perl CGI scripts and PHP works just fine after installing libapache-mod-php5 but when I do the same for Perl (libapache-mod-perl2) my Perl CGI files refuse to work.

    All configuration files are currently left at their defaults after installing lamp-server though I've browsed through /etc/apache/apache2.conf as well as /etc/apache2/httpd.conf which is mentioned in a few documentation files on the internet but that is empty. I'm using the default server root at /var/www since I'm only using this web-server for practising coding skills as well as learning more and apache2 is only turned on while I'm doing this so there's no security issues with it this way.

    So my problem is when I browse to http://localhost/perl_test.pl it displays a download window asking me whether I'd like to either download or view my Perl file - neither of which I want to do, just run the file in my web-browser.
    At first I considered it possibly be compilation errors for my Perl script so I tried running perl perl_test.pl and it works okay in the terminal, so it's probably an Apache2 config'. I'm not too knowledgable about these config files but I have looked and cgi-bin is in /var/lib/cgi-bin which is supposedly lamp-server's default so would anybody know what my problem is?

    I've looked and tried many things but it doesn't work.

    Oh. And for confirmation purposes this is all my script contains:

    Code:
    #!usr/bin/perl
    #cgihi.pl
    use strict;
    use warnings;
    
    print "Content-type: text/plain\n\n";
    print "Does it wor?";
    print "IP: . $ENV{REMOTE_ADDR}\n";

  2. #2
    Linux Engineer Segfault's Avatar
    Join Date
    Jun 2008
    Location
    Acadiana
    Posts
    877
    #!usr/bin/perl

    #!/usr/bin/perl

  3. #3
    Just Joined!
    Join Date
    Dec 2008
    Posts
    35
    That was just a typo when I was typing out the post above. The script is exactly how it should be and to confirm this I have changed it countless amount of times.

    I can't even print plain text to the client with a Perl script at the minute even after following these instructions

  4. #4
    Penguin of trust elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    3,483
    Try adding

    Code:
    # enable mod_perl
    <Files ~ "\.(pl|cgi)$">
           SetHandler perl-script
           PerlResponseHandler ModPerl::Registry
           Options +ExecCGI
           PerlSendHeader On
    </Files>
    to /etc/apache2/sites-available/default and then bouncing the apache service. This used to be sudo /etc/init.d/apache2 restart but it may have changed.
    What do we want?
    Time machines!

    When do we want 'em?
    Doesn't really matter does it!?


    Conkybots: Interactive plugins for your Conkys!

  5. #5
    Just Joined!
    Join Date
    Dec 2008
    Posts
    35
    Quote Originally Posted by elija View Post
    Try adding

    Code:
    # enable mod_perl
    <Files ~ "\.(pl|cgi)$">
           SetHandler perl-script
           PerlResponseHandler ModPerl::Registry
           Options +ExecCGI
           PerlSendHeader On
    </Files>
    to /etc/apache2/sites-available/default and then bouncing the apache service. This used to be sudo /etc/init.d/apache2 restart but it may have changed.
    Great, that done it. Thanks a lot for your help both, I really appreciate it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •