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. This means you can run your Craft locally and remotely 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 if 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 already be set. On fortrabbit the environment variables are seeded from the ones set in the Dashboard (not from the .env file). If you chose Craft in the Software Preset when creating the App, all ENV vars at fortrabbit will already be pre-populated. If not, see here.
Configuration settings¶
Please include the following settings in the settings file located in config/general.php
:
return [
'siteUrl' => App::env('PRIMARY_SITE_URL') ?: '@web',
];
The file contains other settings as well: keep those. For more details and options, check out our Craft CMS tuning guide.
Next steps¶
Craft CMS is configured to run locally and is also ready for fortrabbit. Next you can deploy it with Craft Copy. Don't forget our Craft tuning guide afterwards.