The directory permissions aren't set. I'm not sure why this worked earlier, it wasn't set in the previous Apache configuration under Lion, as far as I can tell. Maybe Mountain Lion has a newer, stricter version of Apache?
You need to edit /etc/apache2/extra/httpd-userdir.conf to add something like this (of course you need root access to edit this):
<Directory "/Users/*/Sites/"> Options Indexes Order allow,deny Allow from all </Directory>
Edit that to include whatever directives you want the users to have.
Then do a "apachectl configtest" to check for errors (it's OK to ignore the one about the server name if this is just for your own use), and "sudo apachectl restart" to get apache to see the new configuration.
I wouldn't edit /etc/apache2/extra/httpd-userdir.conf as previously suggested. Leave it as is. mod_userdir should be able to find your users' homes and if it can access the Sites directory within, it will just work. Well, it will work if you edit these two files:
In both files, uncomment line 532:
Once you do that, restart the web service and try again.
Note: userdir will be enabled for all sites. If you only want it to be enabled for some sites, then you need to make a "webapp" that includes the /private/etc/apache2/httpd-userdir.conf file.
I think you still need to edit httpd-userdir.conf - granted, I'm working on Mountain Lion without Server installed so my configuration differs a little. But compare the httpd-userdir.conf that Brad posted above with the one that comes from the MacPorts version of apache:
# Settings for user home directories # # Required module: mod_userdir # # UserDir: The name of the directory that is appended onto a user's home # directory if a ~user request is received. Note that you must also set # the default access control for these directories, as in the example below. # UserDir Sites # # Control access to UserDir directories. The following is an example # for a site where these directories are restricted to read-only. # <Directory "/Users/*/Sites"> AllowOverride FileInfo AuthConfig Limit Indexes Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec <Limit GET POST OPTIONS> Order allow,deny Allow from all </Limit> <LimitExcept GET POST OPTIONS> Order deny,allow Deny from all </LimitExcept> </Directory>
Apple has removed part of the default configuration and replaced it with the bonjour configuration (but left a confusing "as in the example below").
Without the <Directory> settings for the user directories, Apache reverts to the defaults that are set in the main conf file, and which deny all access:
Deny from all
One correction to the above - Apple replaced the <Directory "/Users/*/Sites"> section with an include to files in the /etc/apache2/users/ directory (plus the bonjour stuff). So it's possible that the <Directory "/Users/*/Sites"> section is moved there - check that first before editing httpd-userdir.conf. And if you don't want to edit httpd-userdir.conf, just put that block of text into a conf file in the /etc/apache2/users/ directory.
In Mountain Lion without Server installed, the /etc/apache2/users/ directory is empty, so these settings definitely needs to be added in one of these two places.
I don't think those changes are required for the basic userdir functionality--they weren't in my testing on Server anyway. (And I haven't tried enabling Web on non-Server Mountain Lion systems. It seems the checkbox for Personal Web Sharing is gone from Sharing System Prefs!) But, you've got a fair point that the default configuration may not provide your desired Apache configuration within the userdir (options, overrides, etc). But I would still say don't edit /etc/apache2/extra/httpd-userdir.conf. If you need them, put them in a separate file in /etc/apache2/users/.
Of course, it will work either way, but Apple seems to be steering you to the /etc/apache2/users/ directory with that include statement that you pointed out. Also, it remains to be seen if edits to /etc/apache2/extra/httpd-userdir.conf will survive a software update. (Speculation: Probably not if the update contains a new /etc/apache2/extra/httpd-userdir.conf file.) It seems more likely (although to be fair this is also not yet proven) that your edits will survive a software update if they are in a separate file in /etc/apache2/users/.
Blaidd Drwg wrote:
... Well, it will work if you edit these two files:
Whoa, whoa, whoa... NEVER edit the .default file. That is the "template" default file as delivered from the vendor, and should only be used as a reference as to how things were setup when the system was virgin. In a pinch, you can always re-copy it to a new .conf file to start over from scratch.
Nope, just edit the .conf file and you'll be good to go.
I had always (from Tiger?) used Web Sharing to host local development sites under ~user/Sites.
My latest setup was Lion Server (default install on a newish macmini server), but continued to use Web Sharing, rather than that provided by the server app.
So, on upgrading to ML + OSX Server, I was frustrated to discover that this no longer worked. However, it is an easy fix, once known!
I can confirm what Blaidd Drwg has written above. OSX Server has its own path for the apache configuration file, which is different to that used by Web Sharing. Edit
to remove the # from the Include directive
# User home directories
# Include /private/etc/apache2/extra/httpd-userdir.conf
will get user directories up and running again, once you have stopped and restarted apache in OSX Server.
I'm not sure what is needed on a clean install of ML + OSX Server, as the above requires the user configuration files to be in place. Perhaps someone else can clarify that.
I was having a similar issue. I am on 10.8.2 with Server. However, my Users's folders are not in the default location, they are on a Xsan volume. Just commenting out Line 532 as described above would turn on User home directory listings, but only for those users that were actually in /Server HD/Users/*/Sites. I wanted a different set of home folders. I finally was able to do it by uncommenting Line 532 and then editing my /etc/apache2/extra/httpd-userdir.conf file as follows:
# Settings for user home directories
# Required module: mod_userdir
# Comment out this line to keep /Server HD/Users/*/Sites folders from displaying
# UserDir Sites
# UserDir: The name of the directory that is appended onto a user's home
# directory if a ~user request is received. Note that you must also set
# the default access control for these directories, as in the example below.
# Users might not be in /Users/*/Sites, so use user-specific config files.
# add the full path to the folders I actually want
What you need to do is add a file to folder
or whatever your name is.
the file would contain a config like this:
Allow from all
The file should be 646 root:wheel
The folder should be 747 root:wheel
Lastly, the file at
needs a directive that says:
Most likely the line is there but only needs to be uncommented.
Restart "Web" of Server.app and your stuff should be up.
OK, your users are on an xsan volume. What about users that have an Open Directory entry?
When asking for http://www.pretendco.com/~thisuser I see in my log files [error] File does not exist: /Network/Servers/www.pretendco.com/Users/thisuser
So how to redirect ~thisuser to the Sites folder of an Open Directory user?
Using a "webapp" might be a good option if all you want to do is enable user directories on individual sites and you don't want to modify any Apache conf files. Save the following plist to /Library/Server/Web/Config/apache2/webapps/org.apache.httpd.userdir.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
Then edit your site in Server.app, click the advanced settings button, and check the "User Directories" box:
After clicking "OK", user directories should be enabled on your site.