Setup Craft CMS

How to configure Craft CMS to run locally AND on fortrabbit.

Get ready

Make sure to have followed our guides so far. You should have already installed Craft locally and deployed it your fortrabbit App.

Craft configuration on fortrabbit

Craft 3 uses modern .env style configuration, learn more about the concepts here. In result, you can run your Craft locally and on remote without code or configuration file changes. Locally, your .env file will be modified and read.

Security key

The mandatory Craft CMS security key has to be shared among all environments. We recommend to use your local security key as the master key. When you used Composer to install, that key was shown at the end of the installation. If not, open your local (hidden) .env file from the root folder of your project and find a line that looks like this:

SECURITY_KEY=69UzZSEquw9E7RdCyRRTRb1lxe7h0EPd

It will contain a value when you have installed Craft 3 correctly on your local machine. Copy that line. Go to the App's ENV vars settings in the Dashboard and paste that line. Here is the direct link:

That ENV var is already set. Just replace it with your local one. Also see the official Craft guide on that topic to learn about the different ways to create the key.

Database setup

TLDR: No need to configure the MySQL database connection for fortrabbit, it should be set. On fortrabbit the environment variables are getting seeded from the ones set in the Dashboard (not from the .env file). When you have chosen Craft in the Software Preset while have creating the App, all ENV vars at fortrabbit are already pre-populated. If not, see here.

Database synchronization

Now, your local Craft installation should already have created a MySQL database with a few tables in it. The fortrabbit database, on the other side, is still empty. Now, export your local database and import it to the fortrabbit remote. Head over to our MySQL export & import guide to learn how to access the database on fortrabbit and export/import tables.

PRO TIP: You will probably often synchronize development and production databases. We have developed a handy command line tool: Craft Copy to speed that up. It works like this:

# Sync database up (local ⟶ fortrabbit)
$ php craft copy/db/up

# Sync database down (local ⟵ fortrabbit)
$ php craft copy/db/down

Next steps

Craft CMS is configured to run locally and is also ready for fortrabbit. Next you can deploy it with Git or upload it by SFTP. Don't forget our Craft tuning guide afterwards.

Further readings

Craft CMS

Install guides

Develop & deploy

Teamwork

Platform

Stacks

Need individual help?
Learn about Company plans ›
Looking for an old article?
See the full list of articles ›
Found an error?
Contribute on GitHub ›