apache虚拟目录配置

开启模块支持

LoadModule vhost_alias_module modules/mod_vhost_alias.so

基于域名的虚拟目录设计

注:低版本可能需要 配置项中 NameVirtualHost *:80 的支持

#匹配localhost访问的地址

	ServerName localhost
	DocumentRoot "D:\www"
	 
		Options FollowSymLinks IncludesNOEXEC Indexes
		DirectoryIndex index.html index.php default.php
		AllowOverride All
		Order Deny,Allow 
		Allow from all 
	


#匹配test1.domain.site访问的地址

	ServerName test1.domain.site
	DocumentRoot "D:\www\test1"
	 
		Options FollowSymLinks IncludesNOEXEC Indexes
		DirectoryIndex index.html index.php default.php
		AllowOverride All
		Order Deny,Allow 
		Allow from all 
	


#匹配test2.domain.site访问的地址

	ServerName test1.domain.site
	DocumentRoot "D:\www\test2"
	 
		Options FollowSymLinks IncludesNOEXEC Indexes
		DirectoryIndex index.html index.php default.php
		AllowOverride All
		Order Deny,Allow 
		Allow from all 
	


修改C:\Windows\System32\drivers\etc\hosts
127.0.0.1 localhost
127.0.0.1 test1.domain.site
127.0.0.1 test2.domain.site


基于端口的虚拟目录配置

Listen 8080

	ServerName localhost
	DocumentRoot "D:\www"
	
		Options FollowSymLinks IncludesNOEXEC Indexes
		DirectoryIndex index.html index.php default.php
		AllowOverride All
		Order Deny,Allow
		Allow from all
	


Listen 8081

	ServerName localhost
	DocumentRoot "D:\www\test1"
	
		Options FollowSymLinks IncludesNOEXEC Indexes
		DirectoryIndex index.html index.php default.php
		AllowOverride All
		Order Deny,Allow
		Allow from all
	


Listen 8082

	ServerName localhost
	DocumentRoot "D:\www\test2"
	
		Options FollowSymLinks IncludesNOEXEC Indexes
		DirectoryIndex index.html index.php default.php
		AllowOverride All
		Order Deny,Allow
		Allow from all
	



你可能感兴趣的:(web服务器)