Page 1 of 1
Only File Not Found (404) when testing
Posted: Fri Jul 25, 2008 2:59 pm
by ayaxian
I'm on a Win XP SP2. I've installed Apache 2.2.9, PHP 5.2.6 (they both are shown in the status area of the Apache Service Monitor window) and MySQL 5.0 but I can't still test a simple php file.
I stopped and restarted Apache after installing PHP.
I entered the '
http://localhost/' in ie7 and got the 'It works' message.
First attempt was trying to test directly from Dreamweaver and I got a 404 error (file not found).
I copied the file to the root directory ('c:\inetpub\wwwroot\myfile.php') and enter the path '
http://localhost/myfile.php' in the address bar again in ie7 and got the same error.
Read an article about configuring Apache to work with PHP and found some lines that should be added to the 'httpd.conf'. Checked the .conf file at the lines were already there.
Now I have no idea what else to do so any help is very welcome
Re: Only File Not Found (404) when testing
Posted: Fri Jul 25, 2008 6:46 pm
by ghurtado
Try to find the apache log (access.log and error.log) under the Apache program folder and read the last few lines to see why apache can't find your file.
Re: Only File Not Found (404) when testing
Posted: Fri Jul 25, 2008 10:20 pm
by ayaxian
Error.log ends with:
[Fri Jul 25 14:29:45 2008] [notice] Apache/2.2.9 (Win32) PHP/5.2.6 configured -- resuming normal operations
[Fri Jul 25 14:29:45 2008] [notice] Server built: Jun 13 2008 04:04:59
[Fri Jul 25 14:29:45 2008] [notice] Parent: Created child process 460
httpd.exe: Could not reliably determine the server's fully qualified domain name, using 192.168.1.33 for ServerName
httpd.exe: Could not reliably determine the server's fully qualified domain name, using 192.168.1.33 for ServerName
[Fri Jul 25 14:29:45 2008] [notice] Child 460: Child process is running
[Fri Jul 25 14:29:45 2008] [notice] Child 460: Acquired the start mutex.
[Fri Jul 25 14:29:45 2008] [notice] Child 460: Starting 64 worker threads.
[Fri Jul 25 14:29:45 2008] [notice] Child 460: Starting thread to listen on port 80.
[Fri Jul 25 14:31:06 2008] [error] [client 127.0.0.1] File does not exist: C:/Archivos de programa/Apache Software Foundation/Apache2.2/htdocs/_test
[Fri Jul 25 14:32:11 2008] [error] [client 127.0.0.1] script 'C:/Archivos de programa/Apache Software Foundation/Apache2.2/htdocs/untitled.php' not found or unable to stat
Access.log ends with:
127.0.0.1 - - [25/Jul/2008:14:31:06 -0500] "GET /_test/untitled.php HTTP/1.1" 404 216
127.0.0.1 - - [25/Jul/2008:14:32:11 -0500] "GET /untitled.php HTTP/1.1" 404 210 (this one is repeated several times)
127.0.0.1 - - [25/Jul/2008:14:32:31 -0500] "GET / HTTP/1.1" 304 -
127.0.0.1 - - [25/Jul/2008:14:32:52 -0500] "GET /untitled.php HTTP/1.1" 404 210
Re: Only File Not Found (404) when testing
Posted: Sat Jul 26, 2008 7:15 pm
by califdon
It looks like you have conflicting directory structures. In the Apache error log it is looking for
Code: Select all
C:/Archivos de programa/Apache Software Foundation/Apache2.2/htdocs/_test
but you said that you configured httpd.conf to specify Document Root as
if I understood you correctly.
Basically, for security reasons, Apache can not serve any files that are not in the specified Document Root or its subdirectory structure. Be sure that whatever is in httpd.conf for Document Root is the same as where you're putting your files.
Re: Only File Not Found (404) when testing
Posted: Sat Jul 26, 2008 8:06 pm
by ayaxian
It looked for 'C:/Archivos de programa/Apache Software Foundation/Apache2.2/htdocs/_test' in one of the attempts cause I tried creating a sub folder.
I've changed Document Root from "C:/Archivos de programa/Apache Software Foundation/Apache2.2/htdocs" to "c:/inetpub" and now I got an 403 error.
I think that's a progress, at least it can find the file...
Re: Only File Not Found (404) when testing
Posted: Sat Jul 26, 2008 9:35 pm
by ayaxian
Changed '<Directory "C:/Archivos de programa/Apache Software Foundation/Apache2.2/htdocs">' to '<Directory "c:/inetpub/wwwroot">' in the httpd.conf file and tested again. It worked!
The code was a simple test:
Code: Select all
<html>
<head>
<title> PHP Test Script </title>
</head>
<body>
<?php
phpinfo( );
?>
</body>
</html>
I tried this second test:
Code: Select all
<HEAD>
<TITLE>Example.com greeting</TITLE>
</HEAD>
<BODY>
<P>Hello,
<?php
// We have now escaped into PHP mode.
// Instead of static variables, the next three lines
// could easily be database calls or even cookies;
// or they could have been passed from a form.
$firstname = ‘Joyce’;
$lastname = ‘Park’;
$title = ‘Ms.’;
echo “$title $lastname”;
// OK, we are going back to HTML now.
?>
. We know who you are! Your first name is <?php echo
$firstname; ?>.</P>
<P>You are visiting our site at <?php echo date(‘Y-m-d H: -- i:s’);
?></P>
<P>Here is a link to your account management page: <A
HREF=”http://www.example.com/accounts/<?php echo
“$firstname$lastname”; ?>/”><?php echo $firstname; ?>’s account
management page</A></P>
</BODY>
</HTML>
and now I'm getting error 500 and this message in the error.log file:
[Sat Jul 26 21:19:44 2008] [error] [client 127.0.0.1] PHP Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in C:\\Inetpub\\wwwroot\\untitled.php on line 14
This code:
Code: Select all
<HTML>
<HEAD>
<TITLE>My first PHP program</TITLE>
</HEAD>
<BODY>
<?php
print(“Hello, cruel world<BR><BR>\n”);
phpinfo();
?>
</BODY>
</HTML>
also gets me a 500 error saying: [Sat Jul 26 21:33:13 2008] [error] [client 127.0.0.1] PHP Parse error: syntax error, unexpected ',' in C:\\Inetpub\\wwwroot\\untitled.php on line 7
Again, any help is very welcome
PS: I still cannot test directly from Dreamweaver, had to copy the files to 'c:\inetpub\wwwroot'
Re: Only File Not Found (404) when testing
Posted: Sat Jul 26, 2008 10:21 pm
by califdon
It appears that Dreamweaver or whatever you are using to create these files is using "smart quotes", that is, the opening quotation mark is a different character than the closing quotation mark. I don't think PHP likes that. Use straight single quotes (apostrophes) and double quotes. And that's right, Dreamweaver is not a web server, so it can't execute PHP. You have to be using a web server like Apache to execute PHP.
Re: Only File Not Found (404) when testing
Posted: Sat Jul 26, 2008 10:40 pm
by ayaxian
The openning and closing quotation marks are ok. I checked.
Dreamweaver is designed to copy the php files to the appropriate local server location to test them, that's what I meant when I said I was trying to test them directly from there. I found it didn't copy any file. I had to do it by myself.
And yes, I'm using Apache as I said at the beginning of this post.
Re: Only File Not Found (404) when testing
Posted: Sat Jul 26, 2008 10:51 pm
by califdon
You checked the quotes? How did they get into your posting, then?
Code: Select all
$firstname = ‘Joyce’;
$lastname = ‘Park’;
$title = ‘Ms.’;
echo “$title $lastname”;
Those are certainly not straight quotation marks there.
Re: Only File Not Found (404) when testing
Posted: Sun Jul 27, 2008 5:24 pm
by ayaxian
It works!
The problem was I was copying the code directly from book samples and the quotation marks were indeed the problem.
Everything seems to be working fine now
Thanks a lot