apache虛擬目錄配置

開啓模塊支持

LoadModule vhost_alias_module modules/mod_vhost_alias.so

基於域名的虛擬目錄設計

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

#匹配localhost訪問的地址
<VirtualHost *:80>
	ServerName localhost
	DocumentRoot "D:\www"
	<Directory "D:\www"> 
		Options FollowSymLinks IncludesNOEXEC Indexes
		DirectoryIndex index.html index.php default.php
		AllowOverride All
		Order Deny,Allow 
		Allow from all 
	</Directory>
</VirtualHost>

#匹配test1.domain.site訪問的地址
<VirtualHost *:80>
	ServerName test1.domain.site
	DocumentRoot "D:\www\test1"
	<Directory "D:\www\test1"> 
		Options FollowSymLinks IncludesNOEXEC Indexes
		DirectoryIndex index.html index.php default.php
		AllowOverride All
		Order Deny,Allow 
		Allow from all 
	</Directory>
</VirtualHost>

#匹配test2.domain.site訪問的地址
<VirtualHost *:80>
	ServerName test1.domain.site
	DocumentRoot "D:\www\test2"
	<Directory "D:\www\test2"> 
		Options FollowSymLinks IncludesNOEXEC Indexes
		DirectoryIndex index.html index.php default.php
		AllowOverride All
		Order Deny,Allow 
		Allow from all 
	</Directory>
</VirtualHost>


修改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
<VirtualHost *:8080>
	ServerName localhost
	DocumentRoot "D:\www"
	<Directory "D:\www">
		Options FollowSymLinks IncludesNOEXEC Indexes
		DirectoryIndex index.html index.php default.php
		AllowOverride All
		Order Deny,Allow
		Allow from all
	</Directory>
</VirtualHost>

Listen 8081
<VirtualHost *:8081>
	ServerName localhost
	DocumentRoot "D:\www\test1"
	<Directory "D:\www\test1">
		Options FollowSymLinks IncludesNOEXEC Indexes
		DirectoryIndex index.html index.php default.php
		AllowOverride All
		Order Deny,Allow
		Allow from all
	</Directory>
</VirtualHost>

Listen 8082
<VirtualHost *:8082>
	ServerName localhost
	DocumentRoot "D:\www\test2"
	<Directory "D:\www\test2">
		Options FollowSymLinks IncludesNOEXEC Indexes
		DirectoryIndex index.html index.php default.php
		AllowOverride All
		Order Deny,Allow
		Allow from all
	</Directory>
</VirtualHost>



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章