Setting up a Laravel application on a Dreamhost shared hosting account - Updated for Laravel 5

December 15, 2015

A ways back I wrote about how to set up Laravel on a Dreamhost shared hosting account. I've still been using Laravel Forge and Digital Ocean for all of my production deployments, but a shared host is really nice for a quick prototype or low-budget application.

This post will list some revised steps for getting a Laravel 5 application deployed quickly on a Dreamhost shared hosting account.

To view my earlier post, click here. Read on for updates to the instructions for Laravel 5.

Sign Up

As before, you need to sign up for a dreamhost account. When you're done signing up, visit your Dreamhost panel.

PHP Mode

The first change from the Laravel 4 instructions is to make sure that "PHP Mode" is set to PHP 5.5 or above. At the time of this writing Dreamhost provides support for 5.6, which I would recommend using.

When logged in to your dashboard, on the left panel select "Domains" and "Manage Domains", and on the screen that comes up click on "Add Hosting to a Domain / Sub-Domain".

Dreamhost Manage Domains

And be sure to choose 5.6.x for "PHP Mode".

PHP 5.6 phar extension

To be able to use the composer dependency manager on Dreamhost you must instruct the php 5.6 executable to use the phar extension that is not enabled by default.

mkdir -p ~/.php/5.6
cd ~/.php/5.6
echo "extension = /usr/local/php56/lib/php/extensions/no-debug-non-zts-20131226/phar.so" >> phprc
echo "extension = fileinfo.so" >> phprc

Composer

Installing 3rd-party dependencies is the same for Laravel 5 as it was for Laravel 4, but it's important to pull in the composer executable with Dreamhost's proper php version.

Once you have the Laravel 5 project checked out on your Dreamhost shared host you may install a local composer instance. Note that this command is slightly changed from composer's instructions to accommodate Dreamhost's php 5.6 executable:

cd [my-git-repository]
curl -sS https://getcomposer.org/installer | php-5.6

Now you may pull in all of the composer dependencies:

php-5.6 composer.phar install

Environments

Environments are slightly different than they were in Laravel 4. You no longer have to define environments in your code and create special environment folders. Instead, create a .env file which will live in your project root. You may copy the .env.example that is included with the Laravel 5 distribution and change the APP_ENV to whatever you want. For prototype sites, local is fine. Just be sure to set the database connection parameters in this file. Your .env file contains sensitive database connection parameters so it is very important to never add this file to source control.

Migrations

Once you have your database set up as outlined in the Laravel 4 post, you may migrate your schema. Migrations are exactly the same, but be sure to use php 5.6 when running them.

cd [my-git-repository]
php-5.6 artisan migrate 

Besides that, the instructions are mostly the same as they were with Laravel 4, so at this point you should be able to visit your working app at http://my.domain.com!

Conclusion

Don't forget to review the previous post for setting up a Laravel 4 instance on dreamhost. Aside from what was outlined here for Laravel 5 everything else is the same.

Dreamhost provides a good way to get a Laravel site live without a high level of cost. Once you have a Dreamhost account you can use one of your unlimited number of subdomains to host a new application for prototyping, validating an idea, client demos, or just about anything.

If you are thinking about signing up for Dreamhost, you can use my dreamhost coupon or click any of the other Dreamhost promo code links on this page. You will get a $90 discount which gives you hosting for $2.45/month.

 

comments powered by Disqus

About This Site

This site was designed by We Are How.

This site is powered by Sculpin static site generator and the source is available here.

Yotta = 10^24, or 1 000 000 000 000 000 000 000 000, the largest metric prefix.


Contact

Get in touch to find out how we can help you refine your vision and implement a dynamite product that will help your business grow. Our agile product development process is thoughtfully designed to give clients ongoing feedback and visibility from project inception to completion.