gpt4 book ai didi

php - Symfony2 开发环境工作,生产环境给出 404 错误

转载 作者:IT王子 更新时间:2023-10-28 23:46:32 25 4
gpt4 key购买 nike

我最近在我的机器上成功安装了 Symfony2。

我可以访问http:/localhost/app_dev.php(开发环境)

但是,当我尝试访问 prod 环境时:

http:/localhost/app.php

我在浏览器中收到以下错误消息:

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.

我已经检查了明显的:文件 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: No route found for "GET /" (uncaught exception) at /path/to/symfony/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/EventListener/RouterListener.php line 83 [] []

最佳答案

你有没有开启生产环境并清除缓存?运行控制台并执行以下操作:

app/console --env=prod cache:clear

关于php - Symfony2 开发环境工作,生产环境给出 404 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11862468/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com