How to host a Laravel (4 and 5) application on a VestaCP account.

I wanted to test out VestaCP this week as I’ve heard good things about it and as currently Sentora is missing DKIM signing and various other nice things that Vesta has (and I’ve not got the time to implement them) I thought I’d test it out.

Being a primarily a PHP developer, my go-to framework of choice for most of my applications these days is Laravel, I have a number of various virtual machines that I host my sites and applications on and normally I use my “Conductor” tool to host dedicated applications on one of my DigitalOcean VM‘s but I wanted to try out and just see how easy it was to get one of my Laravel 4 (and a Laravel 5) application hosted and running on Vesta.

Firstly as you’ll soon notice, Vesta uses a folder inside the root of the website folder named as follows: ‘/web/yourwebsite.com/public_html’, this is where the web server will serve your web requests from and is accessible to the public – knowing this, we need to separate the contents of the Laravel’s /public directory and the rest of the application files, my solution is as follows….

  1. Upload the contents of your Laravel’s public directory into the /web/yourwebsite.com/public_html directory.
  2. Open up  /web/yourwebsite.com/public_html/index.php and change this line:
    require __DIR__ . '/../bootstrap/autoload.php';

    to

    require __DIR__ . '/../private/app_data/bootstrap/autoload.php';

    and

    $app = require_once __DIR__. '/../bootstrap/start.php';

    to

    $app = require_once __DIR__ . '/../private/app_data/bootstrap/start.php';

    Save the file and let’s move on…

  3. Create a new directory called ‘app_data‘ under /web/yourwebsite.com/private.
  4. Upload ALL files and folder from your Laravel project’s root directory except the ‘public’ directory.
  5. Edit the paths.php file found under /web/yourwebsite.com/private/app_data/bootstrap and change this line:
    'public' => __DIR__ . '/../public',

    to

    'public' => __DIR__ . '/../../public_html',

    Save the changes!

Now if all went well you should now see your Laravel application running just fine!

Remember, if the page is blank or you’re getting the ‘Something went wrong’ message, check that you have the correct permissions set and that you’ve updated any database connection details etc.

I’ve also noticed that it’s best to set the ‘url‘ option correctly inside your app.php file, like so:

'url' => 'http://yourdomain.com',

Without this I had some issues with some pages appearing when using the HTML and URL helper classes within Laravel.

Share
 

One thought on “How to host a Laravel (4 and 5) application on a VestaCP account.

Comments are closed.