Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

how do i configure apache webserver to run perl scripts

by Anonymous Monk
on Apr 25, 2000 at 22:22 UTC ( [id://9060]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question: (http and ftp clients)

I am trying to run my html which is calling a cgi script. After i hit submit i am getting a 404 error. if i run my perl script on the command line it runs fine.

Originally posted as a Categorized Question.

  • Comment on how do i configure apache webserver to run perl scripts

Replies are listed 'Best First'.
Re: how do i configure apache webserver to run perl scripts
by btrott (Parson) on Apr 25, 2000 at 22:52 UTC
    A 404 error means that your CGI script wasn't found, which doesn't necessarily mean that Apache isn't configured to run CGI scripts.

    You need to tell Apache two things:

    • that certain files (identified by file extension) are CGI scripts and should be executed.
    • where such scripts live.
    A very easy way to do this is to use the ScriptAlias directive. It maps a URL path (like "/cgi-bin/foo.cgi") to a filesystem path (like "/home/httpd/cgi-bin/foo.cgi"). It also tells Apache that all files in that directory are CGI scripts and should be executed.

    So, to configure your Apache for the above path configs, add this line to your httpd.conf:

    ScriptAlias /cgi-bin/ /home/httpd/cgi-bin/
    You may need to adjust the paths, but that should get you started.

    It's in the Apache Docs.

    If you don't have access to httpd.conf, you can use .htaccess files, but you can't use ScriptAlias. In that case you can use the AddType directive, which associates file extensions with mime types. More in the appropriate docs.

Re: how do i configure apache webserver to run perl scripts
by merlyn (Sage) on Apr 26, 2000 at 02:46 UTC
Re: how do i configure apache webserver to run perl scripts
by taint (Chaplain) on Apr 19, 2013 at 19:56 UTC
    Another thing to consider is simply telling Apache to consider .html files as being peppered with perl code:
    AddOutputFilter Includes html
    To use the above, you must also include Includes in the Options section of your httpd.conf file.
    Options Indexes Includes etc...
    This way, you may include perl modules, or bits of perl code you'd like to exec, much as you would with the more commonly used extension: .shtml. In fact you could invent any extension you like -- .perl5, for example.

    HTH

Re: how do i configure apache webserver to run perl scripts
by dushyantvaghela (Initiate) on Mar 14, 2015 at 06:34 UTC
    You'll need to take a look at your apache error log to see what the "internal server error" is. The four most likely cases (in my experience) would be:
    The CGI program is in a directory which does not have CGI execution enabled.

    Solution: Add the ExecCGI option to that directory via either httpd.conf or a .htaccess file.

    Apache is only configured to run CGIs from a dedicated cgi-bin directory.

    Solution: Move the CGI program there or add an AddHandler cgi-script .cgi statement to httpd.conf.

    The CGI program is not set as executable.

    Solution (assuming a *nix-type operating system): chmod +x my_prog.cgi

    The CGI program is exiting without sending headers.

    Solution: Run the program from the command line and verify that a) it actually runs rather than dying with a compile-time error and b) it generates the correct output, which should include, at the very minimum, a Content-Type header and a blank line following the last of its headers.

Re: how do i configure apache webserver to run perl scripts
by Anonymous Monk on Nov 14, 2000 at 09:30 UTC

    Re: how do i configure apache webserver to run perl scripts

    Originally posted as a Categorized Answer.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://9060]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-16 06:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found