PDA

View Full Version : suPHP. Premature end of s.


Wiesemarc
14th November 2006, 14:04
I have installed php4 and php5 after this http://howtoforge.com/apache2_with_php5_and_php4 howto, and now i have used the http://howtoforge.com/apache2_suphp_php4_php5 howto, an have checked the logs and all files on the server has the right permissions. But i just get "Premature end of script header: info.php", i have been searching for answers on this all day and yesterday, but nothing about this ?

I have tried to change "x-httpd-php" in suphp.conf to /usr/bin/php4-cgi and /usr/lib/cgi-bin/php4-cgi but same error everytime.

Hope some of you guys have seen this error before and know what it is.

falko
15th November 2006, 16:26
What's in Apache's error log? What's the output of apache2 -t or httpd2 -t?

Wiesemarc
15th November 2006, 21:19
apache2 -t gives:
Syntax OK

apache2 -v gives:
Server version: Apache/2.0.54
Server built: Jul 28 2006 09:04:55
Server's Module Magic Number: 20020903:9
Architecture: 32-bit
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D HTTPD_ROOT=""
-D SUEXEC_BIN="/usr/lib/apache2/suexec2"
-D DEFAULT_PIDLOG="/var/run/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="/var/run/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="/etc/apache2/mime.types"
-D SERVER_CONFIG_FILE="/etc/apache2/apache2.conf"

Error.log:
[Tue Nov 14 12:58:09 2006] [error] [client x.x.x.x] Premature end of script headers: index.php

falko
16th November 2006, 17:03
Error.log:
[Tue Nov 14 12:58:09 2006] [error] [client x.x.x.x] Premature end of script headers: index.php
What's in that index.php file?

Wiesemarc
16th November 2006, 18:32
In the file index.php this is:

<?
phpinfo();
?>

falko
17th November 2006, 16:05
What happens if you change it to
<?php
phpinfo();
?>?

Wiesemarc
17th November 2006, 17:07
Then i will get the same error.
Have also tried <? echo "test; ?>, <?php echo "test; ?> <?PHP echo "test; ?> and others, but same error everytime, if i change the dir to 644 i will get the pcfg_openfile error (.htaccess)

Don't really know what to do next.

falko
18th November 2006, 15:51
Directories must always be executable, so you should chmod it back to 755 (or whatever it was before).

Can you post your Apache vhost configuration here? Which PHP is your CGI version, and which an Apache module?

Wiesemarc
18th November 2006, 16:49
Apache Vhost Info:

<VirtualHost *>
DocumentRoot "/var/www/mydata/test"
ServerName domain
ServerAlias domain
ServerAdmin mail
ErrorLog /var/www/logs/admin/test.ooz.dk-error.log
CustomLog /var/www/logs/admin/test.ooz.dk-access.log combined
suPHP_Engine on
suPHP_UserGroup 10000 10000
AddHandler x-httpd-php .php .php3 .php4 .php5
suPHP_AddHandler x-httpd-php
<Directory /var/www/mydata/test>
Options ExecCGI
</Directory>
</VirtualHost>

Php informations.

# php4 -v
PHP 4.4.4-0.dotdeb.1 (cli) (built: Aug 21 2006 16:07:30)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies

# php5 -v
PHP 5.1.6-0.dotdeb.2 (cli) (built: Aug 31 2006 17:18:42)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies

falko
19th November 2006, 18:24
What's in /etc/suphp.conf?
In which directory is index.php located?

Wiesemarc
19th November 2006, 20:27
Index.php location:
/var/www/mydata/test/index.php


SuPHP.conf Content:

[global]
;Path to logfile
logfile=/var/log/suphp.log

;Loglevel
loglevel=info

;User Apache is running as
webserver_user=www-data

;Path all scripts have to be in
docroot=/

;Path to chroot() to before executing script
;chroot=/mychroot

; Security options
allow_file_group_writeable=false
allow_file_others_writeable=false
allow_directory_group_writeable=false
allow_directory_others_writeable=false
;Check wheter script is within DOCUMENT_ROOT
check_vhost_docroot=true

;Send minor error messages to browser
errors_to_browser=false

;PATH environment variable
env_path=/bin:/usr/bin

;Umask to set, specify in octal notation
umask=0077

; Minimum UID
min_uid=100

; Minimum GID
min_gid=100


[handlers]
;Handler for php-scripts
x-httpd-php=php:/usr/lib/cgi-bin/php4

;Handler for CGI-scripts
x-suphp-cgi4=execute:!self

falko
20th November 2006, 14:36
Can you put this:

<Directory /var/www/mydata/test>
Options ExecCGI
</Directory>

right at the beginning of your vhost and change it to

<Directory /var/www/mydata/test>
Options +ExecCGI
</Directory>?

What's the output of /usr/lib/cgi-bin/php4 -v and which php4?

Wiesemarc
20th November 2006, 15:07
#/usr/lib/cgi-bin/php4 -v
PHP 4.4.4-0.dotdeb.1 (cgi-fcgi) (built: Aug 21 2006 16:04:56)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies

# which php4
/usr/bin/php4

falko
21st November 2006, 16:20
Did this <Directory ...> thing help?

raruiz
26th December 2008, 19:17
I had the same problem and solved reading here.
suphp and premature end of script ....
I found my directory permission were 777, and changed it to 755. Works fine now. Thank you.