如何在Zend Server上创建虚拟主机?

8
我是使用Zend Server的,我在extra/httpd-vhosts.conf文件中添加了一个VirtualHost,并从httpd.conf文件中去掉了#。
以下是我添加到extra/httpd-vhosts.conf文件中的内容:
NameVirtualHost *:80

<VirtualHost *:80>
    ServerName quickstart.local
    DocumentRoot D:/quickstart/Code


    <Directory D:/quickstart/Code>
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

当我访问quickstart.local时,它能正常工作,但它也影响了localhost(即当我尝试加载http://localhost/时,我看到的是与http://quickstart.local/相同的站点)。
我该如何解决这个问题?我想让localhost(我用它做另一个项目)和quickstart.local保持分开。
4个回答

10
我有同样的问题。尝试在 zend.conf 中添加一个主机或添加


Include conf/extra/httpd-vhosts.conf                   

添加到httpd.conf文件中


取消注释以下行:在htppd.conf文件中包含conf / extra / httpd-vhosts.conf,并将您的指令添加到位于C:\ Program Files ... \ Zend \ Apache2 \ conf \ extra目录中的httpd-vhosts.conf。 - i--
在Windows中,您可能还需要向您的hosts文件添加一行。 - Isaac Montaine

3
您可以通过添加指令到一个新文件来添加新的虚拟主机:
/path/to/zend/etc/sites.d/vhost_[my-site].conf

[my-site]替换为您想要的任何内容(不要有空格)。

然后,请确保您重新启动apache

sudo /path/to/zend/bin/apachectl restart

0
[文件路径] \xampp\apache\conf\extra\httpd-vhosts.conf 或者,如果您使用的是 Apache 2.4 或更高版本:
<VirtualHost *:80>
     ServerName dev.zendapp
     DocumentRoot "G:/xampp/htdocs/io2018/zend2018/zendApps"
     SetEnv APPLICATION_ENV "development"
     <Directory "G:/xampp/htdocs/io2018/zend2018/zendApps">
         DirectoryIndex index.php
         AllowOverride All
         Require all granted
     </Directory>
 </VirtualHost>

更改后。C:\ Windows \ System32 \ drivers \ etc \ hosts
127.0.0.1       dev.zendapp

重启你的XAMPP服务器。

0

当我尝试添加自己的站点时,我遇到了类似的问题。对我来说,解决方案是在vhosts文件中注释掉两个虚拟主机示例,并取消注释或添加

127.0.0.1 localhost 

插入到%windir%/system32/drivers/etc文件夹中的hosts文件中

...当然,如果您需要取消注释vhost_alias模块并在httpd-vhosts文件中包含它..


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接