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]

36 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

  25. Mwandha Mufumbiro Says:

    your post is exceptional after timewasting in searches i got to your solution and believe me you it works magic.

  26. Catzhead Says:

    Thanks for this post, very useful.

    For those like me who forgot that they moved their home directory to another volume, remember to adapt the “<Directory "/Users/…" to the correct location, e.g. "_<

  27. Alex Says:

    Please elaborate on “remember to adapt the “<Directory"/Users?…" comment. I have followed all of the instructions of this page with no results.

  28. Ray Says:

    You are brilliant, bravo. :)
    I didn’t think they’d have “Deny all” in there, pfft

  29. Rich Says:

    Thank you so much sir! I’m a noob to this stuff and spent the entire morning trying to figure this one out. Your post was the solution!

  30. DronNick Says:

    chmod 701 ~
    chmod 705 ~/Sites

  31. stvs Says:

    All the methods described here are insecure, and Apple isn’t helping by forcing people to open their home directories as read-all to get web sharing to work.

    I DO NOT recommend giving EVERYONE read permission to your home directory, nor do I recommend the method described above of changing “Allow from all” in /private/etc/apache2/httpd.conf.

    Rather, I recommend creating a separate “/Users/Shared” directory with a corresponding weak Shared user account, then hosting content from the Shared directory.

    You can also use /Users/Shared to keep things like photos, music, virtual disk images, and other items that you do not necessarily wish FileVault to encrypt.

    As root, do these steps:

    # create /Users/Shared and user Shared with no login capability:

    mkdir /Users/Shared
    mkdir /Users/Shared/Sites
    mkdir /Users/Shared/Sites/images

    dscl localhost -create /Local/Default/Users/Shared
    dscl . -create /Users/Shared UniqueID 511
    [dsexport users.out /Local/Default dsRecTypeStandard:Users ; less users.out to find next UniqueID -- see http://osxdaily.com/2007/10/29/how-to-add-a-user-from-the-os-x-command-line-works-with-leopard/
    dscl . -create /Users/Shared UserShell /usr/bin/false # no login for Shared!
    dscl . -create /Users/Shared PrimaryGroupID 20 # staff
    dscl . -create /Users/Shared NFSHomeDirectory /Users/Shared
    # change ownership, permissions
    chown -R Shared:staff /Users/Shared
    chown -R 775 /Users/Shared

    # create apache conf file
    cp -p /etc/apache2/users/myusername.conf /etc/apache2/users/Shared.conf
    nano /etc/apache2/users/Shared.conf
    [Edit first line to use directory "/Users/Shared/Sites/"]
    httpd -k restart

    # copy over default web pages to /Users/Shared/Sites
    cp -p ~myusername/Sites/index.html /Users/Shared/Sites
    cp -p ~myusername/Sites/images/macosxlogo.gif /Users/Shared/Sites/images
    cp -p ~myusername/Sites/images/apache_pb.gif /Users/Shared/Sites/images
    cp -p ~myusername/Sites/images/web_share.gif /Users/Shared/Sites/images

    Now log out of root, and either under a new shell (bash/sh/tcsh/whatever) or a new Terminal window, you ought to be able to “cd ~Shared” to get to /Users/Shared. Sanity check your permissions using:
    ls -ld /Users/Shared. If you don’t want all staff to have write access to /Users/Shared and below, then:
    chmod -R g-w /Users/Shared

    Now Stop/Start System Preferences>Sharing>Web Sharing, and point your browser to:

    http://localhost/~Shared

    That should work. Now host from /Users/Shared without anyone being able access to your home directory. If you edited /private/etc/apache2/httpd.conf to “Allow from all” as default, change this back to “Deny from all” as default, and restart httpd and Web Sharing.

  32. YurikRecords Says:

    http://support.apple.com/kb/TA25038
    it worked

  33. jk Says:

    Fantastic! The Apple fix didn’t work for me but this one did after I removed the user.conf file I created using the Apple fix…

    Thanks for the tip!

  34. Stellablue Says:

    Good post and comments! #24 part 3 fixed it for me. I did not need to change httpd.conf and user.conf was setup already. #31 has good point in a shared environment with multiple users & sites. I think it is a good idea to keep all sites (& files) in one spot (ie: /library/webserver/documents) and setup user-owned folders…But to each his own.

    Unix is sure powerful tho – Stellablue

  35. basia Says:

    Hello everyone, I would very much appreciate further guiding through this process since all that my brain could follow is to open my terminal. In my terminal all I see is:
    Last login: Thu Jul 29 10:00:35 on console
    basias-MacBook:~ basia$

    all your comments seem to help everyone, but my old brain is not able to comprehend what to do next.
    If anyone is kind enough to take me step by step what to do from the point in my terminal :
    Last login: Thu Jul 29 10:00:35 on console
    basias-MacBook:~ basia$

    I will be most grateful.
    by the way, this error started after running the upgrades, and shows up on all web pages of my 2 domains and 3 subdomains, and all my tripot.com pages that have many.

    thank you in advance
    basia

  36. basia Says:

    hello again. in regard to post #35, my daughter fixed my problem. I wish I could share how she did this, but it was a labyrinth of unknown commands to me I blindly followed, and finally it involved going to /private/etc/apache2/ folder, then something about httpd.conf file. I am sure to everyone here it is meaningful, for me it is just an unbearable inside world of my MacBook I do not wish to revisit again. Thanks anyway, for posting your resolution.

Leave a Comment

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