发布个人站点
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 httpdstart
Starting httpd:[OK]
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
134 Listen 80—明文访问
349
--存放发布个人站点的模块
--一般是禁用的
355#UserDir disable—默认是禁用的
362# UserDir public_html
364UserDir public_html—取消禁用,目录要与个人站点的一致
365
[root@localhost ~]# service httpd restart
Stopping httpd:[OK]
Starting httpd:[OK]
[root@localhost ~]#
[root@localhost ~]# netstat -tupln |grep http
tcp00 :::80:::*LISTEN2272/httpd
tcp00 :::443:::*LISTEN2272/httpd
[root@localhost ~]#
3.权限被拒绝
22-1
[baidu@localhost ~]$ cd ..
[baidu@localhost home]$ ll
total 12
drwx------ 4 baidubaidu4096 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
373AllowOverride all
374 #Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
375 #
376 #Order allow,deny
377#Allow from all
378 #
379 #
380 #Order deny,allow
381 #Deny from all
382 #
383
400 AccessFileName .htaccess
-- Web保护某些文件
406
407Order allow,deny
408Deny from all
409
[root@localhost ~]# service httpd restart
Stopping httpd:[OK]
Starting httpd:[OK]
7.验证身份的用户登陆测试
22-4