|
1 | 1 | .. include:: /Includes.rst.txt |
| 2 | + |
2 | 3 | .. index:: deployment, composer, production setup |
3 | 4 |
|
4 | 5 | .. _deploytypo3: |
5 | | -.. _deployment: |
6 | 6 |
|
7 | 7 | =============== |
8 | 8 | Deploying TYPO3 |
9 | 9 | =============== |
10 | 10 |
|
11 | | -.. _deployment-git-composer: |
12 | | - |
13 | | -Using Git and Composer on the webserver |
14 | | -======================================= |
15 | | - |
16 | | -* Check if Composer is available on the production server. If it is not |
17 | | - available consider to use the |
18 | | - `latest composer.phar <https://getcomposer.org/download/>`__. |
19 | | -* Keep all development related files in a Git repository. |
20 | | -* Clone this repository on your production server. |
21 | | -* Copy the database to the production server. |
22 | | -* Install TYPO3 without dev dependencies on the production server: |
23 | | - |
24 | | - .. code-block:: |
25 | | -
|
26 | | - composer install --no-dev |
27 | | -
|
28 | | -* Compare the database |
29 | | -* Fix file permissions |
30 | | -* Clear caches |
31 | | - |
32 | | -.. todo: Link these steps once documented |
33 | | -
|
34 | | -If you do a `composer install` directly on the production server you might |
35 | | -experience some problems. For this reason some developers and administrators |
36 | | -decide not to do it: |
37 | | - |
38 | | -* There can be several minutes of downtime even if the installation goes |
39 | | - smoothly. |
40 | | -* The installation might fail if some packages are not available. |
41 | | -* You might accidentally call `composer update` as is often done during |
42 | | - development and do unintended, untested updates. |
43 | | -* You might omit the `--no-dev` option and accidentally install packages |
44 | | - that are not save to be used during production. |
45 | | - |
46 | | -Some of these problems can be fixed by using a symlink strategy where one |
47 | | -directory is running on production and another one is being updated. |
| 11 | +This guide outlines the steps required to manually deploy TYPO3 and ensure the installation |
| 12 | +is secure and ready to be used in a production context. This guide also highlights a number of |
| 13 | +automation tools that can help automate the deployment process. |
48 | 14 |
|
49 | | -.. _deployment-copy-files: |
| 15 | +There are several different ways to deploy TYPO3. One of the more simple |
| 16 | +options is to manually copy its files and database |
| 17 | +from a local machine to the live server, adjusting the configuration where |
| 18 | +necessary. |
50 | 19 |
|
51 | | -Build locally and copy all files and symlinks to the server |
52 | | -=========================================================== |
| 20 | +General Deployment Steps |
| 21 | +======================== |
53 | 22 |
|
54 | 23 | * Build the local environment (installing everything necessary for the website) |
55 | 24 | * Run :bash:`composer install --no-dev` to install without development dependencies |
56 | 25 | * Copy files to the production server |
57 | 26 | * Copy the database to the production server |
58 | | -* Compare the database |
59 | | -* Fix file permissions |
60 | | -* Clear caches |
61 | | - |
62 | | -.. todo: Link these steps once documented |
63 | | -
|
64 | | -There can be several problems with this strategy: |
65 | | - |
66 | | -* Copying files or unzipping files can be slow, there can be several minutes |
67 | | - of downtime. |
68 | | -* A TYPO3 installation depends on symlinks. Make sure these symlinks are |
69 | | - preserved during copying and or compressing files. |
70 | | - |
71 | | -.. _deployment-automatic: |
72 | | - |
73 | | -Automatic deployment |
74 | | -==================== |
75 | | - |
76 | | -There are multiple tools that can be used to automate deployment. Read more |
77 | | -about it: :ref:`TYPO3 Explained, automatic deployment <t3coreapi:deployment-automatic>`. |
78 | | - |
79 | | -Deployment Automation |
80 | | -===================== |
81 | | - |
82 | | -A typical setup for deploying web applications consists of three different parts: |
83 | | - |
84 | | -* The local environment (for development) |
85 | | -* 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) |
86 | | -* The live (production) environment |
87 | | - |
88 | | -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. |
89 | | - |
90 | | -One widely employed strategy is the "symlink-switching" approach: |
91 | | - |
92 | | -In that strategy, the webserver serves files from a virtual path :path:`releases/current/public` which consists of a symlink :path:`releases/current` pointing to the latest deployment ("release"). That symlink is switched after a new release has been successfully prepared. |
93 | | -The latest deployment contains symlinks to folders that should be common among all releases (commonly called "shared folders"). |
94 | | - |
95 | | -Usually the database is shared between releases and upgrade wizards and schema upgrades are run automatically before or |
96 | | -shortly after the new release has been set live. |
97 | | - |
98 | | -This is an exemplatory directory structure of a "symlink-switching" TYPO3 installation: |
99 | | - |
100 | | -.. directory-tree:: |
101 | | - |
102 | | - * :path:`shared` |
103 | | - |
104 | | - * :path:`fileadmin` |
105 | | - * :path:`var` |
106 | | - |
107 | | - * :path:`charset` |
108 | | - * :path:`lock` |
109 | | - * :path:`log` |
110 | | - * :path:`session` |
111 | | - |
112 | | - * :path:`releases` |
113 | | - |
114 | | - * :path:`current -> ./release1` (symlink to current release) |
115 | | - * :path:`release1` |
116 | | - |
117 | | - * :path:`public` (webserver root, via releases/current/public) |
118 | | - |
119 | | - * :path:`typo3conf` |
120 | | - * :path:`fileadmin -> ../../../shared/fileadmin` (symlink) |
121 | | - * :file:`index.php` |
122 | | - |
123 | | - * :path:`var` |
124 | | - |
125 | | - * :path:`build` |
126 | | - * :path:`cache` |
127 | | - * :path:`charset -> ../../../shared/var/charset` (symlink) |
128 | | - * :path:`labels` |
129 | | - * :path:`lock -> ../../../shared/var/lock` (symlink) |
130 | | - * :path:`log -> ../../../shared/var/log` (symlink) |
131 | | - * :path:`session -> ../../../shared/var/session` (symlink) |
132 | | - |
133 | | - * :path:`vendor` |
134 | | - * :file:`composer.json` |
135 | | - * :file:`composer.lock` |
136 | | - |
137 | | - |
138 | | -The files in :path:`shared` are shared between different releases of a web site. |
139 | | -The :path:`releases` directory contains the TYPO3 code that will change between the release of each version. |
140 | | - |
141 | | -When using a deployment tool this kind of directory structure is usually created automatically. |
| 27 | +* Clearing the caches |
142 | 28 |
|
143 | | -The following section contains examples for various deployment tools and how they can be configured to use TYPO3: |
| 29 | +.. note:: |
144 | 30 |
|
145 | | -.. toctree:: |
146 | | - :titlesonly: |
| 31 | + The :bash:`composer install` command should not be run on the live environment. |
| 32 | + Ideally, Composer should only run locally or on a dedicated deployment machine, |
| 33 | + to allow testing before going live. |
147 | 34 |
|
148 | | - Deployer/Index |
149 | | - Surf/Index |
150 | | - Magallanes/Index |
| 35 | + To avoid conflicts between the local and the server's PHP version, |
| 36 | + the server's PHP version can be defined in the :file:`composer.json` file |
| 37 | + (e.g. ``{"platform": {"php": "8.2"}}``), so Composer will always check |
| 38 | + the correct dependencies. |
0 commit comments