Setting up Laravel on Dreamhost VPS.

     

I inevitably google these things in advance so here’s my chance to pay it forward. The good news is it’s incredibly easy.

Set up PHP 7.1 as the command-line binary:

  1. Create a fully-hosted, choosing your VPS as the destination server. By default it’s going to set the web directory to /home/username/{domain} and you’ll want to append /public to the end of that. Use (or create) a user with shell access, the default is SFTP only. Make sure you set the PHP version to 7.0 or 7.1 if you’re using Laravel 5.3 or later. I’m using 7.1 for these examples.
  2. That’ll take 5 or 10 minutes to get set up, and then it’ll email you with the address to use to SSH in.
  3. If you do a php -v you’ll notice that 5.6 is the default binary used (at the time of this writing). Change it to 7.1 by doing the following:
    export PATH=/usr/local/php71/bin:$PATH
    . ~/.bash_profile

Now your php -v should show 7.1.

Enable PHAR:

  1. nano ~/.php/7.1/phprc
  2. Add the following 2 lines and save:
extension = phar.so
suhosin.executor.include.whitelist = phar

Install Composer:

  1. mkdir -p ~/.php/composer
  2. cd ~/.php/composer/
  3. curl -sS https://getcomposer.org/installer | php
  4. mv composer.phar composer
  5. chmod +x composer
  6. export PATH=~/.php/composer:$PATH

Install Laravel:

  1. rm ~/{domain}/* (Composer won’t install anything to a non-empty directory.)
  2. cd ~
  3. composer create-project --prefer-dist laravel/laravel {domain}

Composer will then do its thing and after a little while, you’ll be finished. Check your website and you should see the Laravel splash screen.

comments powered by Disqus