500 and 404 Internal Server Error


I received this error after I compiled the php 4.4.7. I had including error messages on broswer and in error log.

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@essaymonster.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Error log messages:

[Fri Aug 17 19:04:57 2007] [error] [client] Premature end of script headers: php.cgi
[Fri Aug 17 19:04:57 2007] [error] [client] File does not exist: /home/essaymonster/essaymonster.com/internal_error.html
[Fri Aug 17 19:08:25 2007] [error] [client] File does not exist: /home/essaymonster/essaymonster.com/unzip.com
[Fri Aug 17 19:08:25 2007] [error] [client] File does not exist: /home/essaymonster/essaymonster.com/missing.html
[Fri Aug 17 19:08:30 2007] [error] [client] Premature end of script headers: php.cgi
[Fri Aug 17 19:08:29 2007] [error] [client] File does not exist: /home/essaymonster/essaymonster.com/internal_error.html
[Fri Aug 17 19:19:19 2007] [error] [client] script ‘/home/essaymonster/essaymonster.com/cgi-bin’ not found or unable to stat
[Fri Aug 17 19:19:19 2007] [error] [client] File does not exist: /home/essaymonster/essaymonster.com/missing.html
[Fri Aug 17 19:19:23 2007] [error] [client] script ‘/home/essaymonster/essaymonster.com/cgi-bin’ not found or unable to stat
[Fri Aug 17 19:19:23 2007] [error] [client] File does not exist: /home/essaymonster/essaymonster.com/missing.html
[Fri Aug 17 20:30:47 2007] [error] [client] Premature end of script headers: php.cgi
[Fri Aug 17 20:30:47 2007] [error] [client] File does not exist: /home/essaymonster/essaymonster.com/internal_error.html
[Fri Aug 17 20:36:07 2007] [error] [client] Premature end of script headers: php.cgi


It looks from your error logs that a lot of things may be at issue there. Have you installed an application on your site, and if so, which application? (it might help with deciphering the error logs).

Are your permissions correct for running PHP-CGI under suexec ? - often that “Premature end of script headers: php.cgi” is the result of having permissions set less restrictively that 755 (like 777 or 666) for the directory a script runs in, or for the script itself; doing so often manifests itself with that error message.

The other error messages look like they were generated from some code running on your site, so it would help to know what, if anything, you are running there.

Obviously, several files are not being found where they are expected to be . :wink:



this is weird… I couldn’t even run info.php (http://www.essaymonster.com/info.php)

if you go to my root www.essaymonster.com, no matter what I click, it will give me that 500 internal error message.

As I aspect, I have set cgi-bin permission to 775 is that normaly what others would do? or it should be 755?
I just leave files in domain (essaymonster.com)

One thing I don’t understand. In DomainHost control panel, “manage domain” I select version 5 php. If I compile my own PHP what makes it to use the php I compiled? I heard that .htaccess controling which php I want to using. Am I right? Therefore, it don’t matter what version I select in control panel, it’s now controled by .htaccess?


It should be 755, suexec will return 500 errors with 775 set. :wink:

Yes, you are correct! if your .htaccess is set up properly to use you custom PHP installation, the Control Panel setting is irrelevant, as your PHP will be used, not DreamHost’s default installtion of PHP4 or PHP5. :slight_smile:



I don’t get it. I had re-compile my php all over again, but it’s still showing the same messages. I have nothing in my domain directory, why the system is keep looking for these folders and files? Who is trying to locate these files? (the php, apachy, mysql, the hosting server?)

I have no idea why it’s trying to locate these files and folders, how can I tell it not to?

[Tue Aug 21 05:20:05 2007] [error] [client] File does not exist: /home/essaymonster/essaymonster.com/missing.html
[Tue Aug 21 05:20:05 2007] [error] [client] File does not exist: /home/essaymonster/essaymonster.com/index.php
[Tue Aug 21 05:20:05 2007] [error] [client] File does not exist: /home/essaymonster/essaymonster.com/missing.html
[Tue Aug 21 08:06:41 2007] [error] [client] File does not exist: /home/essaymonster/essaymonster.com/index.php
[Tue Aug 21 08:06:40 2007] [error] [client] File does not exist: /home/essaymonster/essaymonster.com/missing.html
[Tue Aug 21 11:15:09 2007] [error] [client] File does not exist: /home/essaymonster/essaymonster.com/shop


Debugging a custom PHP installation can be challenging. It looks like something is trying to locate both index.php and /shop/ - only you can tell why it is doing that, as you have access to your directories.

You might want to check to see if you have any .htaccess directives that might be responsible for this (re-directs?, re-write rules?).

Make sure you completely clear your cache after your re-compile. You directory does appear to have stuff in it:

cgi-bin/ 21-Aug-2007 12:27 -
shop.zip 21-Aug-2007 12:20 4.6M
unzip.php 21-Aug-2007 12:20 56K

Make sure you don’t have any file in that directory that is read by apache as a “default” file. From the DH wiki:

[quote]The DirectoryIndex command lists all the files Apache should look for (in order) to determine what to display when somebody goes to a URL for a directory. That is, it’s the default file name for your web site. Ours is set to:

DirectoryIndex index.html index.shtml index.htm Index.html Index.htm Index.shtml default.htm Default.htm default.html Default.html default.shtml Default.shtml page1.html index.pl index.cgi index.php index.php3 index.phtml home.htm home.html home.shtml index.wml

As long as you name your “index” file any one of those things, it will work!

If you have two files with names from that list, Apache will show the one that shows up first (e.g. index.html will show up, even if you have an index.php file in the same directory). [/quote]



Thanks rlparker.

I had cleans up everything, I mean everything inside my domain directory, my php folder, dist and source folder. Re-compile again the PHP 4.4.7, it works and I can see my info.php page. but after I setup my web site then same problem happen again. Can access info.php, can see my index.php page, or anything else. HELP~~

Why it keep saying it could not access some files, and seems like there is php.cgi error. And no, I am sure I had set cgi-bin permission to 755.

Does it has something to do with MySQL db? or it has something to do with my self-extract web application that can build my web site in mins.

it give me following errors:

[Tue Aug 21 22:13:37 2007] [error] [client] Premature end of script headers: php.cgi
[Tue Aug 21 22:13:38 2007] [error] [client] File does not exist: /home/essaymonster/essaymonster.com/internal_error.html
[Tue Aug 21 22:47:17 2007] [error] [client] Premature end of script headers: php.cgi
[Tue Aug 21 22:47:17 2007] [error] [client] File does not exist: /home/essaymonster/essaymonster.com/internal_error.html


Outstanding! That means you are getting somewhere, and eliminates a lot of potential issues from consideration when you are trying to identify the source of the problem. Hopefully, you “info.php” was a “phpinfo()” run, so that you could inspect your PHP copnfiguration and confirm that everything your thought was installed actually was installed and is working correctly.

I’m assuming that you meant to say you can’t “access info.php, can’t see my index.php page, or anything else.” :wink:

Once you “setup” your website, you introduce a whole set of potential problems, and it could any one thing, more than one thing, or any combination of things involving that “website setup”. From the error messages you report, some of the potential issues could include:

  1. Permissions issues with the files or directories that comprise the “self-extracting web application” you are trying to install. This is especially likely if you prepared the “self-extracting” archive of the application as it was set-up/running on another server (with different settings for PHP? Not running PHP-CGI under suEXEC?, etc). Generally, running PHP-CGI on DreamHost shared server you should set all directories to 755 (not just the cgi-bin) and all files to 644. If everything is working you can experiment with other permissions, but start with this setup, even if the documentation from the script tells you otherwise.

  2. Extraneous characters before the opening PHP tags and/or after the ending PHP tag in one or more of the file in that application; this is often the cause of “premature end of script headers” when running PH-CGI. This information might be helpful to you in investigating the “premature end of script headers” error(s).

  3. The structure of the application’s file layout and program flow could be different then how you are set-up on DreamHost (.htaccess files with directives in various directories, different “base” directory/file system structure for the application’s files, etc., is the application even compatible with running PHP-CGI and opposed to mod_php?)

At this point, considering what you have running, I feel it is more likely to be (at least initially) “something to do with your self-extract web application”.

The first thing I would do to try to resolve this is get back to where you had a functioning domain with a working custom PHP.4.4.7; at that point, nothing is broken.

At this point, you have an environment that should work, you just need to make sure any necessary changes (correction of “bad” line endings in files, assorted file and directory permissions, etc) are in place in that “application”.

This might take some doing - I can’t tell because I have not seem the application. First, what is the web application you are trying to install?

Is this an Open Source application you are using, or is is proprietary code? It’s pretty easy to find help with an Open Source application that many use, while it can be a lot harder with proprietary, commercial, or custom software.

Is any of the code encrypted or “protected” with zend, ioncube or some other “crippling” function?

If the application is one that you purchased, once you have a working domain with the proper PHP-CGI installed per the programs requirements, you should contact the author for help in installing it on DreamHost. DreamHost is now a large enough and popular enough webhost that most authors are willing to help you get it installed on DreamHost (and all should help you, if you paid for it).

If it is Open Source, make sure you are trying to install from the *original installation archive/tarballk, etc, using the most current revision of the software that is compatible with your data, and not just moving your code from another host.

The differences between host set-ups are very likely to be different, and if the install process for the application read environment variables from the other host, those “config” values are not likely to work on DH.

Though there is no indication in the error messages you have shared that indicates MySQL is involved at this point, since you mentioned MySQL is used in your application make sure your db is backed up from it’s prior home. That way, worst case, if you can succeed in installing the application on DreamHost, you should be able to import your data from the old host into your new DreamHost db (which you will have to create, in the CP, before installing the application).

First things first: Get your domain back in a usable condition with a working PHP, and work forward from that point to determine what/where you application breaks.