第五章 web服务器 实验一

实验要求

1.要求搭建web服务器,能够访问到网页内容为“小胖,你咋这么胖呢!”

2.要求搭建web服务器,创建基于域名的虚拟主机,能够使用www.xiaopang.com和www.dapang.com访问各自的网站网站存放路径分别为/xiaopang和/dapang,内容自定。

 

1.实验  要求搭建web服务器,能够访问到网页内容为“小胖,你咋这么胖呢!”

步骤一:首先进行挂载,配置yum源,装包

挂载命令:mount /dev/sr0 /mnt

可使用rpm命令查询已安装的软件包

rpm -qa | grep httpd

 

步骤二:建立配置文件,进行网页参数配置

vim /etc/httpd/conf.d/vhosts.conf

<Directory /www>
  AllowOverride none
  Require all granted
</Directory>

<VirtualHost 192.168.10.134>
  ServerName 192.168.10.134
  DocumentRoot /www/openlab
</VirtualHost>

 

步骤三:根据配置文件创建对应参数文件

mkdir -p /www/openlab

echo this is '小胖,你咋这么胖呢!' > /www/openlab/index.html

 

步骤四:重启http服务

systemctl restart httpd

 

步骤五:通过浏览器访问ip地址192.168.10.134测试结果

 

2.实验  要求搭建web服务器,创建基于域名的虚拟主机,能够使用www.xiaopang.com和www.dapang.com访问各自的网站网站存放路径分别为/xiaopang和/dapang,内容自定。

第一步同上

步骤二:建立配置文件,进行网页参数配置

vim /etc/httpd/conf.d/vhosts.conf

<Directory /www>
  AllowOverride none
  Require all granted
</Directory>

<VirtualHost 192.168.10.134:80>
  ServerName www.xiaopang.com
  DocumentRoot /www/xiaopang
</VirtualHost>

<VirtualHost 192.168.10.134:80>
  ServerName www.dapang.com
  DocumentRoot /www/dapang
</VirtualHost>

 

步骤三:根据配置文件创建对应参数文件

mkdir /www/{xiaopang,dapang}

echo this is xiaopang > /www/xiaopang/index.html

echo this is dapang > /www/dapang/index.html

 

步骤四同上

步骤五:用浏览器访问www.xiaopang.com和www.dapang.com网址测试结果

或使用命令curl测试

curl http://www.xiaopang.com

curl http://www.xiaopang.com

 

posted @ 2022-10-30 21:31  胧月北宸  阅读(54)  评论(0)    收藏  举报