Results 1 to 8 of 8
  1. #1


    Member Since
    Jul 08, 2007
    Posts
    3
    Personal Web Sharing: can't get Aliases to work (Apache expert please!)
    I want to use Apache on my Mac to test sites I'm working on locally, as I'm accustomed to doing on Windows. Personal Web Sharing is enabled, and I can see the Apache welcome screen on 192.168.0.3 (the Mac's IP address), and the page under MyUserName/Sites/index.html at 192.168.0.3/~MyUserName

    However, I store all my work under /Documents/Work/Projectname/, and I don't want to move it all under /MyUserName/Sites.

    So what I'd normally do is edit Apache's httpd.conf and add a line like

    Code:
    Alias /Projectname/ "/Users/MyUserName/Documents/Work/Projectname/"
    but as far as I know on OS X you're not supposed to edit httpd.conf (well hidden under /private/etc/httpd/), but should edit /private/etc/httpd/users/MyUserName.conf instead.

    Is that correct? Anyway, it doesn't work! I get 403 Forbidden when trying to access html files under 192.168.0.3/MyProjectName/.

  2. #2


    Member Since
    Jul 08, 2007
    Location
    SLC, UT
    Posts
    31
    Specs:
    Macbook Pro, 2.2Ghz, 4GB Memory, 120GB HDD, LCD Display, OS X Tiger
    Quote Originally Posted by fjordaan View Post
    I want to use Apache on my Mac to test sites I'm working on locally, as I'm accustomed to doing on Windows. Personal Web Sharing is enabled, and I can see the Apache welcome screen on 192.168.0.3 (the Mac's IP address), and the page under MyUserName/Sites/index.html at 192.168.0.3/~MyUserName

    However, I store all my work under /Documents/Work/Projectname/, and I don't want to move it all under /MyUserName/Sites.

    So what I'd normally do is edit Apache's httpd.conf and add a line like

    Code:
    Alias /Projectname/ "/Users/MyUserName/Documents/Work/Projectname/"
    but as far as I know on OS X you're not supposed to edit httpd.conf (well hidden under /private/etc/httpd/), but should edit /private/etc/httpd/users/MyUserName.conf instead.

    Is that correct? Anyway, it doesn't work! I get 403 Forbidden when trying to access html files under 192.168.0.3/MyProjectName/.

    I've always editted /etc/httpd/httpd.conf and it's always worked fine for me. I'll try and add an alias real quick and report back.

  3. #3


    Member Since
    Jul 08, 2007
    Location
    SLC, UT
    Posts
    31
    Specs:
    Macbook Pro, 2.2Ghz, 4GB Memory, 120GB HDD, LCD Display, OS X Tiger
    Quote Originally Posted by fjordaan View Post
    I want to use Apache on my Mac to test sites I'm working on locally, as I'm accustomed to doing on Windows. Personal Web Sharing is enabled, and I can see the Apache welcome screen on 192.168.0.3 (the Mac's IP address), and the page under MyUserName/Sites/index.html at 192.168.0.3/~MyUserName

    However, I store all my work under /Documents/Work/Projectname/, and I don't want to move it all under /MyUserName/Sites.

    So what I'd normally do is edit Apache's httpd.conf and add a line like

    Code:
    Alias /Projectname/ "/Users/MyUserName/Documents/Work/Projectname/"
    but as far as I know on OS X you're not supposed to edit httpd.conf (well hidden under /private/etc/httpd/), but should edit /private/etc/httpd/users/MyUserName.conf instead.

    Is that correct? Anyway, it doesn't work! I get 403 Forbidden when trying to access html files under 192.168.0.3/MyProjectName/.
    Quote Originally Posted by supergper View Post
    I've always editted /etc/httpd/httpd.conf and it's always worked fine for me. I'll try and add an alias real quick and report back.
    alright, I've figured out your problem, the permissions in your homes folder are wrong for allowing access for Apache. If you change the group on all the folders from your homes folder down to Projectname from your user to wheel (and the files inside of them) then you can use that Alias. I don't know what other repercussions this may have but it will solve your Alias problem. The other possible solution (I didn't test it) is use symlinks, point from the webroot directory to Projectname.

  4. #4


    Member Since
    Jul 08, 2007
    Posts
    3
    Hi supergper, I'd love that to be the solution, but unfortunately not.

    I know that Aliases are understood, whether I put them in myusername.conf or in httpd.conf, because without them I just get a 404 Not Found, and with them, 403 Forbidden.

    So that leaves file/folder permissions. But the /Users/MyUserName/Sites folder -- which works -- has Read & Write permissions (chmod 755, I think: rwxr-xr-x), and this is exactly the same as the folder I'm trying to use /Documents/Work/Projectname.

    One difference: the same permissions apply to /MyUserName, but not to /Documents. The latter is rwx------

    Could that make a difference? Surely only the permissions of the relevant folder /Documents/Work/Projectname matter?

    Thanks for your help so far.

  5. #5

    xstep's Avatar
    Member Since
    Jun 25, 2005
    Location
    On the road
    Posts
    3,231
    Specs:
    2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
    I just played with this out of interest. I had to set execute permission from my personal root folder down the chain to the distination. So...

    I altered the users xstep.conf file as you suggested. The I setup the following permission via the command line. I doubt the group permission actually needs to be set.

    /User/xstep is set to drwx--x--x
    ~/Documents is set to drwx--x--x
    ~/Documents/Work is set to drwx--x--x
    ~/Documents/Work/Projectname is set to drwx--x--x

    I had to set my final target file, index.html, to -rw----r--

    So, for what ever reason, read permission all the way down the directory path is NOT needed. Just execute. The files that the browser are going to load require read permission. That included a PHP file I tested against.

    One final note. I had to use this format http://localhost/Projectname/ to get to the folder. Note the trailing slash.

  6. #6


    Member Since
    Jul 08, 2007
    Location
    SLC, UT
    Posts
    31
    Specs:
    Macbook Pro, 2.2Ghz, 4GB Memory, 120GB HDD, LCD Display, OS X Tiger
    Quote Originally Posted by xstep View Post
    I just played with this out of interest. I had to set execute permission from my personal root folder down the chain to the distination. So...

    I altered the users xstep.conf file as you suggested. The I setup the following permission via the command line. I doubt the group permission actually needs to be set.

    /User/xstep is set to drwx--x--x
    ~/Documents is set to drwx--x--x
    ~/Documents/Work is set to drwx--x--x
    ~/Documents/Work/Projectname is set to drwx--x--x

    I had to set my final target file, index.html, to -rw----r--

    So, for what ever reason, read permission all the way down the directory path is NOT needed. Just execute. The files that the browser are going to load require read permission. That included a PHP file I tested against.

    One final note. I had to use this format http://localhost/Projectname/ to get to the folder. Note the trailing slash.
    the only issue is you are giving EVERYONE execute permissions by setting it like that. It's safer to change the group to wheel for those same files/directories and be done with it. Both will work as they are both giving wheel/apache the needed permissions.

    Also, the reason for the need for the trailing slash is because you setup the alias as /Projectname/ instead of /Projectname (note, no trailing slash)...it doesn't matter which you use, but this is just an explanation as to why.

  7. #7


    Member Since
    Jul 08, 2007
    Posts
    3
    Problem solved!

    I had to chmod /Documents to 755 as well. So all folders in the path (/Documents/Work/Projectname) need to be 755. Can't see why, but there you go.

    Thanks for the help, all

  8. #8

    xstep's Avatar
    Member Since
    Jun 25, 2005
    Location
    On the road
    Posts
    3,231
    Specs:
    2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
    Quote Originally Posted by supergper View Post
    the only issue is you are giving EVERYONE execute permissions by setting it like that. It's safer to change the group to wheel for those same files/directories and be done with it. Both will work as they are both giving wheel/apache the needed permissions.
    I assumed that fjordaan wasn't concerned about tight security, just a basic answer. But...

    If you want to get all technical, I believe the proper group would be www on OSX as that is what the children httpd processes are spawned as after you start httpd up via the Sharing Preferences. When I just tested this, setting group ownership to wheel, httpd couldn't load the file. Changing group ownership to www fixed this issue. Note that I didnt' mess with the directories as I'm pretty much done with this discussion.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Personal Web Sharing IP logger
    By mario1123 in forum OS X - Operating System
    Replies: 10
    Last Post: 04-05-2011, 01:49 PM
  2. personal web sharing
    By bling in forum OS X - Apps and Games
    Replies: 2
    Last Post: 05-31-2008, 01:00 PM
  3. Personal Web Sharing
    By shahvikram123 in forum OS X - Operating System
    Replies: 13
    Last Post: 05-22-2008, 03:40 PM
  4. personal web sharing
    By the_New_guy in forum OS X - Operating System
    Replies: 2
    Last Post: 03-15-2005, 09:33 AM
  5. Personal Web Sharing / File Sharing ?
    By WhitE_RabbiT in forum OS X - Operating System
    Replies: 3
    Last Post: 07-29-2004, 03:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •