I have recently successfully installed Symfony2 on my machine.
I can access http:/localhost/app_dev.php
(dev environment)
However, when I try to access the prod environment:
http:/localhost/app.php
I get the following error message in the browser:
Oops! An Error Occurred
The server returned a "404 Not Found". Something is broken. Please e-mail us at [email] and let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.
I have checked the obvious: The file app.php does exist in the same folder as app_dev.php - so I don't know whats causing this.
Does anyone have a solution to fix this?
[[Edit]]
I have cleared the cache by typing: sudo php app/console cache:clear env=prod no-debug
as recommended. I now get a blank screen. Worryingly, there are no error messages logged in app/logs/prod.log, so I have not got the faintest idea as to what is wrong (prod environment still works just fine).
Contents of my app/config/routing.yml file:
### 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
Here is my app/config/routing_dev.yml file
_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
I just noticed that I DO NOT have a routing_prod.yml**
(alarm bells ringing) - does Symfony2 not ship with a production routing config file?
My Apache configuration file content is shown below:
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>
[[Further Details]]
Contents of 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: No route found for "GET /" (uncaught exception) at /path/to/symfony/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/EventListener/RouterListener.php line 83 [] []
app/config/routing.yml
? – Vitalii Zurianrouting_dev.yml
androuting_prod.yml
. I also think you should checkaccess.log
anderror.log
of your web-server. And also, please, attach your web-server virtual host configuration. – Vitalii Zurianrouting_prod.yml
. It means that it will pickrouting.yml
– Vitalii Zurianrm -rf app/cache/*
) and runapp/console router:debug
to see exactly which routes have been registered. – kgilden