Drupal guide
Drupal is a free and open-source content management system. Learn how to install and run Drupal on fortrabbit.
This is work in progress. We are still learning about Drupal. Let us know if something is odd.
# Get ready
It's assumed you've already created a new app and chose Drupal in the software template. If not: You can do so in the fortrabbit dashboard. You should have a local PHP development environment running on your local machine. Drupal has good backward compatibility and this guide should work for Drupal 9, 10, and 11. We recommend following the official Drupal installation guide to install Drupal locally first. Here is an idea how to do it with Composer:
# Create a new Drupal project with Composer composer create-project drupal/recommended-project my-drupal-site # Navigate to the project directory cd my-drupal-site # Install Drupal via Composer (alternative method) composer installshell
We recommend to use DDEV for local development. See their Drupal quick start.
# Root path
If Drupal was chosen or detected when creating the environment in the dashboard, 'web' was pre-selected as the root path. You can configure the root path in the dashboard.
# MySQL configuration
If Drupal was chosen or detected, required environment variables for the MySQL connection will be pre-populated.
# Deployment
Drupal supports Git and Composer workflows. Deploy via GitHub using our GitHub integration via git push. SSH/SFTP code access is also available too.
# Git ignores
By the time of this writing, it appears that Drupal does not ship with a standard .gitignore file. It's suggested to create such a file on the root directory of the project, matching your requirements.
- drupal.org/project/drupal_cms/issues/3500134 - Issue
- github.com/github/gitignore/blob/main/Drupal.gitignore - Example
# Git deployment workflow
- Set up your local Drupal project with Git
- Deploy to GitHub
- Install the fortrabbit GitHub App
- Connect your GitHub repository to your fortrabbit app environment
- Push to deploy automatically
The build commands will automatically run composer install during deployment when using our Drupal software template.
# Initial deployment steps
- Create your Drupal project locally
- Initialize Git and make your initial commit
- Push your code to your GitHub repository
- Deploy to fortrabbit via GitHub integration
- Import your database (see MySQL section below)
- Run Drupal installation via SSH or upload your database
# Files and uploads
Drupal stores uploaded files in the sites/default/files directory by default. For production sites, consider:
# Using rsync for file management
You can use rsync to sync files between your local development and fortrabbit:
# Download files from fortrabbit to local rsync -av {{app-env-id}}@ssh.{{region}}.frbit.app:web/sites/default/files/ ./web/sites/default/files/ # Upload files from local to fortrabbit rsync -av ./web/sites/default/files/ {{app-env-id}}@ssh.{{region}}.frbit.app:web/sites/default/files/shell
# Environment variables
When Drupal is detected or chosen, important environment variables for connecting to the database should be pre-configured. Set these environment variables in your fortrabbit dashboard:
# Additional ENV vars
DRUPAL_HASH_SALT: A unique hash salt for your Drupal installationAPP_URL_HOST: Your domain name (automatically set)- Other custom variables as needed for your modules
# Logs
Check your Drupal logs via the admin interface at /admin/reports/dblog or access system logs in the fortrabbit dashboard.
# Manual database settings
Drupal uses a settings.php file to configure database connections. When using our software template, the database configuration is automatically handled via environment variables. Your web/sites/default/settings.php should include:
// Database configuration using fortrabbit environment variables $databases['default']['default'] = [ 'database' => $_ENV['MYSQL_DATABASE'], 'username' => $_ENV['MYSQL_USER'], 'password' => $_ENV['MYSQL_PASSWORD'], 'host' => $_ENV['MYSQL_HOST'], 'port' => $_ENV['MYSQL_PORT'] ?? '3306', 'driver' => 'mysql', 'prefix' => '', 'collation' => 'utf8mb4_general_ci', ];php
For your local development setup, you can create a settings.local.php file with your local database credentials.