Apache功能之userdir

[userdir模块]
通过userdir模块,共享目录资料,配置步骤如下
编辑userdir配置文件,修改如下参数
vim /etc/httpd/conf.d/userdir.conf

1.启用userdir,
<IfModule mod_userdir.c>
    #
    # UserDir is disabled by default since it can confirm the presence
    # of a username on the system (depending on home directory
    # permissions).
    #
    #UserDir disabled  #添加注释,表示启用

    #
    # To enable requests to /~user/ to serve the user‘s public_html
    # directory, remove the "UserDir disabled" line above, and uncomment
    # the following line instead:
    #
    UserDir public_html             去掉注释
</IfModule>

<Directory "/home/*/public_html">
    #AllowOverride FileInfo AuthConfig Limit Indexes
    AllowOverride all
    # 添加一些认证的配置,使得用户可以用账号,密码访问该目录
    authuserfile "/etc/httpd/passwd"        
    authname "input your account"
    authtype basic
    require user chao
    #Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
    #Require method GET POST OPTIONS

</Directory>

2.创建网站数据文件夹,注意权限
useradd chaoge                  #如没有该用户就创建一个普通用户
[root@chaogelinux conf.d]# su - chaoge
[chaoge@chaogelinux ~]$ mkdir public_html

3.创建首页文件
[chaoge@chaogelinux ~]$ cat public_html/index.html
<meta charset=utf8>
欢迎大家来和超哥一起学起apache,感谢大家 <br>
下课,大家休息一下


4.设置权限
[root@chaogelinux www]# chmod -Rf 755 /home/chaoge/

5.创建需要验证的账户密码,生成数据库文件,这里需要退回到root用户执行命令
[root@chaogelinux www]# htpasswd -c /etc/httpd/passwd chao
New password: chaoge666
Re-type new password:chaoge666
Adding password for user chao



6.重启httpd,注意退回root
[root@chaogelinux conf.d]# systemctl restart httpd

7.可以访问http://192.168.178.187/~chaoge/   格式是 ip/~用户名  账号:chao   密码:chaoge666

8.访问目录下资源
[root@chaogelinux public_html]# pwd
/home/chaoge/public_html
[root@chaogelinux public_html]# ls
hehe.html  index.html

Apache功能之userdir

 

 Apache功能之userdir

 

Apache功能之userdir

上一篇:html 渲染原理


下一篇:关于html属性中onSubmit事件属性的使用