Update and upgrade Craft CMS

Published

Updated

Update Craft CMS in the local development environment, test it there, then deploy with git. The post-deploy commands run the migrations on fortrabbit.

Update locally first

Updates go into the local development environment first, get tested there, and reach fortrabbit with the next deployment. The software template sets CRAFT_ALLOW_UPDATES and CRAFT_ALLOW_ADMIN_CHANGES to false, so the control panel on fortrabbit offers no updates.

Update Craft and all plugins locally in the control panel under Utilities → Updates → Update all, or in the terminal:

# List the available updates
php craft update

# Update Craft and all plugins
php craft update all
shell

See the Craft update docs for single plugins and version constraints.

Deploy the update

Commit composer.json, composer.lock and config/project, then git push. The build commands run composer install, and the template sets these post-deploy commands:

php craft migrate/all
php craft project-config/apply
php craft clear-caches/all
shell

They do nothing when no changes are pending. Change them in the deployment settings of the environment or in the deploy file.

After an upload with SFTP or rsync, no post-deploy commands run. Apply migrations and project config over SSH with php craft up.

Upgrade to a new major version

A major upgrade, such as Craft 4 to Craft 5, raises the requirements. Craft 5 needs PHP 8.2 or newer and starts from the latest Craft 4 release. A Craft 3 project goes to Craft 4 first, with the Craft 4 upgrade guide.

  1. Follow the Craft 5 upgrade guide locally, including the plugin updates and the Craft 5 Upgrade utility.
  2. Set the environment to a PHP version Craft 5 supports, see PHP version upgrade.
  3. Create a backup of the environment.
  4. Add the temporary CRAFT_DB_CHARSET and CRAFT_DB_COLLATION ENV vars the guide asks for, then deploy. The post-deploy commands run the migrations.
  5. Remove the two ENV vars and run php craft db/convert-charset over SSH.

A plugin without a release for the new major version blocks the upgrade, see Craft CMS plugins.

Frequently asked

How do I upgrade Craft CMS on fortrabbit?

Upgrade locally with the official Craft upgrade guide, set the environment to the PHP version the new major version needs, back up the database, then deploy with git. The post-deploy commands run the migrations and apply the project config.

#
Why is the update button missing in the Craft control panel on fortrabbit?

The Craft CMS software template sets CRAFT_ALLOW_UPDATES to false, which removes updates from the control panel. Update locally and deploy that state instead.

#

Written by humans and AI in collaboration.

AI use & editorial processEdit on GitHub ↗