954,176 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

500 internal server error

I am trying to execute a basic hello world cgi script. However I keep getting 500 error. I tried changing the scriptsock setting in my httpd.conf file as well as file permissions and every other suggestion I could find on various postings.... I have reinstalled the OS and started from scratch. I am pretty new to linux however I have learned alot over the past 2 months..Any help would be so appreciated.

Izick

izick
Newbie Poster
23 posts since Feb 2004
Reputation Points: 10
Solved Threads: 0
 

Which version of Apache are you running?

TheOgre
Posting Whiz
393 posts since Aug 2003
Reputation Points: 128
Solved Threads: 9
 

Thank you for replying so quickly...Redhat9

izick
Newbie Poster
23 posts since Feb 2004
Reputation Points: 10
Solved Threads: 0
 

Oh sorry....Apache 2.0 (httpd 2.0.46)

izick
Newbie Poster
23 posts since Feb 2004
Reputation Points: 10
Solved Threads: 0
 

RedHat 9 is the distribution of Linux that Apache is running on, not the Apache version. Do you know which version of Apache you have? I don't use RedHat, so I don't know which version it ships with. (Look at the bottom of the error page, and if you have the server signature turned on in httpd.conf, it'll say something like "Apache 1.3.27 at www.mydomain.com Port 80" or something similar.)

TheOgre
Posting Whiz
393 posts since Aug 2003
Reputation Points: 128
Solved Threads: 9
 

Heh.. you were reading my mind while I was posting that :P

TheOgre
Posting Whiz
393 posts since Aug 2003
Reputation Points: 128
Solved Threads: 9
 

Are you restarting httpd after making changes to httpd.conf ?
(apachectl start|stop|restart)

TheOgre
Posting Whiz
393 posts since Aug 2003
Reputation Points: 128
Solved Threads: 9
 

I originally uncommented the ScriptSocks log/cgisocks then rebooted the machine which httpd is set to restart on boot. It was recommended that I change the file group and owner to apache so i did that two and chmod all the files to 755.


izick
Newbie Poster
23 posts since Feb 2004
Reputation Points: 10
Solved Threads: 0
 

Try commenting the line about ScriptSocks log/cgi and do:
apachectl restart

You don't have to reboot the box to restart Apache :) ...rebooting is for adding hardware :P

TheOgre
Posting Whiz
393 posts since Aug 2003
Reputation Points: 128
Solved Threads: 9
 

Ok...I will try it now. Thank you for your help. I will post in a few and let you know.
Quick question. It seems like I can only get ftp access outside of my /home/user folder if I change the ownership of the /var/www/ folder to owner-me so in other words when I try to upload directly to the /var/www/cgi-bin/ it will not transfer the file unless I make myself the owner. I have tried adding me to the root user accound under the user administration control panel but no luck. ANy suggestions

izick
Newbie Poster
23 posts since Feb 2004
Reputation Points: 10
Solved Threads: 0
 

I commented the scriptsock changed all the group and owner properties to apache. Then chmod all files /var/ /www/ /cgi/ hello.cgi to 755 then restarted apache. still got 500 error. So I uncommented the scriptsock again and restarted, but still got error. :

izick
Newbie Poster
23 posts since Feb 2004
Reputation Points: 10
Solved Threads: 0
 

Are you accessing this box from a Windows machine? If so, I highly recommend installing Samba. Once you have Samba installed, you can share your www directory, and map that shared directory as a drive on your Windows box and just copy the files to it.

If you're transferring the files from another *nix box using FTP, you need to give your Linux user +w access to that directory, or even chmod -R 777 /var/www/*

Also, check the section of httpd.conf where it deals with the cgi-bin directory, as it might be aliased to another directory - ensure the entry is pointing to the proper path for your cgi-bin directory.

TheOgre
Posting Whiz
393 posts since Aug 2003
Reputation Points: 128
Solved Threads: 9
 

Can you send me your hello.cgi file so I can check it on my server? If I can get it working on my 2.x server, I'll know what to tell you to look for/check on your server.

TheOgre
Posting Whiz
393 posts since Aug 2003
Reputation Points: 128
Solved Threads: 9
 

That is really helpful. I am tired of transfering things twice and even sicker of changing ownership rights. That you..I will map the drive for now that seems the easiest way. I have samba up and running. Here is the script.

#!/usr/bin/perl
# simple Hello World script
print "Content-type: text/plain\n\n";
print 'Hello World!';

izick
Newbie Poster
23 posts since Feb 2004
Reputation Points: 10
Solved Threads: 0
 

I checked the scriptalias directive and it was pointing to /var/www/cgi-bin/ also I looked at the apache error logs and it says premature end of script header

izick
Newbie Poster
23 posts since Feb 2004
Reputation Points: 10
Solved Threads: 0
 

OK, here's what I did to get it to work:

Once you transfer it to your Linux box, re-edit the file (using a text editor such as vi or pico on your Linux box) to make sure there's no ^M characters at the line ends, then chmod 755 hello.cgi

Have a look: http://www.geekis-kahn.net/cgi-bin/hello.cgi

TheOgre
Posting Whiz
393 posts since Aug 2003
Reputation Points: 128
Solved Threads: 9
 

Did that help?

TheOgre
Posting Whiz
393 posts since Aug 2003
Reputation Points: 128
Solved Threads: 9
 

The "premature end of script header" was in my httpd-errors.log before I edited the script and removed the ^M characters from the line ends. After I did that and chmod 777 it worked fine.

TheOgre
Posting Whiz
393 posts since Aug 2003
Reputation Points: 128
Solved Threads: 9
 

I did not make any changes to the file..I opened it in a text editor and it did not change compared to the text i sent over to you. so I just chmod's it to 775 and changed the ownership and group to apache apache. However still get error.

izick
Newbie Poster
23 posts since Feb 2004
Reputation Points: 10
Solved Threads: 0
 

When I am looking for the ^M will it look exactly like "^M" I dont see anything other than the ; at the end. I am just using the default editor when I " gedit hello.cgi " from the termial. I changed to 777, also when I run the script from the command line it runs just fine.

izick
Newbie Poster
23 posts since Feb 2004
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: