1.要求搭建web服务器,能够访问到网页内容为“小胖,你咋这么胖呢!”
1. 下载httpd
yum install httpd
2.重启httpd
systemctl restart httpd
3.编辑网页资源文件
cd /var /www/html
vim index.html
4.浏览器访问
http://192.168.137.128/
2.要求搭建web服务器,创建基于域名的虚拟主机,能够使用www.xiaopang.com和www.dapang.com访问各自的网站网站存放路径分别为/xiaopang和/dapang,内容自定。
1.添加多个ip地址134 100 200
# nmcli connection modify ens160 ipv4.method manual ipv4.addresses 192.168.10.100/24 +ipv4.addresses 192.168.10.200/24 ipv4.gateway 192.168.10.2 ipv4.dns 114.114.114.114 connection.autoconnect yes
nmcli connection up ens160
2.关闭防火墙和selinux
#systemctl stop firewalld
#setenforce 0
3.安装对应的服务软件Apache http server
# mount /dev/sr0 /mnt
yum install httpd
4.更改配置文件实现自定义设置
vim /etc/httpd/conf.d/vhosts.conf
<VirtualHost 192.168.10.134:80> ServerName 192.168.10.134 DocumentRoot /www/openlab</VirtualHost><Directory /www> AllowOverride none Require all granted</Directory><VirtualHost 192.168.10.100:80> ServerName 192.168.10.100 DocumentRoot /www/xiaopang</VirtualHost><VirtualHost 192.168.10.200:80> ServerName 192.168.10.200 DocumentRoot /www/dapang</VirtualHost>
5.根据配置创建资源文件
mkdir -p /www/{openlab,xiopang,dapang}
echo this is 134 > /www/openlab/index.html
echo this is 100> /www/xiaopang/index.html
echo this is 200 > /www/dapang/index.html