我最近在我的机器上成功安装了 Symfony2。
我可以访问http:/localhost/app_dev.php
(开发环境)
但是,当我尝试访问 prod 环境时:
http:/localhost/app.php
我在浏览器中收到以下错误消息:
哎呀!发生错误
服务器返回“404 Not Found”。东西坏了。请通过 [email] 给我们发送电子邮件,让我们知道发生此错误时您在做什么。我们会尽快修复它。给您造成的任何不便,请原谅。
我已经检查了显而易见的:文件 app.php 确实存在于与 app_dev.php 相同的文件夹中 - 所以我不知道是什么原因造成的。
有没有人有解决这个问题的方法?
[[编辑]]
我已sudo php app/console cache:clear env=prod no-debug
按照建议键入:清除了缓存。我现在得到一个空白屏幕。令人担忧的是,app/logs/prod.log 中没有记录任何错误消息,所以我对出了什么问题一无所知(prod 环境仍然可以正常工作)。
我的 app/config/routing.yml 文件的内容:
### fos routing, remove later
fos_user_security:
resource: "@FOSUserBundle/Resources/config/routing/security.xml"
fos_user_profile:
resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
prefix: /profile
fos_user_register:
resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
prefix: /register
fos_user_resetting:
resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"
prefix: /resetting
fos_user_change_password:
resource: "@FOSUserBundle/Resources/config/routing/change_password.xml"
prefix: /profile
###
# Internal routing configuration to handle ESI
#_internal:
# resource: "@FrameworkBundle/Resources/config/routing/internal.xml"
# prefix: /_internal
这是我的 app/config/routing_dev.yml 文件
_welcome:
pattern: /
defaults: { _controller: AcmeDemoBundle:Welcome:index }
_demo_secured:
resource: "@AcmeDemoBundle/Controller/SecuredController.php"
type: annotation
_demo:
resource: "@AcmeDemoBundle/Controller/DemoController.php"
type: annotation
prefix: /demo
_assetic:
resource: .
type: assetic
_wdt:
resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
prefix: /_wdt
_profiler:
resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
prefix: /_profiler
_configurator:
resource: "@SensioDistributionBundle/Resources/config/routing/webconfigurator.xml"
prefix: /_configurator
_main:
resource: routing.yml
我刚刚注意到我没有 routing_prod.yml **
(警钟响起)- Symfony2 不附带生产路由配置文件吗?
我的 Apache 配置文件内容如下图所示:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /path/to/symfony/web
ServerName localhost
# Custom log file
Loglevel warn
ErrorLog /path/localhost.error.log
CustomLog /path/localhost.access.log combined
<Directory /path/to/symfony/web>
AllowOverride None
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</Directory>
</VirtualHost>
[[更多详细信息]]
app/logs/prod.log 的内容
[2012-08-10 18:10:38] security.INFO: Populated SecurityContext with an anonymous Token [] [] [2012-08-10 18:10:38] request.ERROR: Symfony\Component\HttpKernel\Exception\ NotFoundHttpException:在/path/to/symfony/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/EventListener/RouterListener.php第83行找不到“GET /”(未捕获的异常)的路由[] []