Forum Moderators: coopster

Message Too Old, No Replies

Newbie: 500 Internal Server Error

         

LaurenceMartin

7:12 pm on Feb 20, 2003 (gmt 0)

10+ Year Member



Greetings all,
I am a VERY new beginner at PHP, and our hosting plan that was upgraded now supports PHP and MySQL.
I am trying to get past the basic "Hello World" webpage creation using this snippet:

<html>
<head>
<title>Today's Date</title>
</head>
<body>
<p>Today's Date (according to this Web server) is
<?php
echo( date("l, F dS Y.") );
?>
</p>
</body>
</html>

I have saved with a .php extension, uploaded in ASCII and chmod to 755 but get a 500 error. This is on Apache/1.3.27.
According to my web host:

"$HOSTING_COMPANY currently has PHP 4.06 installed on all its Linux/UNIX servers. This version also runs PHP3. PHP is only available with the $BigNumber Plan or higher. The file needs to have the following:

Files need to have a .php or .php3 extension
Files need to be uploaded in ASCII
Files need to have 755 permissions, and the path to PHP at the top of the file. The path to PHP is #!/usr/local/bin/php
Please note that on $HOSTING_COMPANY dedicated servers, PHP is installed as a module and is compiled as a cgi instead of a module."

I have tried putting the path above the <HTML> tag, but get an invalid markup warning.
Do I have to make a separate script, save it in cgi-bin, and somehow call it from the HTML page?
Is the fact that is "installed as a module and compiled as cgi" make any difference, athough now that I think of it we are not on a dedicated server, but virtual.
BTW, their tech support is so slow, that is why the post here.

I've been to php.org and dozens of tutorial sites, but there is no mention of having to include the path to PHP in the places I've browsed.
Any tips on where to look, links, etc.?

Thanks in advance,
Laurence Martin

RussellC

8:07 pm on Feb 20, 2003 (gmt 0)

10+ Year Member



My only guess is to use <? instead of <?php as your opening tag. Also make a phpinfo.php file with

<?
phpinfo();
?>

in it and see what it says.

LaurenceMartin

9:45 pm on Feb 20, 2003 (gmt 0)

10+ Year Member



Thanks Russell,
I have tried your suggestion, but get the same 500 error.
Arghh!

Thanks again.

sun818

9:53 pm on Feb 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi Laurence, does your web host offer access to the raw logs? Since a 500 error can be anything, you will detailed errors to better isolate your issue.

Birdman

10:37 pm on Feb 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This may be way off, but my pc will not allow me to save as .php. It always adds .txt to the end(ie index.php.txt).

Just a thought.

digitalghost

10:39 pm on Feb 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>>This may be way off, but my pc will not allow me to save as .php. It always adds .txt to the end(ie index.php.txt).

If you save the file by adding quotes the .txt extension won't be appended.

"myfile.php"

Click save.

LaurenceMartin

11:04 pm on Feb 20, 2003 (gmt 0)

10+ Year Member



Thanks all,
Here's the logs for the last few attempts (I have modified the actual user paths for security reasons):

[Thu Feb 20 14:10:16 2003] [error] [client 67.x.x.x] Premature end of script headers: /home/xxx/xxx/untitled.php
failed to open log file
fopen: Permission denied
[Thu Feb 20 14:33:38 2003] [error] [client 67.x.x.x] Premature end of script headers: /home/xxx/xxx/untitled.php
[Thu Feb 20 16:43:57 2003] [error] [client 67.x.x.x] Premature end of script headers: /home/xxx/xxx/phpinfo.php
failed to open log file
fopen: Permission denied
[Thu Feb 20 16:46:26 2003] [error] [client 67.x.x.x] Premature end of script headers: /home/xxx/xxx/phpinfo.php
failed to open log file
fopen: Permission denied
[Thu Feb 20 17:02:50 2003] [error] [client 67.x.x.x] Premature end of script headers: /home/xxx/xxx/untitled.php

Thanks

LaurenceMartin

2:31 am on Feb 21, 2003 (gmt 0)

10+ Year Member



First, thanks to all who responded.
I got an email back from the scripting person at our web hosting provider.
They went ahead and modified the two web pages in question.
The solution was to include a path statement as the first line in my HTML files.

I swear I tried this! Honest!

But it works now.
<snip>

Here is the code in case anyone is interested:
#!/usr/local/bin/php
<html>
<head>
<title>Today's Date</title>
</head>
<body>
<p>Today's Date (according to this Web server) is
<?php
echo( date("l, F dS Y.") );
?>
</p>
</body>
</html>

It may be that this "problem" is unique to my web host.
More likely it is my ignorance.
I am moving on to learn more! Many thanks.

-Laurence Martin

[edited by: jatar_k at 3:11 am (utc) on Feb. 21, 2003]

sun818

4:41 am on Feb 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I've had this error occur too when you upload text files to a Linux box in binary mode. When you use vi to view the file, you should see a ^M for binary transfers, but Linux (Red Hat?) won't show it for some reason. It makes for a real pain to diagnose. FTP programs like CuteFTP have the correct file types already mapped out for ASCII, but LeechFTP and others have a limited number of file types that is on by default.

LaurenceMartin

5:01 pm on Feb 22, 2003 (gmt 0)

10+ Year Member



hehe. I have to laugh because that was my first "experience" with uploading (or was it imploding?) scripts. I didn't know what the heck an ASCII transfer was, let alone of it's existence.
Good tip on vi and Linux. Must remember that.

andreasfriedrich

5:39 pm on Feb 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>>PHP is installed as a module and is compiled as
>>a cgi instead of a module

Could anybody explain that? How can PHP [php.net] be installed as a module when it is compiled as a CGI binary? If it is installed as a module the webserver will need load a dynamic library containing the PHP [php.net] engine. If it is installed as a binary then it will be called via the CGI and will need a correct shebang to tell the kernel which interpreter to use.

Andreas