apache 子目录绑定域名

www域名已经绑定主目录,这个主目录的子目录在单独绑定一个域名,

1.在httpd.conf里面搜索 打开vhosts虚拟主机配置文件

参考路径:D:\PC_webserver\apache\conf\httpd.conf

确保前面的#号已经去掉 ,保证开启

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

 

2.打开虚拟主机配置文件httpd-vhosts.conf 

参考D:\PC_webserver\apache\conf\extra\httpd-vhosts.conf

添加需要绑定的域名和目录  然后重启apache

<VirtualHost *:80>
	
	DocumentRoot D:/PC_webserver/phproot/m
	ServerName m.netnic.com.cn
	<Directory "D:/PC_webserver/phproot/m">

	Options Indexes FollowSymLinks
	AllowOverride Options FileInfo
	Order allow,deny
	Allow from all
	DirectoryIndex index.htm index.html index.php
	</Directory>
	
</VirtualHost>

 完整文件代码参考 第一个是默认的 都参考第一个就可以了

NameVirtualHost *:80
<VirtualHost *:80>
	ServerAdmin phpip.com@gmail.com
	DocumentRoot D:/PC_webserver/phproot
	ServerName localhost
	<Directory "D:/PC_webserver/phproot">

	Options Indexes FollowSymLinks
	AllowOverride Options FileInfo
	Order allow,deny
	Allow from all
	DirectoryIndex index.htm index.html index.php
	</Directory>
	Alias /phpmyadmin "D:/PC_webserver/phpMyAdmin/"
		<Directory "D:/PC_webserver/phpMyAdmin">
		AllowOverride AuthConfig
		Order allow,deny
		Allow from all
	</Directory>
</VirtualHost>

<VirtualHost *:80>
	
	DocumentRoot D:/PC_webserver/phproot/m
	ServerName m.netnic.com.cn
	<Directory "D:/PC_webserver/phproot/m">

	Options Indexes FollowSymLinks
	AllowOverride Options FileInfo
	Order allow,deny
	Allow from all
	DirectoryIndex index.htm index.html index.php
	</Directory>
	
</VirtualHost>

 

不同端口绑定 测试用 

 修改httpd.conf 参考路径:D:\wamp\bin\apache\apache2.4.9\conf\httpd.conf

添加监听端口 

Listen 0.0.0.0:8089
Listen [::0]:8089

确保开启虚拟主机配置 

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

 

打开虚拟主机配置文件 添加配置信息

参考路径:D:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf

配置不同端口号 

<VirtualHost *:8089>

    DocumentRoot D:/www.netnic.com.cn/phproot
    ServerName m.netnic.com.cn
    <Directory "D:/www.netnic.com.cn/phproot">


    Options Indexes FollowSymLinks
     AllowOverride all
     Require all granted
      DirectoryIndex index.htm index.html index.php
    </Directory>

</VirtualHost>

  

完成后重启apache 即可生效

 

 

posted @ 2016-04-25 11:30  星耀学园  阅读(828)  评论(0)    收藏  举报