Craft CMS Logo

Setting up Craft CMS 3 on Nanobox

Oct 25, 2018 · 4 min read

Here @ we use a super swanky CMS to host all our brilliant coupon codes and vouchers — it’s called CraftCMS. If you haven’t heard of Craft CMS I’d go check it out, it’s like the daddy of Wordpress. We’ve used Craft to build numerous sites, you can pull it, tear it and play with it so to speak. In this tutorial, we’re going to set you up on Nanobox (an epic SaaS solution for dev-ops) which makes handling CraftCMS oh so much easier, there are a few caveats but we’ll make sure we mention them as we go.

Getting Prepared

You should have a Nanobox account (which you can register here)
Medium amount of time
Terminal (Mac)
Some knowledge of PHP (but not essential)
Some knowledge of Liquid Templating (but not essential)

The Setup

We’re going to set this baby going, let’s dive in.

  1. Go to Nanobox and Register an Account
  2. Download their Nanobox Client

Create a New Directory

This is where your Craft Install will live, as well as the folder to access your server through Nanobox, the name of your project is usually sufficient. (but it can really be whatever you want.) In the following line, we’re going to create a new directory and cd in.

mkdir nanobox-craft3 && cd $_

Create a boxfile.yml

“What’s in the box?!” you may ask, well, it tells nanobox what kind of server we’re wanting to build out or run. For CraftCMS we want to run it on postgres and have a good stable version of PHP. Below is a great start to a boxfile but there is a lot of possibilities here so do check out the docs.

Create a boxfile.yml file in the root of the folder you’ve just made.

engine: php
runtime: php-7.1
document_root: web
webserver: apache
- ctype
- pdo
- pdo_pgsql
- mcrypt
- mbstring
- json
- curl
- dom
- iconv
- imagick
- fileinfo

- session
- zip
- zlib

php: start-php
apache: start-apache
- storage
craft[error]: storage/logs/web.log
craft[stacktrace]: storage/logs/phperrors.log

image: nanobox/postgresql:9.5
image: nanobox/unfs:0.9

What this code is doing above is telling nanobox what to build, what extensions to add on and what database we’re wanting to run it on. Read more about it here.

Let’s start the local dev.

Before we go ahead and start the server, we should really add an alias to our server, we don’t want to be accessing every time we want to test our website, we really want to be going to mysuperproject.local instead. So let’s do just that in our terminal window.

(Be warned, don’t change it to your domain or you want be able to access it via the browser. e.g. if I owned I would set this to google.local instead so I can still access

# Add a convenient way to access the app from a browser
nanobox dns add local craft3.local

Let’s see if this beauty wants to purrrr for us. Go ahead and kick the servers off by entering the following command in your terminal.

# Start the dev environment
nanobox run

Let’s Install Craft

Now we’ve got that all running — finally. Let’s install CraftCMS and get our project going! We’re going to use something called composer which nanobox comes with automatically (sweet!). This is where a caveat comes in — Composer won’t let you create new projects inside directories that aren’t empty, so let’s create a new directory and cd into that so we can download and install CraftCMS. Enter the following lines into your terminal:

# Move into the /tmp directory
cd /tmp

# Install Craft 3 beta
composer create-project craftcms/craft craft -s stable

# Enable the dotglob shell option to interact with hidden files
shopt -s dotglob

# Copy Craft into your project directory
cp -a craft/* /app

# cd back into /app, your project directory
cd -

With this done, we now have all the files we need for CraftCMS accessible to us from any code editor such as Atom/Sublime or any others.

Updating our Database Config

Now Craft has downloaded, we just need to tell it where our database lives on Nanobox — it’s as easy as copy and pasting! Open config/db.php from your project folder with your code editor, and change it to the following:

return [
'driver' => 'pgsql',
'server' => $_ENV['DATA_DB_HOST'],
'user' => $_ENV['DATA_DB_USER'],
'password' => $_ENV['DATA_DB_PASS'],
'database' => 'gonano',
'schema' => 'public',
'tablePrefix' => '',
'port' => 5432

Let’s Start — it’s time.

Roll up, Roll up! It’s time to boot this bad boy up. Enter the following line into your terminal window:

# Start your app

Nanobox is handy, it’ll start apache and everything else for you all with this command. Just to re-iterate how to start a server it’s nanbox run and then php-server.

Install Craft

Remember we made those aliases before? Head to whatever your alias we set up before + /admin like below:


You should see that sweet sweet Craft install screen, follow the instructions and enjoy hacking!


Written by

Save money every day with the latest voucher codes and deals when you shop at your favourite stores. Only at 👍

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade