Deploying TYPO3
Using Git and Composer on the webserver
- Check if Composer is available on the production server. If it is not available consider to use the latest composer.phar.
- Keep all development related files in a Git repository.
- Clone this repository on your production server.
- Copy the database to the production server.
-
Install TYPO3 without dev dependencies on the production server:
composer install --no-dev
Copied! - Compare the database
- Fix file permissions
- Clear caches
If you do a composer install
directly on the production server you might
experience some problems. For this reason some developers and administrators
decide not to do it:
- There can be several minutes of downtime even if the installation goes smoothly.
- The installation might fail if some packages are not available.
- You might accidentally call
composer update
as is often done during development and do unintended, untested updates. - You might omit the
--
option and accidentally install packages that are not save to be used during production.no- dev
Some of these problems can be fixed by using a symlink strategy where one directory is running on production and another one is being updated.
Build locally and copy all files and symlinks to the server
- Build the local environment (installing everything necessary for the website)
- Run
composer install --
to install without development dependenciesno- dev - Copy files to the production server
- Copy the database to the production server
- Compare the database
- Fix file permissions
- Clear caches
There can be several problems with this strategy:
- Copying files or unzipping files can be slow, there can be several minutes of downtime.
- A TYPO3 installation depends on symlinks. Make sure these symlinks are preserved during copying and or compressing files.
Automatic deployment
There are multiple tools that can be used to automate deployment. Read more about it: TYPO3 Explained, automatic deployment.
Deployment Automation
A typical setup for deploying web applications consists of three different parts:
- The local environment (for development)
- The build environment (for reproducible builds). This can be a controlled local environment or a remote continuous integration server (for example Gitlab CI or Github Actions)
- The live (production) environment
To get an application from the local environment to the production system, the usage of a deployment tool and/or a continuous integration solution is recommended. This ensures that only version-controlled code is deployed and that builds are reproducible. Ideally setting a new release live will be an atomical operation and lead to no downtime. If there are errors in any of the deployment or test stages, most deployment tools will initiate an automatic "rollback" preventing that an erroneous build is released.
One widely employed strategy is the "symlink-switching" approach:
In that strategy, the webserver serves files from a virtual path releases/
which consists of a symlink releases/
pointing to the latest deployment ("release"). That symlink is switched after a new release has been successfully prepared.
The latest deployment contains symlinks to folders that should be common among all releases (commonly called "shared folders").
Usually the database is shared between releases and upgrade wizards and schema upgrades are run automatically before or shortly after the new release has been set live.
This is an exemplatory directory structure of a "symlink-switching" TYPO3 installation:
-
-
fileadmin
-
-
charset
-
lock
-
log
-
session
-
-
-
-
current -> ./
(symlink to current release)release1 -
-
-
typo3conf
-
fileadmin -> ../../../
(symlink)shared/ fileadmin -
index.
php
-
-
-
build
-
cache
-
charset -> ../../../
(symlink)shared/ var/ charset -
labels
-
lock -> ../../../
(symlink)shared/ var/ lock -
log -> ../../../
(symlink)shared/ var/ log -
session -> ../../../
(symlink)shared/ var/ session
-
-
vendor
-
composer.
json -
composer.
lock
-
-
The files in shared
are shared between different releases of a web site.
The releases
directory contains the TYPO3 code that will change between the release of each version.
When using a deployment tool this kind of directory structure is usually created automatically.
The following section contains examples for various deployment tools and how they can be configured to use TYPO3: