Craft CMS Deployment
A bash script for zero-downtime Craft CMS deployment to run on production servers. Inspired by the Capistrano routine. This script is still beta! Please use it very carefully!
- Copy the files to your project folder on the server.
.envand enter your credentials.
chmod +x deploy.sh setup.shto set execution permissions.
./setup.shto create the initial folders.
- Upload your
- Setup a webhook to call the scripts or run
Following files and folders must be added to
.gitignore to make the symlinks work:
This script is still beta. Please use it carefully and not on large and heavy projects. Or do, whatever, your call.
What does it do?
Creates the necessary
shared/web folders on the server. Run this script first.
./craft backup/dbto create a database backup first.
- Creates a release folder in
releasesnamed by the current timestamp, i.e.
- Clones your git repo into this folder.
composer installto install Craft CMS.
- Creates symlinks for shared folders and files.
- Creates a symlink from the
currentfolder to the newest release.
- Deletes old releases and keeps max. 5 releases.
- Deletes oldest backup and keeps max.
- Restarts PHP to delete symlink cache (optional)
Optional webhook script to run the bash scripts and creates a logfile. You can use your own scripts of course.
What does it not do?
This script doesn't do rollbacks. Although it doesn't re-link the
current folder when the script throws an error. If an error occurs the previous release will still be the current one.
Why should I use it?
When you don't want to spend money on deployment services and tools like Capistrano are just too much to set up for smaller projects.
.envfor better config handling.
Delete releases folder if an error occurs during deployment. Delete not only the oldest release folder, but multiple release folders if there's more than 5 folders (occurs if an deployment fails).(Corrupt folders will be removed if installation fails) Integrate
deploy.shand/or create flags.