Pregunta

I'm having difficulties deploying my symfony2 project to 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.
I've exported my local db and inserted it on the server.
I've changed the settings in my 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:

You are not allowed to access this file. Check app_dev.php for more information.

In my 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?

¿Fue útil?

Solución

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. And allowed IP's are contained in this array array('127.0.0.1', 'fe80::1', '::1').

NOTE

in prod env you'll need to point to app.php not app_dev.php

EDIT

in order to switch to PROD env, run this command:

php app/console cache:warmup --env=prod --no-debug

--env=prod will provide to point to app.php instead of app_dev.php

--no-debug will exit the debug mode like it won't show the Symfony debug bar in the browser..

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top