目录
一、要求搭建web服务器,能够访问到网页内容为"小胖,你咋这么胖呢!"
二、要求搭建web服务器,创建基于域名的虚拟主机,能够使用www.xiaopang.con和www.dapang.com访问各自的网站 网站存放路径分别为/xiaopang和/dapang,内容自定.
1.添加多个ip地址(图形化界面)
(命令行操作)
# nmcli connection modify ens160 ipv4.method manual ipv4.addresses 192.168.87.128/24 +ipv4.addresses 192.168.87.100/24 +ipv4.addresses 192.168.87.200/24
# nmcli connection modify ens160 ipv4.gateway 192.168.87.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.87.128:80>
ServerName 192.168.87.128
DocumentRoot /www/openlab
</VirtualHost>
<Directory /www>
AllowOverride none
Require all granted
</Directory>
<VirtualHost 192.168.87.100:80>
ServerName 192.168.87.100
DocumentRoot /www/jincheng
</VirtualHost>
########多域名#######
<VirtualHost 192.168.87.100:80>
ServerName www.xiaopang.com
DocumentRoot /www/xiaopang
</VirtualHost>
<VirtualHost 192.168.87.100:80>
ServerName www.dapang.com
DocumentRoot /www/dapang
</VirtualHost>
5.增加多域名
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.87.100 www.xiaopang.com
192.168.87.100 www.dapang.com
~
6.根据配置创建资源文件
mkdir -p /www/{openlab,jincheng,xiaopang,dapang}
echo this is 128 > /www/openlab/index.html
vim /www/jincheng/index.html
小胖,你咋这么胖呢!
echo this is xiaopang> /www/xiaopang/index.html
echo this is dapang > /www/dapang/index.html
7.重启服务测试
systemctl restart httpd