无法在WAMP上运行zend框架MVC应用程序

时间:2011-03-14 11:45:41

标签: zend-framework wamp

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

我错过了什么!?

谢谢

2 个答案:

答案 0 :(得分:8)

只是您错过了启用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/

答案 1 :(得分: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>

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

最后要使其工作,您需要编辑主文件,该文件应位于:C:\Windows\System32\drivers\etc\hosts

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

127.0.0.1       zendProject.local 

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

重启你的Wamp服务器,你很高兴