Saturday, August 4, 2012

Effective Solutions for 500 error (Premature End of Script Headers)

October 21, 2009 by  
Filed under cPanel, Direct Admin, General, HyperVM, Kloxo, Plesk, Webmin

There may a number of reasons and solutions for it. We listed a few here for your conveniences.


File/Directory Permission

  • error: directory is writable by others: (/home/user/public_html/)
    This could be easily fixed by just changing the permissions of the file/directory in question. You can change the permissions by using the File Manager within cPanel, or an FTP client (for example Filezilla). The correct permissions are 755. In our cPanel tutorial you can find detailed instructions for changing permissions through the File Manager.
  • error: file has no execute permission:  (/home/user/public_html/)
    In order to fix the issue, you should use your FTP client or the Filemanager within the cPanel and change the permissions of the file in question to 755.
  • Permission denied: /home/user/public_html unable to check htaccess file, ensure it is readable
    The error is caused by incorrect permissions of the .htaccess file. However, such error message could be invoked if the permissions for the folder are not the correct ones either. Please ensure that both folder and .htaccess file within are set with 755 permissions.

If you are in cPanel server, try running /scripts/chownpublichtmls in SSH. Also check sub folder permissions are 0755 on any affected account. Frontpage is wonderful for screwing with folder permissions, although it could be something else, remotely possible I guess.


Wrong Upload Mode (FTP)

Most of the time, this error is caused by either uploading in binary instead of ASCII or by incorrect file permissions (not chmod 755).

SuPHP Symlink

suPHP module was attempting to run php5 on the server, unfortunately php5 was a symlink to the php-cli executable and not the php-cgi executable as it was expecting.
The fix was simple in the end, issue the following command.

ln –s /usr/local/php /usr/local/php5


Interference with an .htaccess file
If you have implemented .htaccess on your site, it may be interfering with the web page you are trying to load into your browser. Please double check the .htaccess configurations to ensure that it doesn’t contain any errors.
To confirm whether an malconfigured .htaccess is the cause of the 500 Internal Server error, either remove or rename the .htaccess file.

PHP Coding Timing Out
If your php script makes external network connections, the connections may time out. If too many connections are attempted and time out, this will cause the Internal Server Error. To prevent such time outs and errors, we suggest that your relevant php scripts be coded with some timeout rules.

Syntax or coding errors in your CGI/Perl script
CGI Script Guidelines:

  • When editing your CGI script, use a program that saves the file as a ‘text file’ type. DO NOT use Wordpad that comes with Microsoft Windows because it doesn’t save files in pure ASCII text format. Use Notepad instead to edit files.
  • Upload your CGI scripts in ASCII mode into the cgi-bin directory.
  • Set the file permissions on the CGI script file and directories to be ‘chmod 755.’ If you use an FTP program to transfer files, right-click on the file and select change file attributes. Using FileZilla, enter 755 under numeric value.
  • If you are still getting errors, you can instruct the server to display any errors messages to the web browser by adding the following line near the top of the Perl script:

#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);

  • Double-check any changes you have made to the script and also ensure the following line appears after the perl path:

print “Content-type: text/htmlnn”;

  • Ensure that the perl modules you require for your script is supported on your host
  • If your website is driven by Joomla, some third party components may result in a 500 Internal Server error.


Log File Size Issue

There is one major problem with SuPHP, that is the logs fill up pretty fast and once you hit a 2GB log file, apache will start throwing 500 errors. So, check the size of log files and clean up necessary.

  • Usually the suphp.log file is the culprit. It lives in /var/log/suphp.log. If this has hit 2GB, roll it and apache will be good to go.
  • There is no suphp.log file in /var/log. In this case, check your suphp.conf file for the location. The conf file is usually located in /etc/httpd/suphp/ or similar.
  • If your conf file is pointing to a log file that is under 2GB, you need to dig a tad deeper. Check out your php.ini file and see if/where you are saving your php error file. Check if this file is over 2GB.

GD Star Rating
loading...
Effective Solutions for 500 error (Premature End of Script Headers), 7.8 out of 10 based on 4 ratings
Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Related posts:

  1. Error reloading bind on server rndc: subdomain creation error
  2. Installing and configuring monit to monitor your server(s)
  3. Secure your Linux Servers
  4. Installing Suhosin as PHP Extension in Linux
  5. DoS Protection via APF, BFD, DDOS and RootKit

Comments

2 Responses to “Effective Solutions for 500 error (Premature End of Script Headers)”

Trackbacks

Check out what others are saying about this post...
  1. Effective Solutions for 500 error (Premature End of Script Headers … Scripts Rss says:

    [...] the original post:  Effective Solutions for 500 error (Premature End of Script Headers … By admin | category: directory script, scripts | tags: ascii, cgi, file, ftp, notepad, [...]

  2. [...] deixar apenas essa alternativa, e facilitar a vida de quem, como eu se deparou com estes erros, este e este blogs trazem algumas soluções que podem ser úteis, caso o problema não seja o seu [...]



Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!