LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-20-2007, 12:37 PM   #1
Zeno McDohl
Member
 
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 322

Rep: Reputation: 30
php script: Premature end of script headers


I have this in file called test.php:
Code:
<html>

<head>
<title>Test PHP Script date!</title>
</head>
<? print(Date("l F d, Y")); ?>

<body>
</body>
</html>
When I try to access it via the web, I get an Internal Server Error. The error_log reports:
Quote:
Premature end of script headers: /public_html/data/test.php
Any idea what is wrong? This is on a linux server.

(If I move the file out of the data directory, it works fine)

Last edited by Zeno McDohl; 06-20-2007 at 12:45 PM.
 
Old 06-20-2007, 09:09 PM   #2
Centinul
Member
 
Registered: Jun 2005
Distribution: Gentoo
Posts: 552

Rep: Reputation: 30
Have you tried this for a test?
Code:
<?php
phpinfo();
?>
Is your PHP configured for short tags as well? ( <? ?> )?

HTH,

Centinul
 
Old 06-21-2007, 10:16 AM   #3
Zeno McDohl
Member
 
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 322

Original Poster
Rep: Reputation: 30
Okay I tried that. I get the same exact error.
 
Old 06-21-2007, 10:26 AM   #4
Centinul
Member
 
Registered: Jun 2005
Distribution: Gentoo
Posts: 552

Rep: Reputation: 30
Have you tried searching google for this error? In my brief research it appears the script dies before it sends anything to the web server and that is where the error arises.

I would imagine this problem must have happened to someone before so I would think you could find a solution on the net.

You mention that it works fine in another directory. Is that directory outside the web server's document root or not? What are the permissions of these two directories?

Thanks

Centinul
 
Old 06-21-2007, 10:37 AM   #5
Zeno McDohl
Member
 
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 322

Original Poster
Rep: Reputation: 30
Indeed, I tried Googling for the error but everything was about perl/cgi etc and not what I wanted.

No, the directory is still under the users account. data is simply a subdirectory. The permissions for data is drwxr-xr-x and for the main directory it's drwxr-x---
 
Old 06-21-2007, 11:20 AM   #6
Centinul
Member
 
Registered: Jun 2005
Distribution: Gentoo
Posts: 552

Rep: Reputation: 30
Hmm...

Could you post your webserver and php configuration so we can take a look at it?

Thanks,

Centinul
 
Old 06-21-2007, 01:26 PM   #7
Zeno McDohl
Member
 
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 322

Original Poster
Rep: Reputation: 30
The entire php.ini? Or something else?
 
Old 06-21-2007, 07:44 PM   #8
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
What are your file permissions on the data directory?
 
Old 06-22-2007, 02:20 AM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
iirc, 'premature end of header' usually means you've forgot that in HTML there have to be 2 (!) newline chars after the hdr, before the body.
 
Old 06-25-2007, 10:26 AM   #10
Zeno McDohl
Member
 
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 322

Original Poster
Rep: Reputation: 30
I figured it out. Turns out the data directory had the wrong user permissions. I had to chown and chgrp the directory and now it works fine.

I wish the error messages actually told me something useful. Maybe mention something about permissions. Sigh.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Premature end of script headers: CGI fatturi Linux - Newbie 4 07-19-2007 04:55 PM
Premature end of script headers bhomass Debian 1 12-02-2005 05:31 PM
python cgi script and premature end of script headers Neruocomp Programming 1 07-28-2005 11:43 AM
Premature end of script headers webhead Red Hat 5 09-22-2004 01:56 AM
Perl/CGI Problem "Premature Premature end of script headers: countdown.pl" newuser455 Linux - Software 2 07-18-2004 11:47 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration