Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Heroku上的Symfony:403禁止您使用';我没有访问/访问此服务器的权限_Php_Symfony_Heroku_Http Status Code 404_Http Status Code 403 - Fatal编程技术网

Php Heroku上的Symfony:403禁止您使用';我没有访问/访问此服务器的权限

Php Heroku上的Symfony:403禁止您使用';我没有访问/访问此服务器的权限,php,symfony,heroku,http-status-code-404,http-status-code-403,Php,Symfony,Heroku,Http Status Code 404,Http Status Code 403,我已成功将我的Symfony 2应用程序部署到Heroku,但现在,当我尝试访问它时,我收到以下403错误: 禁止的 您没有访问/访问此服务器的权限 这是Heroku的日志: 2015-07-29T14:31:41.827491+00:00 heroku[router]: at=info method=GET path="/" host=my-app.herokuapp.com request_id=557a70f4-ea11-4519-b8df-301b714f6ffa fwd="151.77

我已成功将我的Symfony 2应用程序部署到Heroku,但现在,当我尝试访问它时,我收到以下403错误:

禁止的

您没有访问/访问此服务器的权限

这是Heroku的日志:

2015-07-29T14:31:41.827491+00:00 heroku[router]: at=info method=GET path="/" host=my-app.herokuapp.com request_id=557a70f4-ea11-4519-b8df-301b714f6ffa fwd="151.77.103.253" dyno=web.1 connect=0ms service=1ms status=403 bytes=387
2015-07-29T14:31:41.828428+00:00 app[web.1]: [Wed Jul 29 14:31:41.827438 2015] [autoindex:error] [pid 104:tid 140466989270784] [client 10.100.0.139:16096] AH01276: Cannot serve directory /app/: No matching DirectoryIndex (index.php,index.html,index.htm) found, and server-generated directory index forbidden by Options directive
2015-07-29T14:31:41.829009+00:00 app[web.1]: 10.100.0.139 - - [29/Jul/2015:14:31:41 +0000] "GET / HTTP/1.1" 403 209 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.125 Safari/537.36
似乎Symfony(或Heroku?)正在尝试为目录
/app/
提供服务,但我认为这是不正确的,从日志中可以看出:

2015-07-29T14:31:41.828428+00:00应用程序[web.1]:[Wed Jul 29] 14:31:41.827438 2015][autoindex:error][pid 104:tid 140466989270784] [客户端10.100.0.139:16096]AH01276:无法为目录/app/提供服务:否 找到了匹配的DirectoryIndex(index.php、index.html、index.htm),以及 Options指令禁止服务器生成的目录索引

接下来,我创建了我的
.procfile
,并将:

web: bin/heroku-php-apache2 web/
我还删除了
DemoBundle
,现在我的根URL在
DefaultController
中配置为:

<?php

// \AppBundle\Controller\DefaultController.php

namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class DefaultController extends Controller
{
    /**
     * @Route("/", name="Homepage")
     */
    public function indexAction()
    {
        return $this->render('default/index.html.twig');
    }
}
我的应用程序的另一部分可能是这个问题的原因:
security.yml
,目前是这样的:

# you can read more about security in the related section of the documentation
# http://symfony.com/doc/current/book/security.html
security:
# http://symfony.com/doc/current/book/security.html#encoding-the-user-s-password
    encoders:
        FOS\UserBundle\Model\UserInterface: sha512

# http://symfony.com/doc/current/cookbook/security/acl.html#bootstrapping
acl:
    connection: default

# http://symfony.com/doc/current/book/security.html#hierarchical-roles
role_hierarchy:
    ROLE_ADMIN:       ROLE_USER
    # ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
    ROLE_SUPER_ADMIN: ROLE_ADMIN

# http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers
providers:
    fos_userbundle:
        id: fos_user.user_provider.username_email

# the main part of the security, where you can set up firewalls
# for specific sections of your app
firewalls:
    main:
        pattern: ^/
        form_login:
            provider: fos_userbundle
            csrf_provider: security.csrf.token_manager
        logout:    true
        anonymous: true

    # disables authentication for assets and the profiler, adapt it according to your needs
    dev:
        pattern:  ^/(_(profiler|wdt)|css|images|js)/
        security: false

# with these settings you can restrict or allow access for different parts
# of your application based on roles, ip, host or methods
# http://symfony.com/doc/current/cookbook/security/access_control.html
access_control:
    #- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
    - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
但是,访问
http://my app.herokuapp.com/login
(这似乎是“向世界开放”),我收到了一个漂亮的404错误:

找不到

在此服务器上找不到请求的URL/登录名


那么,哪一个可能是问题?哪种设置阻止我访问Heroku上的Symfony应用程序?

这是不可能的。3个多小时才能找到解决方案。 在我发布的所有代码中都找不到解决方案

一个真正的、简单的、愚蠢的、小的解决方案:
procfile
name。 你注意到了吗?我用小写字母写的

解决方案是什么
Procfile
,首字母大写


这是一个地狱,但我终于让我的应用程序启动并运行起来了!:D

如果任何人仍有此问题,您可以尝试在proc文件中用单引号替换双引号

范例

"web: vendor/bin/heroku-php-apache2 public/"
应该是

'web: vendor/bin/heroku-php-apache2 public/'

最简单的方法是键入不带引号的行

比如说

web: vendor/bin/heroku-php-apache2 public/

部署时检查此通知: 注意:没有Procfile,使用“web:heroku-php-apache2”。 对我来说,在我直接在heroku云设置中编写web:heroku-php-apache2 public/directly之后没有什么不同。 然后我找到了这个,它工作了

如果在将代码部署到时不在本地主分支上 Heroku,你会犯错误的。你需要推到Heroku 当你在你当地的master分支机构时,master。这是默认设置 设置


换句话说,新的docroot只能从Procfile中设置,部署应该从本地主分支推送。

所以我在同一个地方发疯,因为我已经超过11个小时了,现在我正在试图找到解决方案,我的配置文件名是正确的,但我仍然得到相同的错误。如果你能让我知道我遗漏了什么,我会非常感激,请在这里回答问题,因为有时网站会离线或链接死亡,访问者将无法用死链接做很多事情
web: vendor/bin/heroku-php-apache2 public/