ActivePerl and Apache CGI config

Posted by troyt on 2006-06-26 15:21
OS: All / Any | Product: ActivePerl | tags: Apache CGI Perl
Question: 

How do I configure Apache to use ActivePerl for CGI?

Answer: 

To configure appache to use ActivePerl for CGI:

  1. Edit your httpd.conf file. You can open this file by selecting
    Start | Programs | Apache HTTP Server | Configure Apache Server
    | Edit the Apache httpd.conf Configuration File
    which will open
    httpd.conf file in the notepad editor.
  2. Search for "DocumentRoot". You should see a section that looks like this:

    # DocumentRoot: The directory out of which you will serve your
    # documents. By default, all requests are taken from this directory, but
    # symbolic links and aliases may be used to point to other locations.
    #
    DocumentRoot "C:/apacheroot"

  3. Change the value of DocumentRoot to the actual local path to your web site.
    Make sure you use '/' forward slashes in the path. Apache doesn't understand
    '\' backward slashes in paths.
  4. Just below the DocumentRoot section you will see the main directory section:
    Options FollowSymLinks
    AllowOverride None
    

    on the Option line, add "ExecCGI":

    Options FollowSymLinks ExecCGI
    
  5. Search for the line:
    #AddHandler cgi-script .cgi
    

    Remove the '#' at the beginning to uncomment this line.

    AddHandler cgi-script .cgi
    

    If you want to use the .pl extension for your CGI scripts, change the extension
    so that the line looks like this:

    AddHandler cgi-script .pl
    
  6. Save and close httpd.conf.

  7. Restart the Apache service using the Apache Service
    Monitor
    .
  8. Test your configuration by placing the following test script in your
    DocumentRoot directory as 'test.pl' (or test.cgi). Open the
    local URL http://localhost/test.pl in your browser.

    The test script:

    #!c:\perl\bin\perl.exe
    # ^^^ this must be the first line of the script! ^^^
    # start code

    use strict;
    use CGI;
    my $q = new CGI;

    # print header and start the markup output

    print $q->header( "text/html" ),$q->start_html( "hello from perl cgi!" );
    print $q->h2("Hello World!");
    print $q->end_html;
    # end code

The ITsmith | Mon, 2008-09-15 15:05

How does one use Apache/mod_perl on Linux with ActiveState?

I use a number of applications, such as RT and Bricologe, that utilize mod_perl. Is there a way to configure Apache to utilize ActivePerl instead of the already installed Perl that comes with the distro?

cgchoffman
ActiveState Staff
Mon, 2012-01-16 15:16

If you happen to run into this error that means that you're shebang line is most likely pointing to the wrong perl.

With the above example it is for Perl x32. For x64 replace the first line with the following line at the top of your test.cgi file:
#!c:\perl64\bin\perl.exe