If, usually after installing/upgrading your mac, you can’t access your ~/Sites folder on your browser ( http://localhost/~username , where username is your mac username):

  • Open a Terminal and $ sudo nano /private/etc/apache2/httpd.conf ;
  • ctrl+w (where is) : “<Directory />” ;
  • Alter the line below from “Deny from all” to “Allow from all“;
  • ctrl+x and y to save;
  • now $ sudo httpd -k restart to restart your Apache 2 server;

Now retry accessing http://localhost/~username on your browser – that should do it;

[del.icio.us] [Digg] [Facebook] [Twitter]

24 Responses

  1. Alex Says:

    Thank you so much! Been looking for a fix for this for quite some time, and it is finally working for me. You made my day!!

  2. jskdoo Says:

    Ditto Alex’s comment! Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you!

  3. kay Says:

    didn’t worked for me .. neither did the apple solution :-(

    http://docs.info.apple.com/article.html?artnum=306884

  4. Carlos Ouro Says:

    file permissions problem?
    - try to set read and execute rights recursively for “anyone” for all file and folders on your ~/Sites folder.

    $sudo chmod -R 755 ~/Sites/*

  5. kay Says:

    i got it running now – but i needed to set permissions of my whole User folder to read-only for anyone, not just the Sites folder

    is that the default value? it seems a file sharing setting i made for my home folder ****** up the permissions

  6. Carlos Ouro Says:

    Yes, the sharing settings set all folders to writable, and, for security reasons, Apache requires the ~/Sites folder itself to be write protected.

    On a general Linux server, if you set /public_html or /www to writable you’ll get forbidden 403 too.

  7. Simon Bailey Says:

    Thanks man, every time I reinstall os x I forget this pearl :)

  8. Mike P Says:

    Open a Terminal and $ sudo nano /private/etc/apache2/httpd.conf ;
    ctrl+w (where is) : “” ;
    Alter the line below from “Deny from all” to “Allow from all“;
    ctrl+x and y to save;
    now $ sudo httpd -k restart to restart your Apache 2 server;

    These commands are all run together and I cannot decipher what is typed, etc. Can someone please make this more clear for me? Thank you.

  9. kaplan Says:

    This didn’t work for me either, but I’m an inept terminal user. The apple link Kay posted did though. Thanks Kay and next time I run into this problem I’m going try the Terminal method first, thanks Carlos.

  10. Dale Says:

    Thanks for the help. Just a small edit to the original. did not work until I changed it to,

  11. Dale Says:

    Sorry, the copy and paste didn’t work on the previous comment. What I was trying to say was, I had to change to for Terminal to find the right line to edit.

  12. Dave Says:

    Worked perfectly.

    You rock.

    Thanks.

  13. Greg Says:

    hmmm… this seems like it would open up permissions a little too much. When I had this problem I just went into /private/etc/apache2/users and made sure that each user had an appropriate *.conf file (a few were missing). If this directory is empty, you can create a new (temporary) user using System Preferences and then just copy their *.conf file over to your username (editing the first line as appropriate).

  14. Mark Says:

    Thanks very (very) much for posting this solution: I was in dire straits for a while there.

    I used Greg’s individual user version (comment 13 above) and it worked perfectly (creating a temporary user to get an initial .conf file and copying it to my real user id).

    Remember though that you must:

    (a) Do this as root (using sudo or sudo -s)
    (b) Restart the server with httpd -k restart

  15. Adrian Says:

    Absolutely brilliant. This newbie spent all day looking for a way to crack this, Google, Apple, everywhere. Followed step by step in Terminal, checked the config file was saved properly, turned web sharing off and back on, clicked on the personal web site link and Bingo. Thank you, thank you, thank you so much TechTrouts.

  16. Paddy Says:

    brilliant works great thanks again!

  17. John Barrett Says:

    Thanks so much I just got a replacement for my macbook pro, and was gong crazy trying to figure out why in the world was the localhost/~myusername not working, and thanks to you I can play with the localhost again.

    I searched for about 2 hours on Google, but could not find the information.

    Thanks so much, your rock dude!
    Johnny

  18. solak Says:

    This shell script will do the whole task. Just give it the usernames on the command line.
    You may have to repair the line breaks or formatting if the forum software mangles the text in its effort to be helpful.

    #! /bin/sh
    # Create web sharing conf file for the users specified as command-line parameters.
    echo
    for name in $*
    do
    if [ -n "$name" ] ; then
    echo creating $name.conf
    cat > /tmp/$name$$.conf << END

    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all

    END
    sudo mv /tmp/$name$$.conf /etc/apache2/users/$name.conf
    sudo chown root:wheel /etc/apache2/users/$name.conf
    fi
    done

    echo
    echo “Restarting apache webserver.”
    sudo httpd -k restart
    echo “Done.”

  19. Lt. Hammer Says:

    Modifying the httpd.conf file should be a last resort.
    Try Greg’s method first. If that doesn’t work, Get Info on your home folder. In the “Ownership and…” pane, click the lock and authenticate if necessary. Give “everyone” “read-only” access. Leave the ‘Ignore ownership…’ box unchecked. I have FileVault on. I assume it should work with FV off. Good Luck : ^ })

  20. Olivier Says:

    yes ! thanks to everybody, but specially to Lt Hammer Says (19).
    My home directory was not readable for all. That was my problem. !

  21. Tom Boutell Says:

    Yes, the Sites folder does have to be readable and executable by ‘_www’ and the sensible way to set that up on a personal machine is to make it readable and executable by everyone.

    But it is not true that it cannot be writable by everyone. It’s certainly not true that making it writable by everyone will cause Apache to refuse to work on Linux systems also as Carlos suggested. If that were true frameworks like Symfony that generate .php files on the fly and reuse them for performance reasons later would not work.

    There might be a system somewhere that refuses to work when it sees that the document root is writable, but I just tested this in Snow Leopard and it’s fine there.

  22. aadfaas Says:

    What worked for me was changing my username.conf so that it read like this:

    Options Indexes Multiviews
    AllowOverride None
    Order allow,deny
    Allow from all

  23. mootoh Says:

    Thanks for this tip.

    I recommend to use “Allow from localhost” instead of “Allow from all” if you want to see the site only from your computer, because giving an access to the computer in the network could bring some troubles.

  24. Mark A Sanderson Says:

    Thanks for all the help here. I checked all the points and my Mac personal website STILL didn’t work.

    Disclaimer in order, I do code for a living and I “bent” my environment a bit more than I should. After I checked all the pointers above, my site still didn’t work. Ultimately, I did figure it out.

    Here’s the check list I’d follow:

    1. Make sure httpd.conf switch is configured properly with

    AllowOverride None
    Order allow,deny
    Allow from all

    2. Make sure your personal user ID config file .conf is configrued in the same manner:

    AllowOverride None
    Order allow,deny
    Allow from all

    3. Then make sure your user directory is set to “Read Only” for “everyone”. At first, this faked me out because I didn’t want everyone to have read only access. However I then made a new ID to see how that was setup. As it turns out, making your ~ user ID home set in that manner isn’t a problem because it only affects your Sites and Public subdirectories. All other subdirectories are set to “no access”

    Once that was set properly… all works fine again.

    Good Luck

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.