Apache error log shows localhost requests going to /var/empty
( 1 )'/etc/apache2/httpd.conf' shows the DocumenRoot as '/Library/WebServer/Documents', as has been standard for previous OSX versions.
( 2 ) Create a simple php file 'local_info.php' and drop it into the DocumenRoot.
( 3 ) try to access : https://localhost/local_info.php
( 4 ) the page is not served, and I get a 'Not Found' error.
------------
( 5 ) Go to '/var/log/apache2/error_log'
[Sat Feb 04 15:21:48 2012] [error] [client ::1]
script '/var/empty/local_info.php' not found or unable to stat
------------
( 6 ) If I go to 'System Preferences -> Sharing -> Web Sharing' and restart Apache, then try to access the page nothing changes, the 'Not Found' error persists.
( 7 ) If I copy 'local_info.php' from '/Library/WebServer/Documents/local_info.php' to '/var/empty/local_info.php' and then point the browser to
( 8 ) try to access : https://localhost/local_info.php
the page is displayed correctly.
This is basically pretty much pristine copy of 'OS X Lion -> OS X Lion Server' with 'Server.app -> Services -> Web' turned off for the moment. During this testing phase I am only trying '/Library/WebServer/Documents', and not the virtual hosts.
I have the virtual hosts working very well through 'Server.app -> Services -> Web' which like I said above is turned off for the moment. The only problem I ran into there was that '/etc/hosts' was not being modified when a new virtual host was added via 'Server.app -> Services -> Web', but that was under OS X Server Lion 10.7.2, since I created the virtual hosts, I installed the Combo Updater for Lion Server 10.7.3, and I have not tried to create any new virtual hosts since then.
It is interesting that towards the bottom of httpd.conf there are some flags that load different pieces of code depending upon what flags are set. What is even more interesting is that both 'Server.app -> Services -> Web', and 'System Preferences -> Sharing -> Web Sharing' use one common '/etc/apache2/httpd.conf' file, which depending upon which flags are set during Apache startup load different config code. At least I think it is interesting...
These are the flags I noticed in /etc/apache2/httpd.conf
<IfDefine !MACOSXSERVER>
<IfDefine MACOSXSERVER>
<IfDefine WEBSERVICE_ON>
<IfDefine !WEBSERVICE_ON>
<IfDefine WEBSHARING_ON>
# Here only 'System Preferences -> Sharing -> Web Sharing' is running
$ ps aux | grep httpd
root ... /usr/sbin/httpd -D FOREGROUND -D MACOSXSERVER -D WEBSHARING_ON
_www ... /usr/sbin/httpd -D FOREGROUND -D MACOSXSERVER -D WEBSHARING_ON
# Here only 'Server.app -> Services -> Web' is running
$ ps aux | grep httpd
root ... /usr/sbin/httpd -D FOREGROUND -D MACOSXSERVER -D WEBSERVICE_ON
_www ... /usr/sbin/httpd -D FOREGROUND -D MACOSXSERVER -D WEBSERVICE_ON
$
# Here both 'Server.app -> Services -> Web', and 'System Preferences -> Sharing -> Web Sharing' are running
$ ps aux | grep httpd
_www ... /usr/sbin/httpd -D FOREGROUND -D MACOSXSERVER -D WEBSERVICE_ON -D WEBSHARING_ON
root ... /usr/sbin/httpd -D FOREGROUND -D MACOSXSERVER -D WEBSERVICE_ON -D WEBSHARING_ON
$
Here's some handy stuff that is echoed to my terminal for easy access
# ------------------------------------------------------------------------
# Some handy commands to access the files I use regularly...
#
sudo open -a /Applications/BBEdit.app /etc/hosts
sudo open -a /Applications/BBEdit.app /etc/php.ini
sudo open -a /Applications/BBEdit.app /etc/bashrc
#
open -a /Applications/BBEdit.app ~/.bash_profile
open -a /Applications/BBEdit.app ~/.bashrc
open -a /Applications/BBEdit.app ~/.bash_history
# ------------------------------------------------------------------------
# Or I can open all three at the same time
#
open -a /Applications/BBEdit.app /etc/bashrc ~/.bash_profile ~/.bashrc
# ------------------------------------------------------------------------
To (show|hide) files set AppleShowAllFiles (true|false) and kill the finder
#
defaults write com.apple.Finder AppleShowAllFiles true
KillAll Finder
# ------------------------------------------------------------------------
Hopefully Apple will get this problem fixed quickly so that 'System Preferences -> Sharing -> Web Sharing' works correctly...
Bill Hernandez
Plano, Texas