部署Symfony2项目时出现问题



我在将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.

在我的app_dev.php:中

<?php
use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentDebugDebug;
// 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);

我做错了什么?

因为注释是

// 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.');
}

这只是检查您的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

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

--no-debug将退出调试模式,就像它不会在浏览器中显示Symfony调试栏一样。。

相关内容

  • 没有找到相关文章

最新更新