Running Craft on Laravel Forge

Last week I moved this site to Laravel Forge - mostly because I wanted to try it out but also because I needed to use a couple of plugins that wouldn’t run on my current VPS, which is still running PHP 5.3 ... don’t shoot me!

I thought I would write up a quick how-to as the only post I could find (here on the awesome Matt Stauffer’s blog) referenced the auto-installer which has since been removed from Forge.

Add a server

First up add your Server Provider details (I use Linode) from the Servers dashboard, then add a server and wait for it to build - it only takes a couple of minutes.

Whilst you wait you can watch the event log that shows you whats going on under the hood.

You should also go check your email at this point and look for one from Forge telling you your server has been provisioned - this will contain all the access credentials for the server and database. Make a note of these!

Add a site

Once it’s done rebooting you can go into that server (click the pencil in the manage column of the servers list) and add a site. Add your domain and set the Web Directory to whatever your public folder in Craft is set to, by default this will be public in both Forge and Craft.

At this point you can also delete the default site which we won’t need.

You should now have something like this:

Next, press manage, add your repo details and authenticate your git host if you haven’t already.

Before you deploy, press “Edit Deploy Script” and double check the contents - mine looked like this at the time of writing:

Unless you have reason not to, remove the composer and artisan lines, save and click “Deploy Now”.

If you want the project to auto-deploy every time you push to master click “Enable Quick Deploy”, then you can forget all about deploying and just push your changes.

Next you will need to create the Craft storage folder - I did this by logging into the server over SSH using the access credentials Forge sent me in that email earlier. Simply run the following two commands:

$ sudo mkdir /home/forge/
$ sudo chmod -R 777 /home/forge/

At this point you probably want to point your domain at the server and wait for it to resolve, but if you already have then its time to do some other fun things!

Tweak nginx

UPDATE: I forgot to include this originally but I also had to swap the try_files declaration in the default location / block for this:

try_files $uri $uri/ /index.php?p=$uri&$args;

That got all the URLs working properly!

Note that to edit your nginx config you need to scroll to the bottom of the site edit screen and under edit files choose the nginx configuration option:

Forge will automatically reload nginx when you hit save, so you don’t have to keep going back to the server page and reloading it from there like I kept doing ...

Fix the fonts

For some reason the fonts don’t load in the control panel to begin with, I think it’s because Craft uses php to load the file and present it at the /admin/resources/... route - either way, after much digging and thanks to the comments on this SE post, I added the following below the location ~ \.php$ block in the nginx configuration file:

location ~* \.(?:ttf|svg|ttc|otf|eot|woff|woff2)$ {
    try_files $uri /index.php?p=$uri&$args;

If you also need your fonts on the front end to work with a CDN then you’ll want to enable CORS for them, I simply added this to that same block:

add_header "Access-Control-Allow-Origin" "*";


This is amazingly easy on Forge thanks to LetsEncrypt - literally just press the button and once it’s finished activate it.

The wonderful thing here is that Forge automatically renews your certificate and sorts out all the nginx config for you.

Thats it! Hopefully that works for some other people out there - comments and improvements welcome! Especially when it comes to the nginx parts, I’m a total newbie at that ;)

Josh Angell

Josh Angell

I build custom software for Craft CMS.
Need a hand with something? Get in touch!
Or you can find me as @josh_angell on Twitter.