linux个人网站发布,51CTO博客-专业IT技术博客创作平台-技术成就梦想

发布个人站点

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.权限被拒绝

734af10120c35e0a80ea0721b6f35b2c.png

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.访问个人站点

154a12e81e9f21b1524fa47381057cd9.png

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]

5767444a7ce1ebaa85f981ca0f86a60a.png

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.验证身份的用户登陆测试

c4a1856d648bcdb177803c0b14808e38.png

22-4

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值