【问题标题】:Can't run zend framework MVC application on WAMP无法在 WAMP 上运行 zend 框架 MVC 应用程序
【发布时间】:2011-07-14 23:06:19
【问题描述】:

我是 zend 框架应用程序的新手。我在网上找到了一本书,里面有它的源代码示例,我正在努力学习 zend 框架 mvc。我在 wamp 中提取了 www 中的示例文件夹。当我尝试访问应用程序 localhost/exampleMVC/ 时,我得到一个页面,其中包含该目录中除公共以外的所有文件夹,该页面应该可用于服务器,当我尝试访问 localhost/exampleMVC/public 时出现错误页面错误 500;内部服务器错误。

我错过了什么!?

谢谢

【问题讨论】:

    标签: zend-framework wamp


    【解决方案1】:

    您需要在 apache 中配置一个virtual-host 以使 zend 与 mode_rewrite 一起正常工作

    在您的wamp\bin\apache\Apache(version number)\conf\httpd.conf 中删除Include conf/extra/httpd-vhosts.conf 行前面的# 符号(就在配置文件末尾附近的# Virtual hosts 行下方)

    然后在文件wamp\bin\apache\Apache(version number)\conf\extra\httpd-vhosts.conf 中应该有类似的内容:

    #
    # Virtual Hosts
    #
    # If you want to maintain multiple domains/hostnames on your
    # machine you can setup VirtualHost containers for them. Most configurations
    # use only name-based virtual hosts so the server doesn't need to worry about
    # IP addresses. This is indicated by the asterisks in the directives below.
    #
    # Please see the documentation at 
    # <URL:http://httpd.apache.org/docs/2.2/vhosts/>
    # for further details before you try to setup virtual hosts.
    #
    # You may use the command line option '-S' to verify your virtual host
    # configuration.
    
    #
    # Use name-based virtual hosting.
    #
    #NameVirtualHost *:80
    
    #
    # VirtualHost example:
    # Almost any Apache directive may go into a VirtualHost container.
    # The first VirtualHost section is used for all requests that do not
    # match a ServerName or ServerAlias in any <VirtualHost> block.
    #
    
    nameVirtualHost localhost
    <VirtualHost 127.0.0.1>
        ServerAdmin webmaster@localhost
        DocumentRoot "c:/wamp/www"
        ServerName localhost
        ErrorLog "logs/localhost-error.log"
        CustomLog "logs/localhost-access.log" common
    </VirtualHost>
    

    在此之后,添加您的新虚拟主机,类似这样:

    <VirtualHost 127.0.0.1>
        ServerAdmin webmaster@localhost
        DocumentRoot "C:\wamp\www\zendProject\public\"
        ServerName zendProject.local
        ErrorLog "logs/zendProject.local-error.log"
        CustomLog "logs/zendProject.local-access.log" common
        <directory "C:\wamp\www\zendProject\public\">
            Options Indexes FollowSymLinks
            AllowOverride all
            Order Deny,Allow
            Deny from all
            Allow from 127.0.0.1
        </directory>
    </VirtualHost>
    

    确保将zendProject 替换为您实际的zend 项目名称。我个人将.local 添加为域扩展,这样我就不会覆盖网络上的真实域。

    最后要让它工作,你需要编辑你的主机文件,它应该位于那里:C:\Windows\System32\drivers\etc\hosts

    您只需在文件末尾添加以下行(在记事本中打开):

    127.0.0.1       zendProject.local 
    

    确保使用您在虚拟主机配置中设置的相同名称。

    重新启动您的 Wamp 服务器,一切顺利

    【讨论】:

      【解决方案2】:

      只是你错过了启用mod_rewrite来解决它去

      WAMP -> APACHE -> apache modules -> then click on the mod rewrite 
      

      你会注意到 apache 会自行重启 你很高兴去

      我在 2 年前做了一个关于 zf + wamp 设置的截屏,欢迎你观看 http://www.zendcasts.com/getting-started-with-zend-and-wamp-server/2009/06/

      【讨论】:

      • mod 重写被禁用,就是这样 :) 轻松愉快
      • 我的意思是,为什么未选中 mod rewrite 以禁止我查看网站或公用文件夹?
      • 我注意到在 wamp 服务器全新安装上默认禁用重写
      • 老兄,这不是我的问题。为什么我必须取消选中 mod rewrite?那有什么作用?你说,“只是你错过了启用 mod_rewrite 来解决它”,但我为什么要这样做?
      • 天哪,每个该死的项目,我都必须浪费半个小时,浏览和更改 httpd.conf 和额外的一个,只是为了记住在 wamp 上激活 mod_rewrite。他们应该默认打开这个东西。谢谢。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-08-16
      • 1970-01-01
      • 2016-02-01
      • 2015-08-13
      • 1970-01-01
      • 2011-05-31
      • 2013-01-14
      相关资源
      最近更新 更多