1、复制一个新的网卡
[root@centos01 ~]# cp /etc/sysconfig/network-scripts/ifcfg-ens32 /etc/sysconfig/network-scripts/ifcfg-ens32:1 [root@centos01 network-scripts]# vim ifcfg-ens32:1 <!--编辑32:1网卡--> ...... <!--此处省略部分内容--> NAME=ens32:1 <!--修改名字--> DEVICE=ens32:1 <!--修改名字--> ONBOOT=yes IPADDR=192.168.100.20 <!--编辑IP地址--> NATEMASK=255.255.255.0 DNS1=192.168.100.10 <!--添加DNS--> [root@centos01 ~]# systemctl restart network <!--重启网卡服务--> 2、配置基于IP地址的虚拟主机 [root@centos01 ~]# vim /usr/local/httpd/conf/extra/httpd-vhosts.conf <!--创建独立配置文件--> NamevirtualHost :80 NamevirtualHost :80 <Directory "/var/www/"> order deny,allow allow from all </Directory> <VirtualHost 192.168.100.10:80> <!--bdqn.com是192.168.100.10--> DocumentRoot "/var/www/bdqn.com/" ServerName ErrorLog "logs/www.bdqn.com.error_log" CustomLog "logs/www.bdqn.com.access_log" common </VirtualHost> <VirtualHost 192.168.100.20:80> <!--benet.com是192.168.100.20--> DocumentRoot "/var/www/benet.com/" ServerName ErrorLog "logs/www.benet.com.error_log" CustomLog "logs/www.benet.com.access_log" common </VirtualHost> [root@centos01 ~]# systemctl restart httpd <!--重启Httpd服务--> 3、客户端访问验证 五、配置基于端口号的虚拟主机 1、修改Apache主配置文件 [root@centos01 ~]# vi /usr/local/httpd/conf/httpd.conf <!-编辑主配置文件--> 40 Listen 80 41 Listen 8080 <!--添加8080端口号--> 2、配置基于端口的虚拟主机 [root@centos01 ~]# vim /usr/local/httpd/conf/extra/httpd-vhosts.conf <!--创建独立配置文件--> NamevirtualHost :80 NamevirtualHost :80 <Directory "/var/www/"> order deny,allow allow from all </Directory> <VirtualHost 192.168.100.10:80> <!--bdqn.com是80端口--> DocumentRoot "/var/www/bdqn.com/" ServerName ErrorLog "logs/www.bdqn.com.error_log" CustomLog "logs/www.bdqn.com.access_log" common </VirtualHost> <VirtualHost 192.168.100.10:8080> <!--benet.com是8080端口--> DocumentRoot "/var/www/benet.com/" ServerName ErrorLog "logs/www.benet.com.error_log" CustomLog "logs/www.benet.com.access_log" common </VirtualHost> [root@centos01 ~]# systemctl restart httpd <!--重启httpd服务--> 3、客户端访问验证CentOS 7.4安装配置Apache网站服务和构建虚拟主机(3)
四、配置基于IP地址的虚拟主机
内容版权声明:除非注明,否则皆为本站原创文章。
转载注明出处:https://www.heiqu.com/7b7dc32704d14a30c803a648ac56942f.html