PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, January 11, 2022

[FIXED] Run Symfony app on shared hosting not working

 January 11, 2022     cpanel, php, shared-hosting, symfony     No comments   

Issue

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?


Solution

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


Answered By - Arleigh Hix
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing