我将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 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);
我做错了什么?
答案 0 :(得分: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.');
}
这只是检查您的IP地址是否被允许。允许的IP包含在此数组array('127.0.0.1', 'fe80::1', '::1')
中。
注意强>
在prod env中,您需要指向app.php
而不是app_dev.php
修改强>
要切换到PROD
env,请运行以下命令:
php app/console cache:warmup --env=prod --no-debug
--env=prod
将指向app.php
而不是app_dev.php
--no-debug
将退出调试模式,就像它不会在浏览器中显示Symfony调试栏一样。