3rew 发表于 2014-7-21 09:13:32

Apache配置基于端口号的虚拟主机 Apache virtual host configuration is based on the port


Listen 81
Listen 82





Step 4:

  按照Step1中的规则,添加虚拟主机配置。


<VirtualHost *:80>
    DocumentRoot "D:\htdocs\project1\www"
    ServerName 127.0.0.1:80
    <Directory "D:\htdocs\project1\www">
      Options Indexes FollowSymLinks Multiviews
      AllowOverride All
      Order Allow,Deny
      Allow from all
    </Directory>
</VirtualHost>

<VirtualHost *:81>
    DocumentRoot "D:\htdocs\project2"
    ServerName 127.0.0.1:81
    <Directory "D:\htdocs\project2">
      Options Indexes FollowSymLinks Multiviews
      AllowOverride All
      Order Allow,Deny
      Allow from all
    </Directory>
</VirtualHost>




Note:

  在虚拟主机配置中一定要覆盖80端口的配置,不然则使用httpd.conf中配置的DocumentRoot的目录,那么项目的上级目录则暴露了。


页: [1]
查看完整版本: Apache配置基于端口号的虚拟主机 Apache virtual host configuration is based on the port