此处所说的个人站点指的是拥有家目录的系统用户,可以通过网页访问的某个用户的家目录
    在个人站点之前最好增加用户认证,否则站点会裸奔。
先做访问控制
访问控制基于指定用户或者合法用户  
  1. AllowOverride AuthConfig
  2. AuthType Basic
  3. AuthName "Secrete Aera"
  4. AuthUserFile "/etc/httpd/conf/htpasswd"
  5. Require valid-user
  6. 或者
  7. Require user USERNAME
添加配置文件后要reload,但是添加用户后不用reload
htpasswd -c -m htpasswd tom
首次使用加-c(create),后来不用,使用的话会覆盖
-D删除用户
  1. # htpasswd -D htpasswd bob
  2. Deleting password for user bob
访问控制基于组
  1. # vim htgroup
  2. accessgroup:hiyang hadoop
  3. 组名:成员1 成员2 ...
此处的成员要是已经生成过htpasswd密码文件的,用空格隔开
  1. AllowOverride AuthConfig
  2. AuthType Basic
  3. AuthName "Secrete Aera"
  4. AuthUserFile "/etc/httpd/conf/htpasswd"
  5. AuthGroupFile /etc/httpd/conf/htgroup
  6. Require valid-user
  7. 或者
  8. Require user USERNAME
重启服务并在浏览器中测试
  1. # service httpd reload
  2. Reloading httpd: 

个人站点
创建可以通过网页访问的某个用户的家目录
1)配置文件
  1. <IfModule mod_userdir.c>
  2.     #
  3.     # UserDir is disabled by default since it can confirm the presence
  4.     # of a username on the system (depending on home directory
  5.     # permissions).
  6.     #
  7.     #UserDir disable
  8.     #
  9.     # To enable requests to /~user/ to serve the user's public_html
  10.     # directory, remove the "UserDir disable" line above, and uncomment
  11.     # the following line instead:
  12.    
  13.     UserDir public_html
  14. </IfModule>
2)步骤
  1. # su - test
  2. $ mkdir public_html #配置中指定的目录名
  3. $ cd public_html
  4. $ vim index.html
  5. Test's place.
  6. # chmod o+x test/ #家目录让其他用户可以访问
测试
httpd之个人站点_网页
注意波浪线要在英文状态下输入,否则出现如下错误
  1. access_log
  2. "GET /%EF%BD%9Etom/ HTTP/1.1" 404
  3. error_log
  4. File does not exist: /var/www/html/\xef\xbd\x9etom
对用户目录的控制
  1. #<Directory /home/*/public_html>
  2. # AllowOverride none
  3. # Options none
  4. # <Limit GET POST OPTIONS>
  5. # Order allow,deny
  6. # Allow from all
  7. # </Limit>
  8. # <LimitExcept GET POST OPTIONS>
  9. # Order deny,allow
  10. # Deny from all
  11. # </LimitExcept>
  12. #</Directory>
路径别名:
  1. Alias /icons/ "/var/www/icons/"
  2. Alias 相对于DocumentRoot 绝对路径