[英]Problems deploying Symfony2 project
I'm having difficulties deploying my symfony2 project to http://beachteamvandenbroecke-engels.be/
. 我在将symfony2项目部署到http://beachteamvandenbroecke-engels.be/
遇到困难。
I don't have access to ssh on my server so I had to copy the project folder to my website manually. 我无权访问服务器上的ssh,因此必须手动将项目文件夹复制到我的网站。
I've exported my local db and inserted it on the server. 我已经导出了本地数据库并将其插入服务器中。
I've changed the settings in my config/parameters.yml
. 我已经更改了config/parameters.yml
的设置。
But now when I want to go to http://beachteamvandenbroecke-engels.be/web/app_dev.php (haven't set my .htaccess file for redirecting) I get this error: 但是现在,当我想访问http://beachteamvandenbroecke-engels.be/web/app_dev.php (尚未设置要重定向的.htaccess文件)时,出现以下错误:
You are not allowed to access this file. Check app_dev.php for more information.
In my app_dev.php : 在我的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);
What I'm I doing wrong? 我做错了什么?
as the comment 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.
remove this: 删除此:
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.');
}
this is just checking that your IP address is allowed. 这只是检查您的IP地址是否被允许。 And allowed IP's are contained in this array array('127.0.0.1', 'fe80::1', '::1')
. 允许的IP包含在此数组array('127.0.0.1', 'fe80::1', '::1')
。
NOTE 注意
in prod env you'll need to point to app.php
not app_dev.php
在prod env中,您需要指向app.php
而不是app_dev.php
EDIT 编辑
in order to switch to PROD
env, run this command: 为了切换到PROD
env,请运行以下命令:
php app/console cache:warmup --env=prod --no-debug
--env=prod
will provide to point to app.php
instead of app_dev.php
--env=prod
将提供指向app.php
而不是app_dev.php
--no-debug
will exit the debug mode like it won't show the Symfony debug bar in the browser.. --no-debug
将退出调试模式,因为它不会在浏览器中显示Symfony调试栏。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.