0

我在 kubuntu 上设置了一个带有 Apache/PHP/MySQL 的本地网络服务器,以使用 ZendSkeletonApplication 开发一个网络应用程序。文档根目录设置为 ZSA 的公用文件夹:

<VirtualHost *>
    ServerName localhost
    ServerAdmin webmaster@localhost
    DocumentRoot "/var/www/ZendSkeletonApplication/public"
    <Directory /var/www/ZendSkeletonApplication/public>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>
    ErrorLog /var/log/apache2/error.log
    LogLevel warn
    CustomLog /var/log/apache2/access.log combined
    ServerSignature On
</VirtualHost>

ZSA 的公共文件夹中有一个 .htaccess 文件,内容如下:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

请求http://localhost正确检索index.php. 此外, mod_rewrite 正在工作。我交换了最后一行

RewriteRule ^.*$ test.php [NC,L]

测试它并且它有效。

接下来,我编写了一个简单的“Hello World”模块来适应架构。实际上,我什至按照不同的教程编写了两个模块。但是每当我尝试请求时,http://localhost/helloworld我都会收到 404 错误

The requested URL /helloworld was not found on this server.

我仔细检查了 ZF2 中的路线。

在这一点上,我被困住了。我是一名专业的 PHP 开发人员,对服务器管理知之甚少,因此我的设置很可能容易出错。

我想问一些方向,我可能做错了什么。有什么我可以检查的陷阱吗?我还需要提供什么信息?

4

1 回答 1

0

mod_rewrite 实际上工作正常,错误出现在我阅读的两个教程中。在更改了很多我不记得的设置后,404 变成了 500 服务器错误。直到那时我才在 apache 错误日志中找到了提示。

在这两个教程中,它都说要在 view/Modulename/Index/index.phtml 创建一个模板,而它必须是 view/modulename/index/index.phtml(注意小写名称)。对于所有小写路径,它现在对我有用。

错误日志中的错误消息(如果有人碰巧遇到同样的错误):

[2012 年 9 月 8 日星期六 14:38:28] [错误] [客户端 127.0.0.1] PHP 致命错误:未捕获的异常 'Zend\View\Exception\RuntimeException' 带有消息 'Zend\View\Renderer\PhpRenderer::render: Unable渲染模板“helloworld/index/index”;解析器无法解析到 /var/www/ZendSkeletonApplication/vendor/zendframework/zendframework/library/Zend/View/Renderer/PhpRenderer.php:451 中的文件

于 2012-09-08T12:52:56.827 回答