1、基于ip地址的虚拟主机
Listen 80
<VirtualHost 172.20.30.40>
DocumentRoot /home/httpd/html1
ServerName www.ok1.com
ErrorLog /usr/local/apache/logs/error1_log
CustomLog /usr/local/apache/logs/access1_log combined
</VirtualHost>
<VirtualHost 172.20.30.50>
DocumentRoot /home/httpd/html2
ServerName www.ok2.com
ErrorLog /usr/local/apache/logs/error2_log
CustomLog /usr/local/apache/logs/access2_log combined
</VirtualHost>
2、基于IP 和多端口的虚拟主机配置
Listen 172.20.30.40:80
Listen 172.20.30.40:8080
Listen 172.20.30.50:80
Listen 172.20.30.50:8080
<VirtualHost 172.20.30.40:80>
DocumentRoot /www/example1-80
ServerName www.example1.com
</VirtualHost>
<VirtualHost 172.20.30.40:8080>
DocumentRoot /www/example1-8080
ServerName www.example1.com
</VirtualHost>
<VirtualHost 172.20.30.50:80>
DocumentRoot /www/example2-80
ServerName www.example1.org
</VirtualHost>
<VirtualHost 172.20.30.50:8080>
DocumentRoot /www/example2-8080
ServerName www.example2.org
</VirtualHost>
3、单个IP 地址的服务器上基于域名的虚拟主机配置
# Ensure that Apache listens on port 80
Listen 80
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.example1.com
ServerAlias example1.com. *.example1.com
# Other directives here
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /www/example2
ServerName www.example2.org
# Other directives here
</VirtualHost>
4、在多个IP 地址的服务器上配置基于域名的虚拟主机:
Listen 80
# This is the "main" server running on 172.20.30.40
ServerName server.domain.com
DocumentRoot /www/mainserver
# This is the other address
NameVirtualHost 172.20.30.50
<VirtualHost 172.20.30.50>
DocumentRoot /www/example1
ServerName www.example1.com
# Other directives here ...
</VirtualHost>
<VirtualHost 172.20.30.50>
DocumentRoot /www/example2
ServerName www.example2.org
# Other directives here ...
</VirtualHost>
5、在不同的端口上运行不同的站点(基于多端口的服务器上配置基于域名的虚拟主机):
Listen 80
Listen 8080
NameVirtualHost 172.20.30.40:80
NameVirtualHost 172.20.30.40:8080
<VirtualHost 172.20.30.40:80>
ServerName www.example1.com
DocumentRoot /www/domain-80
</VirtualHost>
<VirtualHost 172.20.30.40:8080>
ServerName www.example1.com
DocumentRoot /www/domain-8080
</VirtualHost>
<VirtualHost 172.20.30.40:80>
ServerName www.example2.org
DocumentRoot /www/otherdomain-80
</VirtualHost>
<VirtualHost 172.20.30.40:8080>
ServerName www.example2.org
DocumentRoot /www/otherdomain-8080
</VirtualHost>
6、基于域名和基于IP 的混合虚拟主机的配置
Listen 80
NameVirtualHost 172.20.30.40
<VirtualHost 172.20.30.40>
DocumentRoot /www/example1
ServerName www.example1.com
</VirtualHost>
<VirtualHost 172.20.30.40>
DocumentRoot /www/example2
ServerName www.example2.org
</VirtualHost>
<VirtualHost 172.20.30.40>
DocumentRoot /www/example3
ServerName www.example3.net
</VirtualHost>
分享到:
相关推荐
php+apache虚拟主机配置 简单.php+apache虚拟主机配置
apache 虚拟主机配置非常适合新人学习
Apache虚拟主机配置文件 httpd-vhosts.comf
Apache虚拟主机的架设,图文都有 有图有真相
详细说明了 Apache虚拟主机配置和zf的环境配置 值得一看
具体的Apache虚拟主机配置,详细描述Apache虚拟主机的配置过程及原理
计算机后端-PHP视频教程. php与mysql加强- 05. php加强49-Apache虚拟主机配置.wmv
linux下apache虚拟主机的配置方法
此文档适用于lamp环境apache虚拟主机的搭建,使用lamp环境搭建虚拟主机的新手,可以参看此文档。
NULL 博文链接:https://ewinlive.iteye.com/blog/1004100
主要给大家介绍了关于Ubuntu 16.04与Apache虚拟主机配置的相关资料,文中通过示例代码介绍的非常详细,对大家学习或者使用ubuntu16.04系统具有一定的参考学习价值,需要的朋友们来一起看看吧。
资源名称:Apache服务器虚拟主机虚拟目录配置 资源截图: 资源太大,传百度网盘了,链接在附件中,有需要的同学自取。
apache虚拟主机配置一例,有需要的朋友可以参考下
一台apache服务器上配置多个站点,使用不同的域名访问不同的站点。本来是前两天帮公司一位同事配置虚拟主机,完成后写的一份技术文档,现在分享给大家了。
访问 http://www.abc.com/course/ ,实际访问的是:d:/www/moodle/index.PHP ServerAdmin webmaster@abc.com DocumentRoot d:/www/abc ... ##ServerAlias ... Options FollowSymLinks AllowOverride None O
文档是总结的apache的三种虚拟主机的配置方式,记录下来,方便以后查阅.
tomcat—apache集群虚拟主机配置详解!
具体如何配置apache里的虚拟主机