【问题标题】:Server set up of project with vhosts config使用 vhosts 配置的项目服务器设置
【发布时间】:2012-08-20 08:52:19
【问题描述】:

Zend 框架对我来说是新的,我正在阅读一本书,以便对事物有一个基本的了解(书是 Zend Framework A Beginners Guide)。

我已经建立了我的项目并在一个名为“test”的文件夹中创建了它

我还添加了一个vhost,vhosts文件包含:

<VirtualHost *:80>
   DocumentRoot "C:/Program Files/Zend/Apache2/htdocs/test/public"
   ServerName .localtest

   # This should be omitted in the production environment
   SetEnv APPLICATION_ENV development

   <Directory "C:/Program Files/Zend/Apache2/htdocs/test/public">
       DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>

</VirtualHost>

我已经从 apaches conf 文件中调用了 vhosts 文件

我还在 system32 hosts 文件中添加了一行:

127.0.0.1 test.localtest

我的问题是,当我浏览到 http://test.localtest/ 时,我得到了 zend 服务器测试页面,而从我正在阅读的内容来看,我应该得到 Zend Framework 项目主页启动画面,我可以通过浏览到 @987654322 来访问@

我错过了什么吗?

【问题讨论】:

    标签: apache zend-framework vhosts


    【解决方案1】:

    尝试改变

    <VirtualHost *:80>
       DocumentRoot "C:/Program Files/Zend/Apache2/htdocs/test/public"
       ServerName .localtest
    

    <VirtualHost *:80>
       DocumentRoot "C:/Program Files/Zend/Apache2/htdocs/test/public"
       ServerName test.localtest
    

    编辑

    好的,我检查了我的系统,它运行良好,但我正在使用 ubuntu 希望这会有所帮助

    编辑此文件

    C:\Program Files\Zend\Apache2\conf (Zend Server on Windows machines)
    

    并添加此代码

    <VirtualHost *:80>
        ServerName test.localtest
        DocumentRoot "C:/Program Files/Zend/Apache2/htdocs/test/public"
    
        SetEnv APPLICATION_ENV "development"
    
        <Directory "C:/Program Files/Zend/Apache2/htdocs/test/public">
            DirectoryIndex index.php
            AllowOverride All
            Order allow,deny
            Allow from all
        </Directory>
    </VirtualHost>
    

    然后编辑这个文件

    C:\WINDOWS\system32\drivers\etc\hosts
    

    并添加这一行

    127.0.0.1 test.localtest
    

    然后不要忘记重新启动你的 apache 服务器(wamp 或 xampp 或你正在使用的任何东西)

    然后打开这个链接

    http://test.localtest
    

    尝试使用http:// 编写网址有时浏览器在没有http:// 的情况下无法工作

    如果不起作用,请尝试评论

    【讨论】:

    • 感谢您的回复,但这只是给了我与 Zend Server Test Page 相同的结果.. :(
    • @user1117324 我已将您的答案从 C:\WINDOWS\system32\drivers\etc 编辑为 C:\WINDOWS\system32\drivers\etc\hosts , C:\WINDOWS\system32\drivers\etc是一个目录。
    【解决方案2】:

    大多数人都错过的一件事是 Zf 需要 FollowSymlinks 大部分时间都可以工作。

    这是我通常在我的虚拟主机中使用的目录定义

    <directory "C:\www\project">
        Options Indexes FollowSymlinks
        AllowOverride all
        Order Deny,Allow
        Allow from all
    </directory>
    

    不确定 DirectoryIndex 将如何影响这一点。

    确保在 Apache 中启用了 mod_rewrite:

    LoadModule rewrite_module modules/mod_rewrite.so //make sure this line is uncommented httpd.conf
    

    在 apache 中启用了 make vhosts:

    Include conf/extra/httpd-vhosts.conf //make sure this line is uncommented httpd.conf
    

    确保此行出现在您的 vhosts 文件中,通常位于 vhosts 定义的上方:

    NameVirtualHost *:80
    

    【讨论】:

    • 我在 vhosts 文件 NameVirtualHost *:80 中遗漏了这行代码,非常感谢 :)
    猜你喜欢
    • 2017-04-26
    • 1970-01-01
    • 2021-03-22
    • 1970-01-01
    • 2016-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-15
    相关资源
    最近更新 更多