PHP scripts problem!

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers PHP scripts problem!
# 1  
Old 01-07-2008
PHP scripts problem!

I've configured a server with Debian Etch 4.0. I followed these instructions:

Install and Configure Apache2 with PHP5 and SSL Support in Debian Etch -- Debian Admin

But when I try to launch a php script with phpinfo() in my browser, It showed me the download manager window.(i.e. wanna to download the script instead of executing it)
For example:

Another thing is when I want to launch it from a public_html of user (I mean:

It shows me this error:
Server error!

The server encountered an internal error and was unable to complete your request.

Error message:
Premature end of script headers: test.php

If you think this is a server error, please contact the webmaster.
Error 500
Can anyone help me?

Last edited by mjdousti; 01-07-2008 at 02:46 PM..
# 2  
Old 01-07-2008
Your test.php file should have only the following:
<?php phpinfo(); ?>

Some sites will show this with spaces after and before the "<" and ">", but PHP will trip on those spaces. It's happened to me before.
# 3  
Old 01-07-2008
My file in the /var/www was incorrect. But when I changed it as you said, It is behaved as my virtual host. (The virtual host's file content was correct before). It showed this error again for both cases:
Server error!

The server encountered an internal error and was unable to complete your request.

Error message:
Premature end of script headers: test.php

If you think this is a server error, please contact the webmaster.
Error 500
# 4  
Old 01-07-2008
I found that, this error is related to suphp module. When I disabled it with this command:
a2dismod suphp

every things works perfectly. I checked this suPHP - FAQ, there was something helpful:
Why do my scripts not work and why do I get an "Premature end of script headers" in the error_log?
You probably have installed the CLI version of PHP, but you need the CGI version. Copy the file /build/path/sapi/cgi/php to /where/ever/you/have/installed/bin/php to use the CGI version.
But I don't know what am I copying exactly!
# 5  
Old 01-07-2008
Excellent! I'm glad you found a solution. Thanks for the info about it too.
# 6  
Old 01-08-2008
As I said, I don't know, what files and where can I copy my files?
# 7  
Old 01-08-2008
Check the "php" executable being used. You can run "php -v" on the command line. On my Debian system, it displays

cbkihong@cbkihong:~$ php -v
PHP 5.1.4 (cgi) (built: Jun  4 2006 00:37:25)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies

which shows the CGI version is used. On another server of mine it shows the CLI version:

admin@np64gw:~$ php -v
PHP 5.2.1 (cli) (built: Feb  9 2007 23:01:18)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

The CGI version differs from the CLI version in that the CGI version will send certain required HTTP response headers, but the CLI version will not. For instance,

cbkihong@cbkihong:~$ php
<? echo "a" ?>
X-Powered-By: PHP/5.1.4
Content-type: text/html


The version installed on a Web server should be a CGI version one instead of the CLI version. For Debian, the 'php5-cgi' is likely the package you should install.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem in two scripts

I wrote one script it is showing wrong out but i wrote another script it is showing right out. I really don't know the difference. first-script-showing mistake. #!/bin/bash echo "Counting the Databases" countp1=`ps -ef |grep pmon |grep -v grep | wc -l` echo $countp1 #countp=3 if ... (3 Replies)
Discussion started by: learnbash
3 Replies

2. UNIX for Dummies Questions & Answers

Execution problem in running multiple scripts

hi all, I have 3 individual scripts to perform the task . 2nd script should run only after the 1st script and 3rd script must run only after first 2 scripts are executed successfully. i want to have a single script that calls all this 3 scripts .this single script should execute the 2nd script... (1 Reply)
Discussion started by: Rahul619
1 Replies

3. UNIX for Advanced & Expert Users

Running multiple php scripts into one php only, cron mail alert problem...

hi, while separated they produce the usual mail alert and i can see the output... if i write into the php script: <?php system('php -f /var/www/vhosts/'); system('php -f /var/www/vhosts/'); system('php -f... (0 Replies)
Discussion started by: 7stars
0 Replies

4. Shell Programming and Scripting

Problem with ftp scripts and cron

Need some help / advice with the follow script... Basically i have an FTP server that connects to other ftp servers and sends and downloads files every few hours or so. There are 12 different accounts that all have 2 scripts each, one to send and one to receive. Below is an example send script... (1 Reply)
Discussion started by: mokachoka
1 Replies

5. Shell Programming and Scripting

Crontab PHP scripts not ending

when i run the scripts from command line like php ./file.php they run fine and it ends. But i have them running in crontab every 5 minutes and they sometimes dont close. Can i write something to log why or force them to close after a certain amount of time by killing the pid? (2 Replies)
Discussion started by: nitrous
2 Replies

6. Shell Programming and Scripting

Cron and multiple scripts problem.

Hello All, I have 3 scripts namingly 1X 2X and 3X. I have one directory ABC created which contains some 40 sub directories. I have one input file in the below format.The input file resides in ABC directory. Inputfile format; subdirectoryname date subdirectoryname1 date subdirectoryname2... (1 Reply)
Discussion started by: RSC1985
1 Replies

7. HP-UX

scripts problem

Hi, the only experience I have with Unix is on C360 workstations using 10.20 and Omniback II to restore email with HP Openmail. I have four brand new machines that I am installing the OS and software on, however, their are scripts that were written specifically for our tape process that I have... (13 Replies)
Discussion started by: Asheley Ryan
13 Replies

8. Shell Programming and Scripting

How to connect PHP and Shell Scripts

Dear Friends, Plz some one tell me how to connect PHP and Shell Scripts. Mail me on address removed by moderator Thanks Nishant (3 Replies)
Discussion started by: krishna_sicsr
3 Replies

9. Shell Programming and Scripting

Shell scripts problem...

Hi, #!/bin/ksh ############################################################################### # ----------------------------------------------------------------------------- # # ------------------------------------------------------------------------------... (1 Reply)
Discussion started by: parola
1 Replies
Login or Register to Ask a Question