Running Laravel on shared hosting subdomain

Running Laravel 5 on a shared host subdomain (I use Vidahost) is a little daunting because Laravel requires the web root to point to the /public folder and generally with a subdomain the website root is the root folder that is created for you.

My solution was to create a directory in the subdomain root folder and copy all the code into there. I then copied the contents of the /public folder into the subdomain root folder and edited index.php.

The two require lines need modifying to remove the ‘..’ characters and replace with the actual path.

//require __DIR__.'/../bootstrap/autoload.php';
require __DIR__.'/mysubdirectory/bootstrap/autoload.php';

It’s not pretty but it worked OK.

The little application I wrote is to help with non-verbal reasoning tests, to memorise the numeric equivalents of the alphabet: Alphabet to Numbers.

Folder structure for running Laravel from site root folder
Folder structure for running Laravel from site root folder

One Reply to “Running Laravel on shared hosting subdomain”

  1. Isn’t it better to avoid shared hosting? Since it has serious drawbacks regarding security and performance, a VPS, like DigitalOcean, is a better option. If a person doesn’t have sysadmin skill to start a DO droplet, then they can instead use managed platform, like Cloudways, to setup Laravel on DO server.

Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA - answer the question below to prove you are human *