I want to run my Symfony5 app on shared hosting (cpanel). On the shared hosting I have the following folder structure:
/
/public_html
/symfony
When I put the whole project in the public_html folder, it works from https://domain.abc/public but that is not the way it should work as the the other symfony folder shouldn't be visible.
I've put the file from symfony/public folder to the public_html folder The index.php (with 755 rights) in the /public_html folder is like this:
<?php
use App\Kernel;
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\ErrorHandler\Debug;
use Symfony\Component\HttpFoundation\Request;
require dirname(__DIR__).'/../symfony/vendor/autoload.php';
(new Dotenv())->bootEnv(dirname(__DIR__).'/../symfony/.env');
if ($_SERVER['APP_DEBUG']) {
umask(0000);
Debug::enable();
}
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
But i get a blank screen when going to https://domain.abc
Any ideas what i'm doing wrong?
CodePudding user response:
In this situation it is best to have /public_html
be a symlink pointing to /symfony/public
.
Alternatively, if your hosting provider allows it, you may be able to re-configure the root directory for your domain to be /symfony/public
.
In either case, start by removing /public_html
and undo any changes made in /symfony/public/index.php
.
If you have made no changes within /symfony/*
, then you only need to run the commands below to create a symlink:
rm -r -f /public_html/
ln -s /symfony/public /public_html