0

每当我尝试登录时都会遇到问题,但是此问题仅发生在上传站点的 Ubuntu 服务器上,并且在 Windows 上使用 wamp 工作正常。

我不知道它有什么问题。我在日志文件中看不到任何内容。

这是 security.yml 文件:

security:
    encoders:
        Op\AppSecurityBundle\Entity\User: sha512
        Symfony\Component\Security\Core\User\User: plaintext

providers:
    default:
        entity: { class: AppSecurityBundle:User, property: email }

role_hierarchy:
    ROLE_OPTIME_ADMIN:  ROLE_OPT_USER
    ROLE_SUPER_ADMIN:   [ROLE_OPT_USER, ROLE_OPT_ADMIN, ROLE_ALLOWED_TO_SWITCH]

firewalls:
    dev:
        pattern:  ^/(_(profiler|wdt)|css|images|js)/
        security: false

    prizes:
        pattern:    ^/admin|^/security|^/landing|^/reports|^/catalog
        form_login:
            check_path: /security/login_check
            login_path: /
            provider: default
            success_handler: whos_online
            failure_handler: whos_online
        logout:
            path:   /security/logout
            target: /
            success_handler: whos_online

access_control:
    - { path: ^/admin, roles: [ROLE_OPT_ADMIN] }
    - { path: ^/security, roles: [ROLE_OPT_ADMIN, ROLE_OPT_USER] }
    - { path: ^/landing, roles: [ROLE_OPT_ADMIN, ROLE_OPT_USER] }
    - { path: ^/reports, roles: [ROLE_OPT_ADMIN, ROLE_OPT_USER] }
    - { path: ^/catalog, roles: [ROLE_OPT_ADMIN] }

routing_dev.yml

_assetic:
    resource: .
    type:     assetic

_wdt:
    resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
    prefix:   /_wdt

_profiler:
    resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
    prefix:   /_profiler

_main:
    resource: routing.yml

路由.yml

ws:
    resource: "@BeSimpleSoapBundle/Resources/config/routing/webservicecontroller.xml"
    prefix:   /ws

security:
    resource: @AppSecurityBundle/Resources/config/routing.yml

parameter:
    resource: @ParameterBundle/Resources/config/routing.yml

status:
    resource: @AppStatusBundle/Resources/config/routing.yml

csc:
    resource: @CSCBundle/Resources/config/routing.yml

catalog:
    resource: @CatalogBundle/Resources/config/routing.yml

prizes:
    resource: @PrizesBundle/Resources/config/routing.yml

reports:
    resource: @ReportsBundle/Resources/config/routing.yml

AppSecurityBundle/Resources/config/routing.yml

_security:
    resource: "@AppSecurityBundle/Controller/AppSecurityController.php"
    type:     annotation

AppSecurityController.php 中的注解

            /**
     * @Route("/", name="_login")
     * @Template()
     */
    public function loginAction( )
    {
         //hidden
        }

/**
     * @Route("/security/login_check", name="_security_check")
     */
    public function securityCheckAction( )
    {
        // The security layer will intercept this request
    }

    /**
     * @Route("/security/logout", name="_logout")
     */
    public function logoutAction( )
    {
        // The security layer will intercept this request
    }

    /**
     * @Route("/landing", name="_landing")
     * @Template()
     */
    public function landingAction( )
    {
        return array ( );
    }

如果这是一个愚蠢的问题,我深表歉意。我不知道为什么它可以在本地工作,但不能在服务器上工作。

我正在使用 Symfony 2.0.12 和 Ubuntu Server 11.10

补充:当我运行 php app/console router:debug 我得到

[router] Current routes
Name                     Method Pattern
_wdt                     ANY    /_wdt/{token}
_profiler_search         ANY    /_profiler/search
_profiler_purge          ANY    /_profiler/purge
_profiler_import         ANY    /_profiler/import
_profiler_export         ANY    /_profiler/export/{token}.txt
_profiler_search_results ANY    /_profiler/{token}/search/results
_profiler                ANY    /_profiler/{token}
_webservice_call         POST   /ws/{webservice}
_webservice_definition   GET    /ws/{webservice}
_login                   ANY    /
_security_check          ANY    /security/login_check
_logout                  ANY    /security/logout
_landing                 ANY    /landing
_concurrency             ANY    /security/concurrency
_overwriteConcurrency    ANY    /security/overwriteConcurrency
_loading                 ANY    /security/loading
_changeLanguage          ANY    /changeLanguage
_security                ANY    /security/{strategy}/{globalStrategy}
_parameter               ANY    /admin/{strategy}/{globalStrategy}
_status                  ANY    /admin/{strategy}/{globalStrategy}
_csc                     ANY    /admin/{strategy}/{globalStrategy}
_catalogs                ANY    /catalog/{strategy}/{globalStrategy}
_prizes                  ANY    /admin/{strategy}/{globalStrategy}
_reports                 ANY    /{globalStrategy}/{strategy}
4

1 回答 1

3

曾经有同样的问题,在我的情况下,我没有很好地配置我的服务器,我通过使用 rewrite 模块配置 apache2 来修复它,在 linux 中它应该像这个 sudo a2enmod rewrite 一样,在你的站点配置站点中加上 etc/apache /sites-available/example.dev 你应该有这样的东西

NameVirtualHost 127.0.0.1

<VirtualHost 127.0.0.1>
  ServerName example.dev
  DocumentRoot "/var/www/intranetcms/web"
  DirectoryIndex app.php
  <Directory "/var/www/intranetcms/web">
    AllowOverride All
    Allow from All
  </Directory>
</VirtualHost>

如果您不知道如何配置本地域,这里有一个示例http://tutorial.symblog.co.uk/docs/configuration-and-templating.html 但如果您不想配置本地域,您可以检查默认值/etc/apache2/sites-enabled/default 中的站点配置文件,并将 AllowOverride None 更改为 AllowOverride All

于 2013-07-16T20:30:46.253 回答