2013-06-01 63 views
1

部署到生产环境失败,我看到空白页并且没有登录到app/log/prod.log。Symfony2:跳转到生产环境失败

我热身督促缓存,给cahce显示目录的所有权www数据,有没有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> 

任何线索?

+0

apache error_log的错误是什么? – Cyprian

+0

PHP致命错误:require():无法打开所需'/var/www/symfony/app/cache/prod/doctrine/orm/Proxies/__CG__MyProjectPanelBundleEntityAlgoritmo.php'(include_path ='。:/ usr/share/php:/ usr/share/pear')in /var/www/symfony/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php on line 165 –

回答

2

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

PHP Fatal error: require(): Failed opening required '/var/www/symfony/app/cache/prod/doctrine/orm/Proxies/_CG_MyProjectPanelBundleEn‌​tityAlgoritmo.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/symfony/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyF‌​actory.php on line 165

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

I gave ownership of cahce dirs to www-data

根据您正在使用ACL的事实,你不能这样做,检查documentation。有很多解决方案来解决这个问题,在灰色框架中解释。

解决您的问题,如果你不使用ACL,我觉得容易的方法是添加“的umask(0000);”在app.php(因为你可能在app_dev.php所做的那样),在你的文件的开头,并在“使用”声明之后。 (请参阅“3.不使用ACL”在灰色框中)。否则,请阅读灰色框架的其他说明。

现在框架将能够在将来写入缓存文件夹内。 但是,如果你不使用ACL,你需要再纠正当前的应用程序/缓存和应用程序/ logs文件夹配置:

考虑您的用户名是“用户”,说在根用户“用户”的用户组“用户”(通常是相同的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,并且你无法读取缓存文件夹(你会有同样的错误)!

+0

我没有ACL,我已经有了'umask(0000 )'在3个文件的开始处,我做了'chown'和'chmod',这是我在日志中看到的新错误:> PHP致命错误:带有消息的未捕获异常'ReflectionException'Class Maycol \\ BlogBu​​ndle \ \ Entity \\ Role does not exist'in /var/www/myproject/vendor/doctrine/common/lib/Doctrine/Common/Proxy/ProxyGenerator.php:760\nStack trace:\ n#0/var/www/myproject /vendor/doctrine/common/lib/Doctrine/Common/Proxy/ProxyGenerator.php(760): –

+0

哎呀,现在又回到原来的错误,看起来仍然困在权限问题 –

+1

你是否尝试重新安装供应商,也许是问题? (rm -rf vendor/*,php composer.phar install) – Sybio

0

数据库模式是最新的吗?

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

我尝试两次类似的情况,解决它以同样的方式:

我在进步在同一项目中的另一束工作与地方这个bug发生的互动操作。其实,我没有更新我的数据库模式。

希望这有助于