Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I had web sharing enabled in Lion and a web site at http://localhost/~user, where user is my User directory. When I upgraded to Mountain Lion, web sharing (Apache) remained enabled and I can go to localhost and get the "It works!" default web page, but I cannot access my user page anymore. The error is


You don't have permission to access /~user/ on this server.

How do I re-enable my user directory's web page?

share|improve this question

Here is how you can re-enable the web page with the command line using Terminal.

First copy this and paste it into Terminal. You may have to press enter after pasting to run it. It will ask for your password because it is adding a file to your system directory.

USER_DIR=$(basename $(echo ~))
sudo bash -c "cat > /etc/apache2/users/$USER_DIR.conf" <<TEXT
<Directory "/Users/$USER_DIR/Sites">
     Options Indexes MultiViews
     AllowOverride None
     Order allow,deny
     Allow from all

Then run this command to restart the web server:

sudo apachectl restart
share|improve this answer
Sorry, my mistake, you need it for the name of the conf file as well. Nevertheless, $(basename ~) should work as well – patrix Jul 28 '12 at 18:35
I did something slightly different than this. Thanks indiv for the info that helped me create a custom solution for my setup. I added the "Directory" block you have to /etc/apache2/extra/httpd-userdir.conf with a "*" in place of "$USER_DIR". This enables user directories for all users that have a "Sites" directory. – Jason Jan 7 '13 at 15:13

I had to add FollowSymLinks as follows to my /etc/apache2/users/username.conf :

<Directory "/Users/username/Sites/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all

(username has to be replaced by your real username)

share|improve this answer

See, basically you have to enable per-user web sharing manually (with

share|improve this answer

Mountain Lion removes the configuration file that gives web access to your user directory. The configuration files are in /etc/apache2/users/. The missing one is user.conf, where user is your short username.

If you don't want to fiddle with the command line, here's an Applescript you can run to create a configuration file for your user. It will ask for your password because it has to create the file in a system-level directory and needs elevated privileges.

In your applications folder or Launchpad, open Other > Applescript Editor. Copy the script below and paste it into the text area of the Applescript editor. Then click the Run button.

set userHome to (short user name of (system info))
set configFile to "/etc/apache2/users/" & userHome & ".conf"
set configFileContents to "<Directory \"/Users/" & userHome & "/Sites/\">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all

do shell script "echo '" & configFileContents & "' > " & configFile with administrator privileges
do shell script "/usr/sbin/apachectl restart" with administrator privileges

When the script finishes, you should be able to access your user-level web page.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.