部署Symfony2项目时出现问题

nie*_*lsv 0 php .htaccess web-deployment symfony

我在部署symfony2项目时遇到了困难http://beachteamvandenbroecke-engels.be/.

我无法访问服务器上的ssh,因此我必须手动将项目文件夹复制到我的网站.
我已导出我的本地数据库并将其插入服务器.
我已经改变了我的设置config/parameters.yml.

但是现在当我想去http://beachteamvandenbroecke-engels.be/web/app_dev.php(没有设置我的.htaccess文件进行重定向)时,我收到此错误:

You are not allowed to access this file. Check app_dev.php for more information.
Run Code Online (Sandbox Code Playgroud)

在我的app_dev.php中:

<?php

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Debug\Debug;

// If you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
//umask(0000);

// This check prevents access to debug front controllers that are deployed by accident to production servers.
// Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP'])
    || isset($_SERVER['HTTP_X_FORWARDED_FOR'])
    || !in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', 'fe80::1', '::1'))
) {
    header('HTTP/1.0 403 Forbidden');
    exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}

$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
Debug::enable();

require_once __DIR__.'/../app/AppKernel.php';

$kernel = new AppKernel('dev', true);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
Run Code Online (Sandbox Code Playgroud)

我做错了什么?

pon*_*ste 6

作为评论sais

// This check prevents access to debug front controllers that are deployed by accident to production servers. // Feel free to remove this, extend it, or make something more sophisticated.

删除这个:

if (isset($_SERVER['HTTP_CLIENT_IP'])
    || isset($_SERVER['HTTP_X_FORWARDED_FOR'])
    || !in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', 'fe80::1', '::1'))
) {
    header('HTTP/1.0 403 Forbidden');
    exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}
Run Code Online (Sandbox Code Playgroud)

这只是检查您的IP地址是否允许.并允许IP包含在此数组中array('127.0.0.1', 'fe80::1', '::1').

注意

在prod env你需要指出app.php不是app_dev.php

编辑

要切换到PRODenv,请运行以下命令:

php app/console cache:warmup --env=prod --no-debug
Run Code Online (Sandbox Code Playgroud)

--env=prod将提供指向app.php而不是app_dev.php

--no-debug 将退出调试模式,因为它不会在浏览器中显示Symfony调试栏.