Apache HTTP Server Version 2.0
Per-user web directories
On systems with multiple users, each user can be permitted to have a web site in their home directory using the
UserDirdirective. Visitors to a URLhttp://example.com/~username/will get content out of the home directory of the user "username", out of the subdirectory specified by theUserDirdirective.
- Per-user web directories
- Setting the file path with
UserDir- Restricting what users are permitted to use this feature
- Enabling a cgi directory for each user
- Allowing users to alter configuration
Per-user web directories
Related Modules mod_userdirRelated Directives UserDirDirectoryMatchAllowOverrideSetting the file path with
UserDirThe
UserDirdirective specifies a directory out of which per-user content is loaded. This directive may take several different forms.If a path is given which does not start with a leading slash, it is assumed to be a directory path relative to the home directory of the specified user. Given this configuration:
UserDir public_htmlthe URL
http://example.com/~rbowen/file.htmlwill be translated to the file path/home/rbowen/public_html/file.htmlIf a path is given starting with a slash, a directory path will be constructed using that path, plus the username specified. Given this configuration:
UserDir /var/htmlthe URL
http://example.com/~rbowen/file.htmlwill be translated to the file path/var/html/rbowen/file.htmlIf a path is provided which contains an asterisk (*), a path is used in which the asterisk is replaced with the username. Given this configuration:
UserDir /var/www/*/docsthe URL
http://example.com/~rbowen/file.htmlwill be translated to the file path/var/www/rbowen/docs/file.htmlRestricting what users are permitted to use this feature
Using the syntax show in the UserDir documentation, you can restrict what users are permitted to use this functionality:
UserDir enabled
UserDir disabled root jro fishThe configuration above will enable the feature for all users except for those listed in the
disabledstatement. You can, likewise, disable the feature for all but a few users by using a configuration like the following:
UserDir disabled
UserDir enabled rbowen krietzSee
UserDirdocumentation for additional examples.Enabling a cgi directory for each user
In order to give each user their own cgi-bin directory, you can use a
DirectoryMatchdirective to make a particular subdirectory of a user's home directory cgi-enabled.
<DirectoryMatch /home/*/cgi-bin/>
Options +ExecCGI
SetHandler cgi-script
</DirectoryMatch>Allowing users to alter configuration
If you want to allows users to modify the server configuration in their web space, they will need to use
.htaccessfiles to make these changed. Ensure that you have setAllowOverrideto a value sufficient for the directives that you want to permit the users to modify. See the .htaccess tutorial for additional details on how this works.

