您当前的位置: 首页 > 学无止境 > 心得笔记 网站首页心得笔记
马哥linux运维学习笔记-httpd属性配置
发布时间:2019-01-12 19:42:20编辑:雪饮阅读()
httpd环境:redhat5.8x64 apache2.23
站点目录索引与符号链接递归访问
Options Indexes FollowSymLinks
Options属性值可以多个,值与自己以空格分隔,多个值间也以空格分隔
Indexes值可以使得站点文档在没有配置默认文档时自动索引该站点目录文件列表呈现给访问者
FollowSymlinks则允许访问者当点击某个站点文件且该文件是符号链接时允许其查看符号链接的实质文件
站点访问权限
Order allow,deny
Allow from all
Deny from 192.168.43.58 192.168.43.144
Order allow,deny:访问权限顺序,这里是先同意后拒绝。
Allow from all:不拒绝请求者
Deny from 192.168.43.58 192.168.43.144:禁止192.168.43.58与192.168.43.144客户端访问,该行配置一般都可以不要,只有在特殊情况下才使用。
linux文本浏览器-elinks
elinks能实现一个纯文本界面的WWW浏览器。
-dump:将HTML文档以纯文本的方式打印到标准输出设备;
-source:可以查看所请求的http对象的源码
示例:
elinks -dump 192.168.43.175
elinks -source 192.168.43.175
站点授权访问
(1)httpd配置
AuthType Basic
AuthName "Restricted Site..."
AuthUserFile "/etc/httpd/conf/htpasswd"
Require valid-user
AuthType Basic:AuthType配置授权类型,一般为Basic
AuthName "Restricted Site...":AuthName权限名称可以自定义
AuthUserFile "/etc/httpd/conf/htpasswd":AuthUserFile授权用户账户配置文件(和passwd文件功能类似)。
Require valid-user:Require授权对象,可以是用户也可以是用户组,这里配置为用户
(2) htpasswd
htpasswd用来生成AuthUserFile配置文件
-c:创建加密文件
-m:使用md5加密方式
示例如:
[root@localhost ~]# htpasswd -c -m /etc/httpd/conf/htpasswd hadoop
New password:
Re-type new password:
Adding password for user hadoop
该命令重复执行会覆盖掉之前的配置文件
(3)完成站点授权访问
重启服务器后访问web页面就会提示如:
![1.png](/d/file/xuewuzhijing/xindebiji/5ab2e76d0a5a756bae6743a873f15748.png)
(4)仅限指定用户访问
Require user hadoop2
这里hadoop2既是指定登录用户的用户名
(5)指定用户组访问
建立用户组配置文件
[root@localhost ~]# cat /etc/httpd/conf/htgroup
myusers:hadoop tom
引入用户组配置文件
AuthGroupFile "/etc/httpd/conf/htgroup"
指定组访问权限
Require group myusers
用户站点
找到配置文件中“<IfModule mod_userdir.c>”模块中去除UserDir disable配置项的注释并配置UserDir配置项的值为 public_html
新增一个用户xy2,登录xy2在其家目录建立public_html并进入该目录建立一个index.html的网页
然后执行如下授权。
#chmod -R 711 /home/*
#cd /home/xy2/
#chmod 755 -R public_html
那么httpd重启后用户站点访问如:
![1.png](/d/file/xuewuzhijing/xindebiji/1af759db26ba5355ecdfdc7fa7f1e3e8.png)
别名路径
配置文件中如:
Alias /bbs "/bbs/forum"
注意:这里路径末尾若前者带斜线则后者也带斜线,若前者不带斜线则后者也不带斜线
建立HTML
[root@localhost logs]# mkdir -p /bbs/forum
[root@localhost logs]# cd /bbs/forum
[root@localhost forum]# vi index.html
[root@localhost forum]# cat /bbs/forum/index.html
this is bbs
重启httpd后访问路径如:
![1.png](/d/file/xuewuzhijing/xindebiji/ffea02f8560fa900ae30a80d3093630c.png)
关键字词:linux,httpd,配置