Ozzie Neher

Developing for the Web

Laravel Server Setup Guide 2016

October 9th, 2016

Hosting Laravel can be a pain in the ass. A big pain in the ass. Hopefully this will help out with all of those 500 errors that you can't seem to figure out.

My specific setup here is going to be a Digital Ocean $5 Ubuntu 16.04 (Referral Link) droplet.

Step 1. SSH into your server

ssh me@myip.com

2. Put your application on your server

This step can be modified a bit to your personal preference, but I like to have all of my projects in /home/MYUSER/www/. So I'll clone my repo here.

git clone GITREPOURL /home/ozzie/www/example

Don't forget to composer install your dependencies.

3. Folder permissions

Next, cd into the parent directory of the project. In my case, this would be /home/ozzie/www.

cd /home/ozzie/www

Here, we're going to run

sudo chmod 755 -R example

Just replace example with your project folder. Here is a great article on Unix folder permissions.

Now we need to give the server access to the storage/ directory.

sudo chmod 775 -R example/storage/

sudo chmod -R o+w example/storage/

4. The public folder

Again, this is personal preference but I'm going to include it anyway. I like to symlink my project's public folder to the /var/www path so I can point my web server there instead of my home folder.

sudo ln -s /home/ozzie/www/example/public/ /var/www/example

It's important that you leave the trailing slash off of the last argument, and that no folder already exists at /var/www/example.

Boom, bam, thank you ma'am. That's it, that's all. Just make sure to point your web server to that new symlinked public folder in /var/www/example and you'll be all set!