1 2 Previous Next 18 Replies Latest reply: Jun 14, 2014 8:43 PM by Dave Rocks
Brad Bishop Level 1 Level 1 (10 points)

On Mountain Lion w/ Server installed:

 

All I want is for:

http://localhost/~user

to work

 

I have played with UserDir setting in httpd.conf (it's actually in  /private/etc/apache2/extra/httpd-userdir.conf - but I've played with moving it around from there to httpd.conf, etc.)

 

For the life of me I can't get it to work.

 

ownership/perms for Sites:
drwxr-xr-x   3 user  staff   102 Jul 29 10:04 Sites

 

http://localhost/~user results in a 404

 

The error in the logs is:

[Tue Jul 31 17:13:21 2012] [error] [client fe80::226:8ff:fee1:382] File does not exist: /Library/Server/Web/Data/Sites/Default/~user

 

This has to be stupid simple but I'm not seeing it.

 

mod_userdir is there and being loaded (not commented out).

I see nothing that would stop this but, obviously, it's not working (unless it's the group on the Sites directory).

 

Any help is appreciated.

 

From /private/etc/apache2/extra/httpd-userdir.conf:

#

# 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

 

#

# Users might not be in /Users/*/Sites, so use user-specific config files.

#

Include /private/etc/apache2/users/*.conf

<IfModule bonjour_module>

       RegisterUserSite customized-users

</IfModule>

 

That tells me that it should just do the UserDir Sites bit. I've tried it with/without the user.conf file which is included at the bottom.

 

What am I missing?

 

Thanks,

Brad


Mac mini, Mac OS X (10.7.3)
  • 1. Re: Apache2: UserDir Sites
    Joseph Delaney Level 3 Level 3 (550 points)

    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.

  • 2. Re: Apache2: UserDir Sites
    Blaidd Drwg Level 1 Level 1 (70 points)

    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:

     

    /Library/Server/Web/Config/apache2/httpd_server_app.conf

    /Library/Server/Web/Config/apache2/httpd_server_app.conf.default

     

    In both files, uncomment line 532:

     

    Include /private/etc/apache2/extra/httpd-userdir.conf

     

    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.

  • 3. Re: Apache2: UserDir Sites
    Joseph Delaney Level 3 Level 3 (550 points)

    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:

    <Directory />

        Options FollowSymLinks

        AllowOverride None

        Order deny,allow

        Deny from all

    </Directory>

  • 4. Re: Apache2: UserDir Sites
    capaho Level 4 Level 4 (3,650 points)

    Brad Bishop wrote:

     

    What am I missing?

     

    The SL Server version of Server Admin with a functional web management tool.  Send a thank you card to Apple for eliminating it.  They don't seem to understand the difference between a server and an iPhone but, hey, what a marketing concept!

  • 5. Re: Apache2: UserDir Sites
    Joseph Delaney Level 3 Level 3 (550 points)

    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.

  • 6. Re: Apache2: UserDir Sites
    Blaidd Drwg Level 1 Level 1 (70 points)

    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/.

  • 7. Re: Apache2: UserDir Sites
    Alphaman. Level 1 Level 1 (35 points)

    Blaidd Drwg wrote:

     

    ... Well, it will work if you edit these two files:

     

    /Library/Server/Web/Config/apache2/httpd_server_app.conf

    /Library/Server/Web/Config/apache2/httpd_server_app.conf.default

     

     

    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.

  • 8. Re: Apache2: UserDir Sites
    Michael Zyda Level 1 Level 1 (10 points)

    This worked great for Mountain Lion Server just editing the .conf file. I did NOT mess with .default. Thanks!!!!!!!!!!!!! mz

  • 9. Re: Apache2: UserDir Sites
    stephenhc Level 1 Level 1 (0 points)

    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

      /Library/Server/Web/Config/apache2/httpd_server_app.conf

    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.

  • 10. Re: Apache2: UserDir Sites
    Mark23 Level 3 Level 3 (975 points)

    If present the directory /etc/apache2/users/ contains configuration directives for mod_userdir, which allows access to web sites users have set up in their home directories.

  • 11. Re: Apache2: UserDir Sites
    neiltorda Level 1 Level 1 (5 points)

    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.

    #

    #UserDir Sites

     

     

    #

    # Users might not be in /Users/*/Sites, so use user-specific config files.

    #

    Include /private/etc/apache2/users/*.conf

    <IfModule bonjour_module>

           RegisterUserSite customized-users

    </IfModule>

     

    # add the full path to the folders I actually want

    <IfModule mod_userdir.c>

            UserDir /Volumes/XSANVOLUME/USERS/*/Sites

    </IfModule>

  • 12. Re: Apache2: UserDir Sites
    Gnarlodious Level 4 Level 4 (3,220 points)

    What you need to do is add a file to folder

    /Library/Server/Web/Config/apache2/other/

     

    called

     

    Username.conf

     

    or whatever your name is.

     

    the file would contain a config like this:

     

    <IfModule apple_userdir_module>

        UserDir Sites

    </IfModule>

     

    <Directory "/Users/username/Sites">

        AllowOverride All

        Order allow,deny

        Allow from all

    </Directory>

     

    The file should be 646 root:wheel

    The folder should be 747 root:wheel

     

    Lastly, the file at

    /Library/Server/Web/Config/apache2/httpd_server_app.conf

     

    needs a directive that says:

    Include /Library/Server/Web/Config/apache2/other/*.conf

     

    Most likely the line is there but only needs to be uncommented.

    Restart "Web" of Server.app and your stuff should be up.

  • 13. Re: Apache2: UserDir Sites
    eljonco Level 1 Level 1 (20 points)

    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?

  • 14. Re: Apache2: UserDir Sites
    Blaidd Drwg Level 1 Level 1 (70 points)

    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">

    <plist version="1.0">

    <dict>

              <key>displayName</key>

              <string>User Directories</string>

              <key>includeFiles</key>

              <array>

                        <string>/etc/apache2/extra/httpd-userdir.conf</string>

              </array>

              <key>installationIndicatorFilePath</key>

              <string>/etc/apache2/extra/httpd-userdir.conf</string>

              <key>name</key>

              <string>org.apache.httpd.userdir</string>

              <key>requiredModuleNames</key>

              <array>

                        <string>mod_userdir.so</string>

              </array>

              <key>sslPolicy</key>

              <integer>0</integer>

    </dict>

    </plist>

     

    Then edit your site in Server.app, click the advanced settings button, and check the "User Directories" box:

    UserDir.png

     

    After clicking "OK", user directories should be enabled on your site.

1 2 Previous Next