cgi-bin error regarding perl script
Hey
I'm tring to get cgi working on my server at home, just so I can learn how to do it. The setup is that the ScriptAlias is to my cgi-bin folder /usr/www/cgi-bin and that folder has <Directory> options: Code:
<Directory /usr/www/cgi-bin> Code:
[Thu Dec 09 10:17:12 2004] [error] [client 10.0.0.1] (8)Exec format error: exec of '/usr/www/cgi-bin/first.pl' failed I think I know how to get everything working, however, my qustion is to clarify how cgi is working. When I set the Handler, should I have installed a seperate module, or is it installed by default, but turned off (I think my apache config turns it on)? Is it the cgi module which executes these files? Secondly, do I need to install perl on my server, or is that also installed by default? If so, how does one turn it on? The apache documentation suggested executing the first.pl file from the command line, which i did: Code:
root@pi cgi-bin # ./first.pl Any pointign in the right direction would be very much appreciated. Thanks hamish |
To find out if you have perl installed and the correct path which is use at the beginning of the script, run:
Code:
which perl Code:
perl first.pl Code:
chmod +x first.pl |
Success! I get a response.
That means that perl is installed on the server. Now I need to know why i get an internal server error with apache2. Do i have to tell apache where perl is on the machine, in order for it to work? Hamish |
Hey
I tried with an regular /bin/sh file, and it will work, however, my browser demands that i download the file (dater.sh) first and then it runs it. How can I get arround this? Hamish |
There is no need to tell apache where perl is installed. Check your script for errors.
|
ok. I will check perl script.
Can you think of a reason that the regular /bin/sh executable would want to be downloaded before it ran? Instead of just running inside the open brower? Excample: http://hamishnet.homelinux.com/cgi-bin/dater.sh hamish |
I'd guess that you have to add the .sh extension in the AddHandler directive
|
hey
I'm done that. but no luck. hamish |
Do you restart the server after you make the changes in httpd.conf?
|
yeah.
I have found some google sites saying that files can be downloaded and not executed if the server is configured not to execute the files. HOwever, i'm fairly sure it is correctly done: I have: script alias: Code:
ScriptAlias /cgi-bin/ /usr/www/cgi-bin/ Code:
AddHandler cgi-script .cgi .sh Code:
<Directory /usr/www/cgi-bin> hamish |
You don't need the AddHandler and SetHandler inside the <Directory...> because apache executes everything in that directory. In fact to test this I created a bash script inside the cgi-bin directory, made it executable and my apache (version 1.3.33) ran it like a charm.
Here is my Directory entry for the ScriptAlias directory: Quote:
|
hey
i have done that now. I copied your code (and changed the directory path). I commented the "AddHandler cgi-script .cgi .sh" line. However, it still seems to want to download it. Really irritating me! It is so simple, I just can't understand what I'm doing wrong! Hamish |
All times are GMT -5. The time now is 08:19 AM. |