You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Miguel - Globalview <mi...@gvi.com.br> on 2005/06/09 14:30:59 UTC

[users@httpd] Can't run any php or any other exec file. Error 500. Premature end of script headers

Hello all!

I am facing a weird thing with running any binary or script of any 
language, PHP or Shell script in my Apache.
When I run the .PHP script, error_log shows me:
"... Premature end of script headers: 
/var/www/owner/any_domain.com/cgi-bin/php431"


Browser shows me:
"Internal Server Error
The server encountered an internal error or misconfiguration and was 
unable to complete your request.

Please contact the server administrator, [no address given] 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. "


In addition, I created a test shell script testing, that usually works fine:
"#!/bin/sh

echo "<h1> Just for testing purposes...";
"
I've got the same entry as above in error_log.


My conf file for the virtual server looks like this:
"<VirtualHost $IP>
ServerName www.any_domain.com
DocumentRoot /var/www/owner/any_domain.com/public_html
User owner
Group owner
DirectoryIndex index.php index.php3 index.html index.htm index.shtml 
default.htm
CustomLog /var/www/owner/any_domain.com/logs/access_log combined
RLimitCPU 60 80
RLimitNPROC 20 30
SetEnv PHPRC
ScriptAlias /cgi-bin/ "/var/www/owner/any_domain.com/cgi-bin/"
ScriptAlias /cgi-bin/php "/var/www/owner/any_domain.com/cgi-bin/php"
<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
</Files>
Alias /errordocs/ "/sites/web1/listel/frioar.com/errordocs/"
ErrorDocument 400 /errordocs/400.html
ErrorDocument 401 /errordocs/401.html
ErrorDocument 403 /errordocs/403.html
ErrorDocument 404 /errordocs/404.html
ErrorDocument 500 /errordocs/500.html
Alias /icons "/usr/local/apache/icons"
<Directory "/usr/local/apache/icons">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>"


But the most weird thing is that it is happening only for this user, for 
any domain created from now on for this user, and it always worked the 
same way we have always done.


All the permissions and owners are accordingly set. I even tried some 
different combinations, but nothing seems to work for this user. I used 
the same files in other virtual host and it worked fine. I created a new 
virtual host, with different name, and it worked fine. I created a 
different virtual host for this user and it did not work again.


I've get Apache 1.3.1 running on a Linux Fedora Core 2, kernel 2.6.


I really don't understand what is going on. I just can't figure out how 
to fix it --and I don't know what I've broken :D.

If anyone could help me, I am burning my brains in here. I might be 
missing something.

Thank you all,

-- 
Andre Miguel
- Engaged in OSS
.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Can't run any php or any other exec file. Error 500. Premature end of script headers

Posted by Jean-Christophe Montigny <jc...@assoces.com>.
While my answer to the other thread about php scripts not running might 
not work for that case, it is obvious it applies in yours..

You need to send the string Content-type: text/html
before sending any data, or it fails with error 500.

Google for the exact string.

Miguel - Globalview wrote:
> Hello all!
> 
> I am facing a weird thing with running any binary or script of any 
> language, PHP or Shell script in my Apache.
> When I run the .PHP script, error_log shows me:
> "... Premature end of script headers: 
> /var/www/owner/any_domain.com/cgi-bin/php431"
> 
> 
> Browser shows me:
> "Internal Server Error
> The server encountered an internal error or misconfiguration and was 
> unable to complete your request.
> 
> Please contact the server administrator, [no address given] 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. "
> 
> 
> In addition, I created a test shell script testing, that usually works 
> fine:
> "#!/bin/sh
> 
> echo "<h1> Just for testing purposes...";
> "
> I've got the same entry as above in error_log.
> 
> 
> My conf file for the virtual server looks like this:
> "<VirtualHost $IP>
> ServerName www.any_domain.com
> DocumentRoot /var/www/owner/any_domain.com/public_html
> User owner
> Group owner
> DirectoryIndex index.php index.php3 index.html index.htm index.shtml 
> default.htm
> CustomLog /var/www/owner/any_domain.com/logs/access_log combined
> RLimitCPU 60 80
> RLimitNPROC 20 30
> SetEnv PHPRC
> ScriptAlias /cgi-bin/ "/var/www/owner/any_domain.com/cgi-bin/"
> ScriptAlias /cgi-bin/php "/var/www/owner/any_domain.com/cgi-bin/php"
> <Files ~ "^\.ht">
>    Order allow,deny
>    Deny from all
> </Files>
> Alias /errordocs/ "/sites/web1/listel/frioar.com/errordocs/"
> ErrorDocument 400 /errordocs/400.html
> ErrorDocument 401 /errordocs/401.html
> ErrorDocument 403 /errordocs/403.html
> ErrorDocument 404 /errordocs/404.html
> ErrorDocument 500 /errordocs/500.html
> Alias /icons "/usr/local/apache/icons"
> <Directory "/usr/local/apache/icons">
>    Options Indexes MultiViews
>    AllowOverride None
>    Order allow,deny
>    Allow from all
> </Directory>
> </VirtualHost>"
> 
> 
> But the most weird thing is that it is happening only for this user, for 
> any domain created from now on for this user, and it always worked the 
> same way we have always done.
> 
> 
> All the permissions and owners are accordingly set. I even tried some 
> different combinations, but nothing seems to work for this user. I used 
> the same files in other virtual host and it worked fine. I created a new 
> virtual host, with different name, and it worked fine. I created a 
> different virtual host for this user and it did not work again.
> 
> 
> I've get Apache 1.3.1 running on a Linux Fedora Core 2, kernel 2.6.
> 
> 
> I really don't understand what is going on. I just can't figure out how 
> to fix it --and I don't know what I've broken :D.
> 
> If anyone could help me, I am burning my brains in here. I might be 
> missing something.
> 
> Thank you all,
> 


-- 
Jean-Christophe Montigny
Responsable Commission Web, Association Planètes
Responsable serveurs assoces.com, Association Planètes
Etudiant de deuxième année à Grenoble Ecole de Management
Majeure Conseil en Organisation des Systèmes d'Information

Re: [users@httpd] Can't run any php or any other exec file. Error 500. Premature end of script headers

Posted by Davide Bianchi <da...@onlyforfun.net>.
Miguel - Globalview wrote:
> "... Premature end of script headers:
> In addition, I created a test shell script testing, that usually works
> fine:
> "#!/bin/sh
> echo "<h1> Just for testing purposes...";

This isn't a correct CGI. A Cgi should start by sending back some
'headers', minimal requirements are:

Content-Type: text/html


(note: two newlines)

If your script doesn't return such header you get the aforementioned
error.

Davide

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Can't run any php or any other exec file. Error 500. Premature end of script headers

Posted by Miguel - Globalview <mi...@gvi.com.br>.
In addition, if this helps, I get this info in suexec.log:
"emerg: failed to setuid (10082: php431)"


Miguel - Globalview wrote:
> Hello all!
>
> I am facing a weird thing with running any binary or script of any 
> language, PHP or Shell script in my Apache.
> When I run the .PHP script, error_log shows me:
> "... Premature end of script headers: 
> /var/www/owner/any_domain.com/cgi-bin/php431"
>
>
> Browser shows me:
> "Internal Server Error
> The server encountered an internal error or misconfiguration and was 
> unable to complete your request.
>
> Please contact the server administrator, [no address given] 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. "
>
>
> In addition, I created a test shell script testing, that usually works 
> fine:
> "#!/bin/sh
>
> echo "<h1> Just for testing purposes...";
> "
> I've got the same entry as above in error_log.
>
>
> My conf file for the virtual server looks like this:
> "<VirtualHost $IP>
> ServerName www.any_domain.com
> DocumentRoot /var/www/owner/any_domain.com/public_html
> User owner
> Group owner
> DirectoryIndex index.php index.php3 index.html index.htm index.shtml 
> default.htm
> CustomLog /var/www/owner/any_domain.com/logs/access_log combined
> RLimitCPU 60 80
> RLimitNPROC 20 30
> SetEnv PHPRC
> ScriptAlias /cgi-bin/ "/var/www/owner/any_domain.com/cgi-bin/"
> ScriptAlias /cgi-bin/php "/var/www/owner/any_domain.com/cgi-bin/php"
> <Files ~ "^\.ht">
>    Order allow,deny
>    Deny from all
> </Files>
> Alias /errordocs/ "/sites/web1/listel/frioar.com/errordocs/"
> ErrorDocument 400 /errordocs/400.html
> ErrorDocument 401 /errordocs/401.html
> ErrorDocument 403 /errordocs/403.html
> ErrorDocument 404 /errordocs/404.html
> ErrorDocument 500 /errordocs/500.html
> Alias /icons "/usr/local/apache/icons"
> <Directory "/usr/local/apache/icons">
>    Options Indexes MultiViews
>    AllowOverride None
>    Order allow,deny
>    Allow from all
> </Directory>
> </VirtualHost>"
>
>
> But the most weird thing is that it is happening only for this user, 
> for any domain created from now on for this user, and it always worked 
> the same way we have always done.
>
>
> All the permissions and owners are accordingly set. I even tried some 
> different combinations, but nothing seems to work for this user. I 
> used the same files in other virtual host and it worked fine. I 
> created a new virtual host, with different name, and it worked fine. I 
> created a different virtual host for this user and it did not work again.
>
>
> I've get Apache 1.3.1 running on a Linux Fedora Core 2, kernel 2.6.
>
>
> I really don't understand what is going on. I just can't figure out 
> how to fix it --and I don't know what I've broken :D.
>
> If anyone could help me, I am burning my brains in here. I might be 
> missing something.
>
> Thank you all,


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org