Personal Web Sharing: can't get Aliases to work (Apache expert please!)

Joined
Jul 8, 2007
Messages
3
Reaction score
0
Points
1
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/.
 
Joined
Jul 8, 2007
Messages
31
Reaction score
2
Points
8
Location
SLC, UT
Your Mac's Specs
Macbook Pro, 2.2Ghz, 4GB Memory, 120GB HDD, LCD Display, OS X Tiger
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.
 
Joined
Jul 8, 2007
Messages
31
Reaction score
2
Points
8
Location
SLC, UT
Your Mac's Specs
Macbook Pro, 2.2Ghz, 4GB Memory, 120GB HDD, LCD Display, OS X Tiger
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.

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.
 
OP
F
Joined
Jul 8, 2007
Messages
3
Reaction score
0
Points
1
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.
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's 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.
 
Joined
Jul 8, 2007
Messages
31
Reaction score
2
Points
8
Location
SLC, UT
Your Mac's Specs
Macbook Pro, 2.2Ghz, 4GB Memory, 120GB HDD, LCD Display, OS X Tiger
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.
 
OP
F
Joined
Jul 8, 2007
Messages
3
Reaction score
0
Points
1
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 :D
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's Specs
2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
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.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top