Configure Apache Web Sharing for user accounts in Mac OS X 10.5 Leopard
Apple’s new Mac OS X 10.5 (Leopard) changes how web sharing is set up. Thankfully, they’ve moved us all to Apache 2 codebase (a good thing™). But in doing so, they’ve disabled the ability to serve web pages contained in your home Site directory.
If you turn on Web Sharing from the System Preferences panel, it works for the main computer (http://localhost) but not for user accounts (http://localhost/~username/). Most perplexing is that Apple’s graphical interface confirms that web sharing is turned on for your personal account, but it doesn’t work. This is *very* un-Apple.
Even if you turn on web sharing from the System Preferences panel, you’ll still receive the dreaded 403 Forbidden. You don't have permission to access /~username/ on this server.
Thankfully, it’s a simple oversight on Apple’s part. Your options are two-fold. You can either set it up to activate the Sites directory in all your user accounts, or just for individual ones. I’ll cover both.
Activate Single User Account
Get your short username by opening a terminal, and typing:
whoami
Navigate to the Apache2 user configuration directory:
cd /private/etc/apache2/users
Now, we’ll open a new document with tee. Make sure to replace ‘username’ below with your short username. You will be prompted for a password when using sudo. Use your root or administrator password:
sudo tee username.conf
Then, copy and paste the following into terminal (replacing username with your short username):
#
# Allow access to this user's Sites directory for web clients.
#
<Directory "/Users/username/Sites/">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Then press Control-D to close the tee session.
Restart the Apache daemon:
sudo apachectl restart
That’s it; your user account should now have web sharing enabled.
If you want to activate web sharing for all current and future accounts, use this method instead:
Activate All User Accounts
Navigate to the Apache2 user configuration directory:
cd /private/etc/apache2/users
Now, we’ll open a new document:
sudo tee local.conf
Then, copy and paste the following into terminal:
#
# Allow access to all users' Sites directory for web clients.
#
<Directory "/Users/*/Sites/">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Then press Control-D to close the tee session.
Restart the Apache daemon:
sudo apachectl restart
Enable PHP
If you want to enable PHP5 which is built into Leopard, simply edit a single file, save it, and restart the Apache daemon:
Open terminal, and issue the following command:
cd /private/etc/apache2/
Then edit the file:
sudo pico httpd.conf
Search for php5 by pressing Control-W, and typing in php5, then pressing return.
You will find a line that reads:
#LoadModule php5_module libexec/apache2/libphp5.so
Delete the ‘#’ character, and save (Control-X) the file.
Restart the Apache daemon:
sudo apachectl restart











































[…] Garbage In Garbage Out - » Configure Apache Web Sharing for user accounts in Mac OS X 10.5 Leopard Get web sharing to work on Leopard. (tags: osx leopard) […]