linux-发布个人站点和实现身份验证-022
发布个人站点 1.创建个人用户和站点 [root@localhost ~]# useradd baidu [root@localhost ~]# passwd baidu Changing password for user baidu [root@localhost ~]# su - baidu [baidu@localhost ~]$ mkdir public_html [baidu@localhost ~]$ cd public_html/ [baidu@localhost public_html]$ vim index.html hello baidu~ ~ 2.配置个人站点的文档 --安装密文访问 [root@localhost ~]# yum install mod_ssl [root@localhost ~]# service httpd start Starting httpd: [ OK ] [root@localhost ~]# vim /etc/httpd/conf/httpd.conf 134 Listen 80—明文访问 349 <IfModule mod_userdir.c> --存放发布个人站点的模块 --一般是禁用的 355 #UserDir disable—默认是禁用的 362 # UserDir public_html 364 UserDir public_html—取消禁用,目录要与个人站点的一致 365 </IfModule>
[root@localhost ~]# service httpd restart Stopping httpd: [ OK ] Starting httpd: [root@localhost ~]# [root@localhost ~]# netstat -tupln |grep http tcp 0 0 :::80 :::* LISTEN 2272/httpd tcp 0 0 :::443 :::* LISTEN 2272/httpd [root@localhost ~]#
3.权限被拒绝
22-1
[baidu@localhost ~]$ cd .. [baidu@localhost home]$ ll total 12 drwx------ 4 baidu baidu 4096 Aug 23 23:22 baidu drwx------ 3 redhat redhat 4096 Aug 12 13:32 redhat [baidu@localhost home]$ chmod o rx baidu [baidu@localhost home]$ pwd /home 3. 访问个人站点 22-2 4. 去掉~访问个人站点 [root@localhost ~]# vim /etc/httpd/conf/httpd.conf alias /baidu "/home/baidu/public_html" [root@localhost ~]# service httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ] 22-3 5.在baidu用户上实现身份验证,只允许其定义的用户可以访问个人网站 --定义身份验证 --在站点的总目录里 [baidu@localhost public_html]$ pwd /home/baidu/public_html [baidu@localhost public_html]$ [baidu@localhost public_html]$ vim .htaccess authuserfile /home/baidu/public_html/.passwd authtype basic authname "please input your name and your password:" require valid-user --创建登陆验证用户 [baidu@localhost public_html]$ htpasswd -c .passwd zhangsan New password: Re-type new password: Adding password for user zhangsan [baidu@localhost public_html]$ htpasswd .passwd lisi New password: Re-type new password: Adding password for user lisi [baidu@localhost public_html]$ cat .passwd zhangsan:cHgZASaOvpzgA lisi:aCb52rQLOeTJg [baidu@localhost public_html]$ ~ 6.打开目录安全性 --指定目录安全性的目录 [root@localhost ~]# vim /etc/httpd/conf/httpd.conf [root@localhost ~]# 372 <Directory /home/*/public_html> Stopping httpd: [ OK ] |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |