How to Configure Lockdown with Personal Web
Sharing
AKA How to get it to work with your Mac's
built in web server
Mac OSX comes built in with the worlds best web
server (Apache) but by default it does allow a
user to enable passwords on a per-directory
basis. This feature is called 'AllowOverride' and
by default it's turned off so Lockdown doesn't
work.
Fortunately the solution to fix it to allow
Lockdown is quite easy but does require you are
comfortable with editing config files.
You need to use a tool that can open 'private'
files, in this example I use
TextWrangler because It's
free and I love it. If you are a Unix Hacker
you can jump to the very bottom of this page
to see how to modify this from the command
line which is less steps and arguably easier
but requires you know vi.
Open the file (it will be in one of the two
locations depending on which version of OSX you
are running)
/private/etc/httpd/users/[username].conf
or
/etc/apache2/users/[username].conf
Where [username] is your 'short' username. In my
case it's 'johnmcl'. Because this is a so-called
private file you have to either open it from a
terminal window using a command line tool such as
'vi' or use a special feature of TextWrangeler
called 'Open file by Name'
In my case I typed in
/private/etc/httpd/users/johnmcl.conf
The file looks like this
<Directory
"/Users/johnmcl/Sites/">
Options Indexes MultiViews
AllowOverride
None
Order allow,deny
Allow from all
</Directory>
Now I want to change the 'None' to 'All' and
TextWranger warns me.
Clicking yes, I modify the file to AllowOverride
<Directory
"/Users/johnmcl/Sites/">
Options Indexes MultiViews
AllowOverride
All
Order allow,deny
Allow from all
</Directory>
And save the file... TextWrangler needs to verify
I can modify this password
No problem.. I type in my password and save...
The only thing left to do is to restart the web
server to have the new settings take effect.
Go to System Preferences -> Sharing
Highlite "Personal Web Sharing" and click 'stop',
give it a second to stop
And then click 'Start' to restart it... That's
it! Lockdown should not be enabled!
If you prefer you can also do this from the
command line. Assuming you are logged in as the
user who you want to enable LockDown at the
command prompt type
sudo vi
/private/etc/httpd/users/$USER.conf
Give it the password, and modify the
'AllowOverride' to 'All' from None, save it,
restart Apache and you are finished!