after working with my project on dev mod, i found some problems with prod on OVH.
it shows me a blank page ! i try to follow the issue on app.php and i found that the problem persist with the execution of $response = $kernel->handle($request); and it don't logging on prod.
so when i change the row on app.php : $kernel = new AppKernel('prod', false); with $kernel = new AppKernel('dev', false); it works well !!!
here's my app.php
<?php
/*
* This file is part of the Sonata package.
*
* (c) Thomas Rabaix <thomas.rabaix#sonata-project.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
umask(0000);
require_once __DIR__ . '/../app/bootstrap.php.cache';
require_once __DIR__ . '/../app/AppKernel.php';
//use Symfony\Component\HttpFoundation\Request;
// if you want to use the SonataPageBundle with multisite
// using different relative paths, you must change the request
// object to use the SiteRequest
use Sonata\PageBundle\Request\SiteRequest as Request;
$request = Request::createFromGlobals();
$kernel = new AppKernel('prod', false);
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
EDIT :
in dev and prod local mode test it works well with
php app/console cache:clear --env=prod --no-debug
php app/console assets:install web_directory
php app/console assetic:dump web_directory
should i add or install php5 on my project ?
EDIT :
my project contains : sonata-project, fosUserBundle,etc...
EDIT
the problem was on config_prod.xml
doctrine:
orm:
entity_managers:
default:
metadata_cache_driver: apc
query_cache_driver: apc
result_cache_driver: apc
intil now after it return an error 500 ! why ? because of apc was not enabled !
so my question how to enable apc on OVH pro !
Go to web/config.php and comment ot the following lines:
if (!in_array(#$_SERVER['REMOTE_ADDR'], array(
'127.0.0.1',
'::1',
))) {
header('HTTP/1.0 403 Forbidden');
exit('This script is only accessible from localhost.');
}
That will enable the config.php to be called from "extern". Don't forget to remove the comments after you've checked everything.
If you have console access on the production server, enter the root directory of your project and call php app/check.php to run the checks on the console.
Related
I know that this is not the first post about this question, but I do it because others answers didn't solve my problem.
I tried the basic :
$kernel = new AppKernel('prod', true);
But this is not the good way to do it because I still have Symfony errors...
I don't know how to rewrite errors pages :
http://le-blog-etudiant.fr/blablabla
Do you know if this Symfony error is caused by the fact that my website is still in dev mode or because my error.html.twig page doesn't work ?
EDIT 1 :
I'm using app.php on my site, I set $kernel = new AppKernel('prod', false); and I did the command : php bin/console cache:clear --env=prod but it still display Symfony's errors
Because you need to do this :
$kernel = new AppKernel('prod', false);
Here is the constructor of AppKernel :
/**
* Constructor.
*
* #param string $environment The environment
* #param bool $debug Whether to enable debugging or not
*/
public function __construct($environment, $debug)
Permission denied here showing your problem http://le-blog-etudiant.fr
You have to give permission
chmod 777 -R var/cache
chmod 777 -R var/cache/*
Other problems then we will check...
The problem is I see trace error pages in production mode, in Symfony app.
I have this in app.php:
$kernel = new AppKernel('prod', true);
And I have done:
php app/console cache:clear --env=prod
Ok, I was completely wrong! The purpose of the second parameter in $kernel = new AppKernel('prod', true); is to enable/disable the debug mode. You can read the doc here: https://symfony.com/doc/current/configuration/environments.html
The issue was solved by setting to false the debug mode.
I downloaded it with composer. Tried to run with the PHPStorm's built in server and it does not load the toolbar (404).
Then I tried to run it with Apache, I copied my project to /var/www/html and then I went to http://localhost/symfony_app/web/app_dev.php in the browser.
What is strange is that it partially shows the source code (but without line breaks):
loadClassCache(); $request = Request::createFromGlobals(); $response = $kernel->handle($request); $response->send(); $kernel->terminate($request, $response);
This file (complete) has the following source code:
<?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#checking-symfony-application-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'], ['127.0.0.1', 'fe80::1', '::1']) || php_sapi_name() === 'cli-server')
) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}
/**
* #var Composer\Autoload\ClassLoader $loader
*/
$loader = require __DIR__.'/../app/autoload.php';
Debug::enable();
$kernel = new AppKernel('dev', true);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
In the Apache error logs there is nothing, just restarts.
The app works OK with Symfony's built-in server, in port 8000
The same thing just happened to me on a new vagrant setup I made. Weirdest thing I've seen. It turns out I had installed php5, but not completely. I needed to install specifically the libapache2-mod-php5 package in Ubuntu. Running this installed it for me in Ubuntu:
sudo apt-get install php5
I don't know what system you're running on but it might be a missing php package like this that's the culprit.
if you have apache2 and php installed and got this issue enable
mod_rewrite
you can do that with:
a2enmod rewrite
in your terminal and restard apache
I'm trying to make my symfony 3.0 app capable to work with multiple kernel.
real aim : Multiple applications in one project
Generally everything is OK. I edited bin/console it's content exactly as the following. It works exactly and results what I need via php bin/console --app=api
But when I execute composer install bin/console throws the Exception naturally it doesn't knows about --app parameter. I want to make something like composer install --app=api and desired behaviour it would pass the parameter to bin/console I checked documentation and almost every pixel of the internet couldn't find a solution.
#!/usr/bin/env php
<?php
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputOption;
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);
set_time_limit(0);
/**
* #var Composer\Autoload\ClassLoader $loader
*/
$loader = require __DIR__.'/../apps/autoload.php';
$input = new ArgvInput();
$env = $input->getParameterOption(array('--env', '-e'), getenv('SYMFONY_ENV') ?: 'dev');
$app = $input->getParameterOption(array('--app', '-a'));
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'prod';
if ($debug) {
Debug::enable();
}
switch ($app) {
case 'api':
$kernel = new ApiKernel($env, $debug);
break;
case 'frontend':
$kernel = new FrontendKernel($env, $debug);
break;
default:
throw new \InvalidArgumentException("[--app|-a=<app>] app: api|frontend");
break;
}
$application = new Application($kernel);
$application->getDefinition()->addOptions([
new InputOption('--app', '-a', InputOption::VALUE_REQUIRED, 'The application to operate in.'),
]);
$application->run($input);
You can use composer install --no-scripts to prevent automatically running app/console after installation.
Or you can remove the the bin/console commands from the scripts section in your composer.json altogether, which probably makes more sense. See https://github.com/symfony/symfony-standard/blob/master/composer.json#L33-L34
Or you can use environment variables instead of arguments.
I have problem with my Symfony2 project. I created new bundle using console, but default controller is avalible only from dev environment level.
For
http://localhost/myproject/web/app_dev.php/hello/ZaqU
everything works fine, but for
http://localhost/myproject/web/app.php/hello/ZaqU
i'm redirecting on
http://localhost/myproject/web/hello/ZaqU
and then i getting only page 404.
This is new bundle and i didn't changed default files so I don't understand why it doesn't work. Files:
/* #FILE: app/AppKernel.php */
$bundles = array(
//...
new ZaqU\TestBundle\ZaqUTestBundle(),
);
.
/* #FILE: app/config/routing.yml */
ZaqU_test:
resource: "#ZaqUTestBundle/Resources/config/routing.yml"
prefix: /
Have you tried to clear your prod cache? Run the following command in the console:
./app/console cache:clear --env=prod
You might have not enabled the production environment in web/app.php. Change the false into true.
$kernel = new AppKernel('prod', true);
Hope this helps.
Cheers!