http_独立的web

http

基于B/S架构的网页服务。服务端提供网页,浏览器下载并显示页面。
html: 超文本标记语言
http: 超文本传输协议,端口80。

默认配置
Listen(监听地址端口) 80(http的端口号)
ServerName: 本站域名
DocumentRoot: 网页根目录 (/var/www/html)
DirectoryIndex: 起始页/首页文件名 (index.html)

主配置文件: /etc/httpd/conf/httpd.conf
调用配置文件:/etc/httpd/conf.d/*.conf
------------------------------------------------------------------------------------
构建独立的web服务器

背景:
DNS服务器(域名解析): classroom.example.com
今日可用域名:server0.example.com
www0.example.com
webapp0.example.com
nslookup server0.example.com #测试是否可以解析上面4个域名

环境(2台虚拟机):
1,防火墙设为trusted #firewall-cmd --set-default-zone=trusted
2,yum清缓存,列仓库

虚拟机server0
1,装包httpd #装包后会自动创建/var/www/html/
2,写页面 echo '<h1>hello world' > /var/www/html/index.html
3,重启服务,并开机自启httpd #systemctl restart/enable httpd
------------------------------------------------------------------------------------
servername:本站域名

虚拟机server0:
1,修改主配置文件 /etc/httpd/conf/httpd.conf
/ServerName #全文搜索,注意S和N字母大写
ServerName server0.example.com:80 #改为server0
2,重起服务httpd

虚拟机desktop0验证: 测试访问 firefox server0.example.com
---------------------------------------------------------------------------------------
DocumentRoot:网页文件的根目录(/var/www/html)

虚拟机server0:
1,修改主配置文件 /etc/httpd/conf/httpd.conf
/DocumentRoot #全文搜索,注意D和R字母大写
DocumentRoot /var/www/myweb #更改网页文件的新路径
2,创建网页文件路径,写新页面
mkdir /var/www/myweb
echo '<h1>myweb' > /var/www/myweb/index.html
3,重起服务httpd

虚拟机desktop0验证: 测试访问
--------------------------------------------------------------------------------------------
网络路径与服务器实际路径

网络路径:在浏览器输入的路径
firefox server0.example.com---》DNS---》firefox 172.25.0.11
--->服务端80--->httpd-->主配置文件----->DocumentRoot /var/www/myweb

浏览器:server0.example.com
服务端:/var/www/myweb

浏览器:server0.example.com/abc
服务端:/var/www/myweb/abc

虚拟机server0:
创建网页文件路径,写新页面 #修改配置文件了,才用重启服务。
mkdir /var/www/myweb/abc
echo '<h1>abc' > /var/www/myweb/abc/index.html

虚拟机desktop0验证: firefox server0.example.com/abc
##########################################################################
思路:

服务端提供资源:
1)新建目录
2)修改配置文件
3)修改配置文件,添加访问控制
4)重起httpd服务

客户端访问资源:
防火墙
SELinux
服务本身的限制
本地目录的限制

猜你喜欢

转载自www.cnblogs.com/summer2/p/10787859.html