web服务常用配置解析
1、CentOS中的web服务
documentRoot:网页根目录 /var/www/html
网络路径与实际路径
网络路径:浏览器中的路径 192.168.4.7
实际路径:服务器上网页文件存放的路径 /var/www/myweb
网络路径:firefox 192.168.4.7/abc
实际路径:/var/www/myweb/abc (具体要去配置文件/etc/httpd/conf/httpd/conf 里面查看 输入D 寻找 documentRoot )
在主机A:
mkdir /var/www/myweb/abc
echo wo shi abc > /var/www/myweb/abc/index.html
这里 因为主机A中网页根目录是/var/www/html

在主机B:
curl 192.168.4.7/abc/

更改配置文件documentRoot
主机a:
vim /etc/httpd/conf/httpd.conf
mkdir /webapp
echo wo shi webapp > /webapp/index.html
systemctl restart httpd


到B中测试 就是如下:是在测试 因为客户机地址的限制

客户机地址限制:
使用<Driectory>配置区段
每个文件夹自动继承其父目录的ACL访问权限
除非针对子目录有明确的设置
<Driectory 目录的绝对路径>
Require all denied|granted
Require ip IP
Require all denied 拒绝所有人访问
Require all granted 允许所有人访问
Require ip 192.168.4.7 仅允许192.168.4.7访问
</Driectory>
例子:针对/opt目录拒绝所有人
<Driectory /opt>
Require all denied
</Driectory>
例子:针对/opt/web目录允许所有人访问
<Driectory /opt/web>
Require all granted
</Driectory>
注:若/opt下面还有nsd目录,没有给任何权限设置,自动继承其父目录的访问权限。
之前如果想要使用webapp可以成功访问,需要以下操作:
vim /etc/httpd/conf/httpd.conf
<Driectory /webapp>
Require all granted
</Driectory>
systemctl restart httpd
curl 192.168.4.7