1

部署到生产环境失败,我看到一个空白页面并且在 app/log/prod.log 中没有登录。

我预热了 prod 缓存并将 cahce 目录的所有权授予www-data,也没有 php 日志记录,但这可能是一个管理错误,我要求对其进行检查,因为我无权访问它。

我将 htaccess 更改为省略 app_dev.php 并考虑 app.php,这是我的 .htaccess:

# Use the front controller as index file. It serves as fallback solution when
# every other rewrite/redirect fails (e.g. in an aliased environment without
# mod_rewrite). Additionally, this reduces the matching process for the
# startpage (path "/") because otherwise Apache will apply the rewritting rules
# to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
DirectoryIndex app.php
#DirectoryIndex app_dev.php

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Redirect to URI without front controller to prevent duplicate content
    # (with and without `/app.php`). Only do this redirect on the initial
    # rewrite by Apache and not on subsequent cycles. Otherwise we would get an
    # endless redirect loop (request -> rewrite to front controller ->
    # redirect -> request -> ...).
    # So in case you get a "too many redirects" error or you always get redirected
    # to the startpage because your Apache does not expose the REDIRECT_STATUS
    # environment variable, you have 2 choices:
    # - disable this feature by commenting the following 2 lines or
    # - use Apache >= 2.3.9 and replace all L flags by END flags and remove the
    #   following RewriteCond (best solution)
    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    #RewriteRule ^app_dev\.php(/(.*)|$) %{CONTEXT_PREFIX}/$2 [R=301,L]
    RewriteRule ^app\.php(/(.*)|$) %{CONTEXT_PREFIX}/$2 [R=301,L]

    # If the requested filename exists, simply serve it.
    # We only want to let Apache serve files and not directories.
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule .? - [L]


    RewriteCond %{REQUEST_FILENAME} -f
    #RewriteRule ^(.*)$ app_dev.php [QSA,L]
    RewriteRule ^(.*)$ app.php [QSA,L]

    # The following rewrites all other queries to the front controller. The
    # condition ensures that if you are using Apache aliases to do mass virtual
    # hosting, the base path will be prepended to allow proper resolution of the
    # app.php file; it will work in non-aliased environments as well, providing
    # a safe, one-size fits all solution.
    RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
    RewriteRule ^(.*) - [E=BASE:%1]
    #RewriteRule .? %{ENV:BASE}app_dev.php [L]
    RewriteRule .? %{ENV:BASE}app.php [L]
</IfModule>

<IfModule !mod_rewrite.c>
    <IfModule mod_alias.c>
        # When mod_rewrite is not available, we instruct a temporary redirect of
        # the startpage to the front controller explicitly so that the website
        # and the generated links can still be used.
        #RedirectMatch 302 ^/$ /app_dev.php/
        RedirectMatch 302 ^/$ /app.php/
        # RedirectTemp cannot be used instead
    </IfModule>
</IfModule>

有什么线索吗?

4

2 回答 2

2

这是一个假设,但如果您的开发环境有效,而不是您的产品(在同一项目和机器上),这是因为您忘记添加“umask(0000);” 在 web/app.php 中。

PHP 致命错误:require(): 无法打开所需的 '/var/www/symfony/app/cache/prod/doctrine/orm/Proxies/_ CG _MyProjectPanelBundleEn‌​tityAlgoritmo.php' (include_path='.:/usr/share/ php:/usr/share/pear') 在 /var/www/symfony/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyF‌​actory.php 第 165 行

这显然是文件夹 app/cache(和 app/logs)的权利和所有权问题。

我将 cahce 目录的所有权授予 www-data

根据您使用 ACL 的事实,您不能这样做,请查看文档。有很多解决方案可以解决这个问题,在灰色框中进行了解释。

如果您不使用 ACL,要解决您的问题,我认为最简单的方法是在app.php中添加“ umask(0000); ” (就像您可能在 app_dev.php 中所做的那样),在文件的开头并且只是在“使用”声明之后。(请参阅灰色框中的“3. 不使用 ACL”)。否则,请阅读灰框的其他说明。

现在框架将来可以在缓存文件夹中写入。但如果您不使用 ACL,您还需要更正当前的 app/cache 和 app/logs 文件夹配置:

考虑到您的用户名是“用户”,在 root 中说用户组“用户”的用户“用户”(通常与 Linux 机器上的用户名相同)是这些文件夹(和子文件夹/文件)的所有者:

su chown user.user -R app/cache app/logs

然后清除这些文件夹以确保没有损坏或丢失的文件(作为“用户”):

rm app/cache/* app/logs/*

授予文件夹 777 权限,以便框架能够在其中写入:

chmod 777 -R app/cache app/logs

此外,即使您可能这样做了,请检查您的应用程序/控制台文件是否具有 umask(0000); 没有注释,因为如果你错过了它,symfony 控制台会将文件写入 www-data,并且你无法读取缓存文件夹(你会遇到同样的错误)!

于 2013-06-02T09:47:51.040 回答
0

您的数据库架构是最新的吗?

php app/console doctrine:schema:update --dump-sql

我尝试了两次类似的情况并以相同的方式解决了它:

我在同一个项目的另一个捆绑包中进行了一项工作,与发生该错误的部分没有交互。实际上,我没有更新我的数据库架构。

希望这可以帮助

于 2014-11-04T15:52:22.267 回答