Would someone else try this and let me know if you see the same problem? Create an index.html file in your Sites folder, then enable web sharing and try to access it from a browser using:
I am also having trouble with web sharing in Leopard. I've turned it on under system preferences and can't even access the server. It appears to be running but regardless of whether I type in the IP address, use 127.0.0.1 or use localhost it comes up with the following message.
+Safari can’t connect to the server.+
+Safari can’t open the page “http://localhost/~YourUserName/” because it could not connect to the server “localhost”.+
I tried what you suggested and cannot view the file either.
Does anyone have any idea what the issue is or how to fix it.
Humm... I kind of talked about it just now on other thread :\
take a look http://discussions.apple.com/thread.jspa?messageID=5915290#5915290
or go directly here http://foundationphp.com/tutorials/php_leopard.php (bottom of the page) and see if it helps you... didn't work for me though...
Leopard uses Apache 2. Tiger used Apache 1.3.
Your config works on tiger because the appropriate user.conf files are in the Apache 1.3 path. They are not moved during an upgrade.
Under this path: /etc/apache2/users
I have a file for each user:
Where user1.conf contains:
Options Indexes MultiViews
Allow from all
I hope that helps.
I also updated my php using the latest entropy package... as I had the Apache 1.3 version installed before. See http://www.entropy.ch/software/macosx/php/
redundant threads.... BAH
You need to have a file named <your_username>.conf in /private/etc/Apache2/users/ for Apache to work properly. Probably you don't have it there or you wouldn't be here :P...
The file might exist in /private/etc/Apache2/users/<yourusername>.conf and if it does, just copy it to the first folder.
If it doesn't exist, you may create it with the following contents:
Options Indexes MultiViews
Allow from all
Don't forget to change "<yourusername>"...
Now I belive that you just need to restart Apache on the Sharing Pref. Pane and you're good to go...
I've tried all of the suggestions that have been posted thus far and still no luck. I've restarted the web sharing as instructed after making the changes and I still get the response:
"Safari can’t connect to the server.
Safari can’t open the page “http://localhost/” because it could not connect to the server “localhost”."
Maybe it's something simple, maybe it's not, but it sure has me stumped.
Has anyone else who has had this problem had success with the posted solutions?
You suggest copying a file "to the first folder", but the two paths you give are identical. Huh?
It looks to me as if /private/etc/apache2/users and /etc/Apache2/users point to the same directory; when I cd to them and ls, I see the same three files including the "AllenW.conf" file I created as instructed here. I am still getting the message in Safari, 'Safari can’t open the page “http://localhost/~AllenW/” because it could not connect to the server “localhost”.'
I've also been to http://foundationphp.com/tutorials/php_leopard.php and have followed those instructions, to no avail.
I took the suggestion to download and install XAMPP. And it worked. The only "problem" was that it expects to find websites in a different location. Rather than "Sites" the websites are expected to be in /Applications/xampp/htdocs/. Once I moved my site folder there, everything works. There is some helpful documentation at http://www.apachefriends.org/en/xampp-macosx.html#873.
This one had me losing some hair for a while, too, but I got it running again, after of course doing everything recommended here -- the problem seemed to be that apache was looking for its log directory, and there wasn't one. (I figured this out while trying to read the ErrorLog, which should have been the first thing I did, but live and learn.)
So, in the finder, Go > Go To Folder, and type /private/var/log.
There should be a folder called apache2 in that directory. If there's not, that's a problem (although I wouldn't dare assume it's the only one).
To make sure, check out the system log by double-clicking on the file in the directory called system.log. When I did that with the web server (supposedly) running, I saw this:
Jan 4 20:42:32 Hatter org.apache.httpd: (2)No such file or directory: httpd: could not open error log file /private/var/log/apache2/error_log.
Jan 4 20:42:32 Hatter org.apache.httpd: Unable to open logs
Jan 4 20:42:32 Hatter com.apple.launchd (org.apache.httpd): Exited with exit code: 1
Jan 4 20:42:32 Hatter com.apple.launchd (org.apache.httpd): Throttling respawn: Will start in 10 seconds
Jan 4 20:42:42 Hatter org.apache.httpd: (2)No such file or directory: httpd: could not open error log file /private/var/log/apache2/error_log.
Jan 4 20:42:42 Hatter org.apache.httpd: Unable to open logs
Jan 4 20:42:42 Hatter com.apple.launchd (org.apache.httpd): Exited with exit code: 1
Jan 4 20:42:42 Hatter com.apple.launchd (org.apache.httpd): Throttling respawn: Will start in 10 seconds
over and over, every ten seconds, for as long as the web server was active.
To fix that, just create that directory. Turn off the webserver, then from terminal:
and restart the webserver.
Same problem for me - I also tried all above suggestions (re. conf files and paths). As jewhanso says, I (also) get the message: Safari can’t open the page "http://localhost/..." because it could not connect to the server "localhost".
Leopard seems to lack a way of designating the local loopback address. Maybe this is IP v.6-related?
Does anybody know how to properly specify the local loopback address in IP V.6? Maybe that will work. I tried using both http://localhost/~mydir/index.php and http://127.0.0.1/~mydir/index.php. They work fine on my Tiger-based MacBook but not under Leopard.
Interestingly - in Leopard, the Apple > System Preferences > Sharing checkbox reads "Web Sharing" (using an external network address). In Tiger this is "PERSONAL Web Sharing" (using the local loopback address). The editing text-boxes disallow the use of 'localhost' or '127.0.0.1'.
There's an interesting error message in the apache2/error_log that reads "[Sat Feb 16 20:05:00 2008] [error] [client ::1] File does not exist: /Users/<mydir>/Sites/sites. Note the '... [client::1] ...' syntax. I don't know for sure but I am guessing this is an IP v.6 syntax - replacing the older syntax for the loopback address. I.e. localhost = IP address 127.0.0.1".
Looks like an Apple "faux pas" to me. :-/
I FOUND the source of MY problem (localhost access not working under leopard - 10.5.2). I had unintentionally corrupted the httpd.conf file in /private/etc/apache2 when I edited it using TextWrangler. Not realizing what I was doing, I had used TextWrangler >Text > Add/Remove line numbers instead of TextWrangler > View > Text Display > Show Line Numbers, which prefixed/prepended the text of the line numbers to the lines in the saved file. :-/
The result was that Apache had not processed the httpd.conf file. I discovered this by testing Apache from Terminal using the 'sudo apachectl -t' comand. The resulting error message indicated a "syntax error on line 1" and displayed the line as "1 #" - making the problem obvious.
Fixing this (after having followed the directions in http://foundationphp.com/tutorials/php_leopard.php) and then stopping and restarting Apache left me with Apple's stock Apache 2 running and PHP 5 testing out perfectly.
Awesome! This lead me to the fix for MY problem as well ("cannot connect to server" error).
I ran "sudo apachectl -t" in the terminal and got this:
httpd: Syntax error on line 116 of /private/etc/apache2/httpd.conf: Cannot load /usr/libexec/apache2/libphp4.so into server: dlopen(/usr/libexec/apache2/libphp4.so, 10): image not found
Makes sense...there is no PHP4. I went to /private/etc/apache2/httpd.conf, commented line 116 (and subsequently un-commented line 114 for PHP5), restarted Web Sharing and Boom! It works!
Thanks Terry, for the clue!