Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I've installed apache2 on Ubuntu 11.04, and localhost is working. I created a simple printenv.pl script and put it in the following directory

$ mv printenv.pl /usr/lib/cgi-bin/
$ chmod +rx /usr/lib/cgi-bin/printenv.pl

However when I go to http://127.0.0.1/cgi-bin/printenv.pl, I get a 500 Internal Server Error

I checked the error log at /var/log/apache2, and this is what it says:

[Mon Oct 24 11:04:25 2011] [error] (13)Permission denied: exec of '/usr/lib/cgi-bin/printenv.pl' failed
[Mon Oct 24 11:04:25 2011] [error] [client 127.0.0.1] Premature end of script headers: printenv.pl

Any suggestions on how I can fix this and run CGI scripts on my localhost?

share|improve this question

2 Answers 2

I had this problem as well. It turned out that I had set the .pl files permissions to 775. Apache does not allow user writable. Try changing your .pl file permissions to 755.

If that isn't it, check your web site permission settings in /etc/apache2/sites-available.

share|improve this answer

I had this exact problem (with the exact same paths, directories, permissions, etc.) just a little while ago, and all of a sudden understood what I read somewhere in the Apach2 documentation about a week ago.

That is this - everything you have set up so far is fine, but for security reasons, apache will not run any file (CGI, Perl, C, etc.) unless its write permission (w) is removed completely.

Make the permissions look like this: -r-xr-xr-x

Then it should work just fine. Hope this helps, let me know if it still doesn't work.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.