mcorbett has asked for the wisdom of the Perl Monks concerning the following question:

Somebody please help me. I am very new to Perl and I have got a serious problem that I have to resolve quickly and timely.

I have installed the Activestate version of Apache ver 1 and Perl 1.3.27 on a xp professional laptop. The Apache server starts ok and resolves HTML but as soon as it recives a *.pl script it just shows the script and does,nt process it.

Please can anyone at least point me in the right direction.

Replies are listed 'Best First'.
Re: Beginners stupid question
by Ovid (Cardinal) on Jun 27, 2003 at 20:28 UTC
Re: Beginners stupid question
by hsweet (Pilgrim) on Jun 27, 2003 at 21:06 UTC
    To start, you have your versions backwards. You probably have apache 1.3x. Perl should be version 5.6 or 5.8. You can check that by typing perl -v at the command line.

    Once you are sure perl is working, test your script without Apache.

    If that's ok, you might need to change the shebang line to point to whatever folder the perl binary is in. #c:/perl/bin or wherever is happens to be.

    Apache might need to be configured to run scripts. At the least you might need a scriptalias directive. If you never did this before, it's in a file called httpd.conf. I have some information about it at http://frontiernet.net/~hsweet/comp1/apache.htm

    Getting scripts to run doesn't really involve anything difficult, but you do have to get a lot of ducks in a row. Also, Teach Yourself Perl in 24 Hours has a good introduction to CGI

    good luck

    Time flies like an arrow, fruit flies like banannas

Re: Beginners stupid question
by hmerrill (Friar) on Jun 27, 2003 at 21:03 UTC
    Beware - I have no experience on Activestate, but I do have some experience with Apache and Perl on Linux. If you can locate your Apache configuration file(mine on Red Hat Linux is /etc/httpd/conf/httpd.conf), look for something like this
    #AddHandler cgi-script .cgi
    and uncomment it. Then save the file, and restart Apache, and try browsing to you script.

    That will allow it to recognize scripts with a .cgi extension - I'm not sure what you need to do to get it to run .pl extension scripts, but just to see if it works rename your .pl file to .cgi. Might be as simple is either adding a '.pl' to the AddHandler line above, but I really don't know.

    HTH.
Re: Beginners stupid question
by chunlou (Curate) on Jun 28, 2003 at 01:45 UTC
    It doesn't sound right the script got displayed instead of browser asking you to download it. Because if they browser is not receiving a text/html or text/plain http header, it probably shouldn't display the file (for security reason). You could check your Apache's httpd.conf file to see (if CGI) whether you have something like:
    <IfModule mod_alias.c> # .... other stuff ..... ScriptAlias /cgi-bin/ "d:/apache/cgi-bin/" <Directory "c:/apache/cgi-bin/"> AllowOverride None Options None Order allow,deny Allow from all </Directory> # .... other stuff ..... </IfModule>
    If mod_perl, it could be:
    # ... other stuff .... LoadModule perl_module modules/mod_perl.so # ... other stuff .... <IfModule mod_alias.c> # ... other stuff .... Alias /mod_perl/ "c:/apache/mod_perl/" # s.t. http://host/mod_perl/script.pl <Location /mod_perl> AllowOverride None SetHandler perl-script PerlHandler Apache::Registry Options +ExecCGI PerlSendHeader On Order allow,deny Allow from all </Location> # ... other stuff .... </IfModule>
    or
    # ... other stuff .... LoadModule perl_module modules/mod_perl.so # ... other stuff .... PerlModule Apache::DBI Apache::Request # ... other stuff .... <Files ~ "\.pl$"> SetHandler perl-script PerlHandler Apache::Registry Options ExecCGI PerlSendHeader On PerlInitHandler Apache::Reload PerlSetVar ReloadAll Off </Files>
    The first mod_perl example is a directory-oriented configuration; second, file-extension-oriented.
Re: Problem with Apache config on XP Pro
by mcorbett (Initiate) on Jun 30, 2003 at 16:44 UTC
    Thank you for all your help Monks, It came down to the ScriptAlias Directive. It was one of those situations where you need a little nudge in the right direction to get you going, again Thanks.