标签:基于 tom 运行 centos 7 vim status localhost code 配置
虚拟主机——在一台www服务器上运行多个网站
god.com目录下的index.html
<html> <head>hell</head> <br></br> <body> this is hell area </body> </html>
hell.com目录下的index.html
<html> <head>hell</head> <br></br> <body> this is hell area </body> </html>
两种方式:基于IP和基于主机名
1、基于同IP不同端口(在默认的配置前提下:已有80端口)
vim /etc/httpd/conf/httpd.conf
添加监听端口:listen 8080
注释ServerAdmin:#ServerAdmin root@localhost
注释documentRoot:#DocumentRoot "/var/www/html"
在配置文件最后添加以下内容:
NameVirtualHost *:80 <VirtualHost 192.168.0.225:80> ServerAdmin admin@god.com DocumentRoot /var/www/god.com Servername www.god.com errorlog logs/god.com-error_log customlog logs/god.com-access_log common </VirtualHost> <VirtualHost 192.168.0.225:8080> ServerAdmin admin@hell.com DocumentRoot /var/www/hell.com Servername www.hell.com errorlog logs/hell.com-error_log customlog logs/hell.com-access_log common </VirtualHost>
测试:分别访问192.168.0.225和192.168.0.225:8080,结果如下:
2、基于同端口不同IP(同1,针对有两个IP的服务器,配置中只是IP不同)
service httpd start/stop/restart/status
apache httpd 虚拟主机配置(基于centos 7)
标签:基于 tom 运行 centos 7 vim status localhost code 配置
原文地址:https://www.cnblogs.com/feer/p/9837439.html