2007年6月16日星期六

关于Apache (fedora 7)的UserDir

在httpd.conf下

# UserDir: The name of the directory that is appended onto a user's home
# directory if a ~user request is received.
#UserDir:指定在得到一个~user请求时将会添加到用户home目录后的目录名。
# The path to the end user account 'public_html' directory must be
# accessible to the webserver userid. This usually means that ~userid
# must have permissions of 711, ~userid/public_html must have permissions
# of 755, and documents contained therein must be world-readable.
# Otherwise, the client will only receive a "403 Forbidden" message.
#注意目录和文件的权限
# See also: http://httpd.apache.org/docs/misc/FAQ.html#forbidden
#

#
# UserDir is disabled by default since it can confirm the presence
# of a username on the system (depending on home directory
# permissions).
#
UserDir disable若要使用,要将这行注释掉

#
# To enable requests to /~user/ to serve the user's public_html
# directory, remove the "UserDir disable" line above, and uncomment
# the following line instead:
#
#UserDir public_html若要使用,须同时取消注释这行



#
# Control access to UserDir directories. The following is an example
# for a site where these directories are restricted to read-only.
#
#
# AllowOverride FileInfo AuthConfig Limit
# Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
#
# Order allow,deny
# Allow from all
#

#
# Order deny,allow
# Deny from all
#

#


#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
# The index.html.var file (a type-map) is used to deliver content-
# negotiated documents. The MultiViews Option can be used for the
# same purpose, but it is much slower.
#~user请求时,到/home/user/public_html/下游览文件的顺序,
若没有列出,会报错You don't have permission to access /~user/ on this server.
DirectoryIndex index.html index.html.var


UserDir:指定在得到一个~user请求时将会添加到用户home目录后的目录名。
userdir public_html 是指各用户目录下的public_html目录是他的网站的根目录。
比如系统有用户sally,则
http://域名/~sally请求,apache会到/home/sally/public_html目录下找首页文件

UserDir指令用以指定被网络读取的用户特定的目录。 此指令有几种不同的形式。

如果路径没有前导斜杠,则被当作该用户宿主目录下的子目录。
如果有如此配置:
UserDir public_html
则URL http://example.com/~rbowen/file.html被会解释为文件路径/home/rbowen/public_html/file.html

如果路径有前导斜杠,则用此路径和用户名构造路径。
如果有如此配置:
UserDir /var/html
则URL http://example.com/~rbowen/file.html被会解释为文件路径/var/html/rbowen/file.html

如果路径中有星号(*), 则星号部分会被用户名所取代。如果有如此配置:
UserDir /var/www/*/docs
则URL http://example.com/~rbowen/file.html会被解释为文件路径/var/www/rbowen/docs/file.html

使用UserDir可以限定被允许使用此功能的用户:
UserDir enabled
UserDir disabled root jro fish

同时,还可以禁止所有用户而允许部分用户使用此功能,例如:
UserDir disabled
UserDir enabled rbowen krietz

没有评论: