Please help... http://localhost/test.php

Hour after Hour, same message... The requested URL /test.php was not found on this server.
Using: http://localhost/test.php (file is actually in my Sites folder)

Even if I drag and drop it on Safari or Firefox, I get this message.
Web Sharing is on, Apache server is running, MySQL is running, same file serves up fine from the web. It's the <?php phpinfo() ?> test file everyone uses to check MySQL/PHP server.

Also troubled with protocol for "root folder" address. Is it localhost or localhost/Users/~long_name/etc.... nothing is working.

Any ideas or suggestions???
Thanks

Mac Pro 2.66 Quad Xeon - 4GB - Radeon 1900XT - Apple 23" Cinema Display, Mac OS X (10.5.6), Pioneer DVR-115D, Hollywood DV Bridge (actually works with 10.5.6 and FCP 6.0.5)

Posted on Jun 25, 2009 12:57 AM

Reply
12 replies

Jun 25, 2009 5:38 AM in response to Peter Mars

To confirm, is this computer running Mac OS X Server, or is this Mac OS X client? (This is the server discussion forum, though the reference to "Web Sharing" implies the client variant.)

Hour after Hour, same message... The requested URL /test.php was not found on this server.
Using: http://localhost/test.php (file is actually in my Sites folder)


Where is the request coming from? Check the Apache access logs here. Are you requesting the file? Or is the request from remote?

Even if I drag and drop it on Safari or Firefox, I get this message.


Drag and drop what to where?

If you're loading files into the web directories, ensure the files and the directories are readable by Apache, but are not writable by and not owned by Apache.

Web Sharing is on, Apache server is running, MySQL is running, same file serves up fine from the web. It's the <?php phpinfo() ?> test file everyone uses to check MySQL/PHP server.


And more than a few attacks look for this file, too.

Also troubled with protocol for "root folder" address. Is it localhost or localhost/Users/~long_name/etc.... nothing is working.


http://localhost/~shortname

Various of the client environments and configurations block access outside the web directories, too. (Usually deliberately and by default.)

Any ideas or suggestions???


We are (well, OK, maybe I am) going to need a few more words around what you're trying to do, and what you're seeing here. Some more details here will help.

Jun 25, 2009 8:58 AM in response to Peter Mars

Hour after Hour, same message... The requested URL /test.php was not found on this server.

Using: http://localhost/test.php (file is actually in my Sites folder)


By default, if you haven't reconfigured apache, then http://localhost/test.php will attempt to serve the document /Library/WebServer/Documents/test.php

Therefore putting the file in your local directory is the problem.

You should move the document to the above directory, or change the URL you're accessing. To access a file in your personal Sites directory you need to use the form:

http://localhost/~username/test.php

The addition of the ~username tells Apache to look in the specified username's Sites directory, not the standard /Library/WebServer/Documents/

Jun 25, 2009 10:37 AM in response to Camelot

You are correct, I am running OS X client. The php test file is in my "Sites" folder. I have tried all combinations of addresses to get it to display in Safari or Firefox. Dragging it to an open browser window does not work either.

UPDATE: I just tried it again and it is working. I checked Sys Prefs and MySQL server is "Stopped"
I just started the computer this morning (a few minutes ago) and haven't started MySQL server yet.
I will start it now and re-check "test.php"

RESULTS: OK... it is still working... this is too weird.

My other question was, "what is my Root Folder address/url" but I guess it depends on whether I'm talking about my "Sites" folder, which is equivalent to http://localhost/~username/ or the actual server root itself... Macintosh HD:Library:WebServer:Documents - which is equivalent to
http://localhost/

Hopefully this is all correct... let me know if not. This is a tough journey for a photographer.... My brain hurts!!!

Jun 25, 2009 12:39 PM in response to Peter Mars

The below example is not working when typed into a browser...


Of course that won't work. That would be a security nightmare if users could type in any path to any file on your machine.

Apache is specifically configured to serve files from specific directories only. By default that's /Library/WebServer/Documents and individual users' ~/Sites directories.

There are two ways of getting Apache to serve content outside of these paths.

One is to create a symlink to the other content (and tell Apache to follow symlinks, which it doesn't do by default).

The other is to create an alias in the configuration. An alias tells Apache to serve content from a different directory when specific URIs are seen.

For example, if you want to serve any http://yoursite.com/media/ URIs from a second volume you could add an alias for /media/ that points to the other volume, like:

Alias /media /Volumes/OtherDisk/folder


Now Apache will take any URI that begins with /media and serve that request from /Volumes/OtherDisk/folder rather than from the normal document root (e.g. /Library/WebServer/Documents)

You can use Server Admin to add such aliases, or edit the site's configuration file directly.

Jun 25, 2009 12:47 PM in response to Camelot

And for the direct question (Camelot is entirely correct about access control here; if this server is internet-facing, you will get attacked and you will find php is a very popular attack target), the %20 character is space character in URL encoding.

Create a space-containing file in your default ~ directory (or somewhere else that the web server can touch), and you should be able to access it with file%20name.html or whatever you've named it.

Jun 25, 2009 1:03 PM in response to MrHoffman

I am trying to setup Dreamweaver CS3 Site - Local Info -- Local Root Folder and Images folder is easy, I can browse to them. Below that It asks for http address. (localhost... I think) it must be entered by hand.

This whole mess is because Dreamweaver is so idiotic... Local, Remote, Testing server, etc, etc, etc....
None of the tutorials I have found, read, watched, seem to adequately address how this works.

Sorry if this off topic for this forum... I am desperate and wasting sooo much time trying to use PHP with Dreamweaver. Previously I just skipped all this BS and uploaded HTML pages as they were made. No setup at all.

Thanks

Jun 26, 2009 12:39 AM in response to Peter Mars

I am still having major problems connecting to MySQL server in dreamweaver and I ran across this "fix", but now I have no root access. "access denied to root@localhost"... so I still cannot connect, but now I may have a bigger problem.

Could someone look at this terminal command I stupidly entered and see if there's anyway back???
I swear I will never do this again!!!! I am just so frustrated with all the problems I'm having with DW CS3... it cannot find my databases.


Here's the fix I followed:
..... your answer was most helpful. Figuring out how to make the symbolic link was my next challenge, but I got it and it works! In Terminal I found there was a /tmp/mysql.sock but nothing at /var/mysql/ Not even a directory for mysql. So I had to create one and then make the -s link. I also had to use super user permissions to do it.

On a Mac 10.4.10, here's what you do--In Terminal
cd /var/
sudo mkdir mysql
cd (to get back to root)
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

At any time you can run the ls command to see all the files and directories within the current directory, so you can keep track of where you are. Always hit cd (enter) to go back to home (root).

Now when I go back to Deamweaver, I can set a connection to my databases and see them in the list!

THIS SOUNDED GOOD AT THE TIME... but as I mentioned, I now get the message "access denied to root@localhost" ----HELP!!!

Jun 26, 2009 8:43 AM in response to Peter Mars

THIS SOUNDED GOOD AT THE TIME... but as I mentioned, I now get the message "access denied to root@localhost" ----HELP!!!


You either haven't configured your MySQL database correctly or, at the very least, you're not using a valid username/password that it recognizes.

It sounds as though you've now got your web application talking to MySQL. But your web app (PHP in this case) is trying to connect to MySQL using the 'root' username. MySQL doesn't permit this by default.

You either need to grant privileges to 'root' to query/update the table or, more correctly, configure your web app to use a more restricted account that has the permissions you need (generally running queries under a root account is discouraged).

For example, you might configure a 'phpuser' account with a password, then change your webapp to connect to MySQL using that password rather than root.

This is all well documented in MySQL's installation guides since granting privileges is a basic prerequisite of running databases.

Jun 26, 2009 9:34 AM in response to Camelot

I am using Sequel Pro and It connects to the server using "localhost" only, no other characters, and user of "root" with no password. Problem is Dreamweaver connection... it will not connect, no matter what I try. I have tried my personal username and password, the data base name and password, root and all passwords, etc... nothing works! I thought the alias solution above might be the answer. Not sure if this fixed or damaged something.

I certainly do not know how to set permissions for any users, root or otherwise!

Thanks

Jun 27, 2009 6:39 PM in response to Peter Mars

With all due respect, you are in over your head.

I mean that nicely, but you're asking for help with step (say) 7 & 8, but you're not understanding steps 1,2 & 3. There's probably nothing wrong with Dreamweaver,
your obstacles lie much earlier on in terms of setup/configuration.

The symlink ("alias" in your words but they're not quite the same) is one possible avenue for addressing differences in a stock MySQL setup vs. what Apple does & why & for good reasons.
Did you search Apple support ? See http://support.apple.com/kb/TS1999
But that has nothing whatsoever to do with your MySQL users, passwords & access rights.

You might wish to hire someone that can help you get this setup correctly and configured securely.
By default, after/apart from certain configuration setup/options, you should not ever connect as root to your SQL database (nor ever use that connection method for PHP, barring something seriously locked down and knowing full well what you're doing and why).

The tasks that you're facing are not difficult in and of themselves, but do require a modicum of understanding local vs network connections, restricting either per the service in question,
and basic database functionality.
There's plenty of documentation at the MySQL site, you'll want to look for "Securing the Initial MySQL Accounts" and be sure to verify that this is enacted for your setup.
Then you'll want to understand that MySQL has its own set of users, passwords & access-rights,
distinct from (by design !) your server/OS X accounts.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Please help... http://localhost/test.php

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.