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

Hi, I am using my computer as a webserver through apache and whenever i try to run a perl script, i get an error. This is the script that i try to run:
#!/usr/bin/perl print "Content-type: text/html\n\n"; print <<END_HTML; <html> <head></head> <body>Hello again, World!</body> </html> END_HTML
I put it in the cgi-bin of my webroot and i named it hello.cgi. so when i go to it on the web
http://webpage/cgi-bin/hello.cgi
this is the error that comes up:
The requested URL /cgi-bin/hello.cgi was not found on this server.
I changed the permission of the hello.cgi to 755 and i have also tried naming it hello.pl, but nothing seems to be working. Perl is in the indicated place and everything. I don't know what i need to do to get this working. Any help would be appreciated. THANKS!

2005-02-26 Janitored by Arunbear - added code tags, as per Monastery guidelines

Replies are listed 'Best First'.
Re: Can't get Perl script to run
by Elijah (Hermit) on Feb 26, 2005 at 00:24 UTC
    grep -n 'cgi-bin' /etc/httpd/conf/http.conf

    Gives you something like:

    593:ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" 596:# "/var/www/cgi-bin" should be changed to whatever your ScriptAlia +sed 599:<Directory "/var/www/cgi-bin"> 899:#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
    /var/www/cgi-bin is the location of my ScriptALias directory and this is where the cgi script should be placed.

    If your http.conf file is not located in the same location mine is then "find" or "locate" it.

    find / -name "httpd.conf"
    locate "httpd.conf"

    If for some reason you are running Apache on Windows then do a search for the config file and manually search it for the cgi-bin location.

      Thanks!! I got it now!
Re: Can't get Perl script to run
by saintmike (Vicar) on Feb 25, 2005 at 22:12 UTC
    Looks like where you put the script is not where your web server searches for it. Typically, the cgi-bin directory is not under the document root (webpage), but in a different hierarchy. Check your apache configuration file and search for cgi-bin to figure out the real cgi directory.
Re: Can't get Perl script to run
by chas (Priest) on Feb 26, 2005 at 02:24 UTC
    In addition to the info provided in the previous replies, note that you may have to use some address of the form
    http://localhost/cgi-bin/hello.cgi
    if you are trying to run the script on your own machine where the server is installed (that seems to be pretty standard for the loop back address; you should be able to use 127.0.0.1 also.)
    chas