【问题标题】:Unable to start Zend2 skeleton app无法启动 Zend2 骨架应用程序
【发布时间】:2013-05-03 22:43:49
【问题描述】:

我在 Windows XP 上有一个 xampp 服务器: 阿帕奇 2.4.3 PHP 5.4.7

我尝试开始学习 Zend2。

我下载了骨架应用:https://github.com/zendframework/ZendSkeletonApplication 并从 cmd 运行:

php composer.phar self-update
php composer.phar install

(并不是说我必须像 C:\xxx\php.exe 那样提供 php 的完整链接 - 我不知道为什么,我的环境变量中有 php)。一切正常 - 没有错误。

我将此代码添加到 httpd-vhosts.conf :

<VirtualHost *:80>
    ServerName zf2-tutorial.localhost
    DocumentRoot /zf2-tutorial/public
    SetEnv APPLICATION_ENV "development"
    <Directory /zf2-tutorial/public>
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

我还将这一行添加到 C:\WINDOWS\system32\drivers\etc\hosts

127.0.0.1               zf2-tutorial.localhost localhost

当我跑步时

http://zf2-tutorial.localhost 

在浏览器中我得到“权限被拒绝”

当我尝试时

http://localhost/zf2-tutorial/public/ 

我得到很长的 php 错误

Fatal error: Uncaught exception 'Zend\ServiceManager\Exception\InvalidArgumentException' with message 'Provided abstract factory must be the class name of an abstract factory or an instance of an AbstractFactoryInterface.' in C:\xampp\htdocs\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php:302 ...........

我认为 serwer 有问题,因为我得到“权限被拒绝”。 我做错了什么?提前谢谢。

非常感谢大家。我的最终配置:

<VirtualHost *:80>
    ServerName zf2-tutorial.localhost
    DocumentRoot C:/xampp/htdocs/zf2-tutorial/public
    SetEnv APPLICATION_ENV "development"
    <Directory C:/xampp/htdocs/zf2-tutorial/public>
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

127.0.0.1               zf2-tutorial.localhost

适用于:http://zf2-tutorial.localhost/

【问题讨论】:

  • 谢谢。这解决了启动骨架应用程序的问题,但我只能在http://localhost/zf2-tutorial/public/ 上运行它,不知道为什么 vhosts 不适用于http://zf2-tutorial.localhost
  • 我面临同样的问题。但这似乎是一个错误,在 zf2 的 github 问题跟踪器上找到了这个github.com/zendframework/zf2/issues/4403(来自weierophinney 的评论)恐怕我们只需要等待修复。

标签: php xampp zend-framework2


【解决方案1】:

您的主机文件不正确。而不是:

127.0.0.1               zf2-tutorial.localhost localhost

去掉最后一个“localhost”,得到:

127.0.0.1               zf2-tutorial.localhost

编辑: 我刚刚注意到的另一件事是您的 DocumentRoot:这应该是您的文档根目录的完全限定路径:即 C:/www/zf-tutorial/public。请注意,您应该使用正斜杠作为目录分隔符。在您的目录配置中使用相同的路径,以确保允许访问该目录。

【讨论】:

  • 感谢您的回复。不幸的是,它没有奏效。现在我在http://zf2-tutorial.localhosthttp://localhost/zf2-tutorial/public/ 上都被拒绝了
【解决方案2】:

您似乎使用的是 Windows,因此您的虚拟主机配置应该包含您项目的类似 Windows 的路径。你确定你的 %PATH% 中有有效的 php\bin 路径吗?

> echo %PATH%

我在 Windows 7 上使用 XAMPP。 这是我的虚拟主机配置:

<VirtualHost *:80>
    ##ServerAdmin postmaster@dummy-host2.localhost
    DocumentRoot "C:/xampp/projects/zf2-tutorial/public"
    ServerName zf2.tutorial
    ##ServerAlias www.dummy-host2.localhost
    SetEnv APPLICATION_ENV "development"
    <Directory C:/xampp/projects/zf2-tutorial/public>
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
        Require all granted
    </Directory>
    ErrorLog "logs/zf2.tutorial-error.log"
    CustomLog "logs/zf2.tutorial-access.log" combined
</VirtualHost>

这是必不可少的(在您的情况下也可能):

    <Directory C:/xampp/projects/zf2-tutorial/public>
        # ...
        Require all granted
    </Directory>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-03
    相关资源
    最近更新 更多