日期:2014-05-17  浏览次数:20859 次

apache 虚拟主机配置

apache 虚拟主机配置

1, 常见配置

##配置一个虚拟主机
<VirtualHost *:80>
   ServerAdmin fengjun
    ##指定主目录
    DocumentRoot "E:\\php"
    ErrorLog "logs/fengjun-error.log"
    CustomLog "logs/fengjun-access.log" combined
</VirtualHost>
??

?

?

2,单独操作目录权限

?

<VirtualHost *:80>
    ServerAdmin fengjun
    DocumentRoot "E:\\php"
    ErrorLog "logs/fengjun-error.log"
    CustomLog "logs/fengjun-access.log" combined
    
     ##配置目录属性

     <Directory "E:\\php">
    	Options Indexes FollowSymLinks Includes ExecCGI
    	AllowOverride All
    	Order allow,deny
    	Allow from all
    </Directory>
</VirtualHost>
?

?

?

3,主机头方式(一个主机同一个端口绑定多个域名)

?

##开启以域名访问方式 -- 不开启,会访问到第一个匹配的虚拟主机

NameVirtualHost *:80


    <Directory "E:\\php">
    	Options Indexes FollowSymLinks Includes ExecCGI
    	AllowOverride All
    	Order allow,deny
    	Allow from all
    </Directory>

<VirtualHost *:80>
    ServerAdmin fengjun
    DocumentRoot "E:\\php\\home"

    ##指定域名

    ServerName home.fengjun.com
    ErrorLog "logs/fengjun-error.log"
    CustomLog "logs/fengjun-access.log" combined
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin fengjun
    DocumentRoot "E:\\php\\study"
    
    ##指定域名

    ServerName study.fengjun.com
    ErrorLog "logs/fengjun-error.log"
    CustomLog "logs/fengjun-access.log" combined
</VirtualHost>
?

?

?

?

?