Show More
@@ -1,150 +1,154 b'' | |||
|
1 | 1 | .. _installation: |
|
2 | 2 | |
|
3 | 3 | ========================== |
|
4 | 4 | Installation on Unix/Linux |
|
5 | 5 | ========================== |
|
6 | 6 | |
|
7 | 7 | The following describes three different ways of installing Kallithea: |
|
8 | 8 | |
|
9 | 9 | - :ref:`installation-source`: The simplest way to keep the installation |
|
10 | 10 | up-to-date and track any local customizations is to run directly from |
|
11 | 11 | source in a Kallithea repository clone, preferably inside a virtualenv |
|
12 | 12 | virtual Python environment. |
|
13 | 13 | |
|
14 | 14 | - :ref:`installation-virtualenv`: If you prefer to only use released versions |
|
15 | 15 | of Kallithea, the recommended method is to install Kallithea in a virtual |
|
16 | 16 | Python environment using `virtualenv`. The advantages of this method over |
|
17 | 17 | direct installation is that Kallithea and its dependencies are completely |
|
18 | 18 | contained inside the virtualenv (which also means you can have multiple |
|
19 | 19 | installations side by side or remove it entirely by just removing the |
|
20 | 20 | virtualenv directory) and does not require root privileges. |
|
21 | 21 | |
|
22 | 22 | - :ref:`installation-without-virtualenv`: The alternative method of installing |
|
23 | 23 | a Kallithea release is using standard pip. The package will be installed in |
|
24 | 24 | the same location as all other Python packages you have ever installed. As a |
|
25 | 25 | result, removing it is not as straightforward as with a virtualenv, as you'd |
|
26 | 26 | have to remove its dependencies manually and make sure that they are not |
|
27 | 27 | needed by other packages. |
|
28 | 28 | |
|
29 | 29 | Regardless of the installation method you may need to make sure you have |
|
30 | 30 | appropriate development packages installed, as installation of some of the |
|
31 | 31 | Kallithea dependencies requires a working C compiler and libffi library |
|
32 | 32 | headers. Depending on your configuration, you may also need to install |
|
33 | 33 | Git and development packages for the database of your choice. |
|
34 | 34 | |
|
35 | 35 | For Debian and Ubuntu, the following command will ensure that a reasonable |
|
36 | 36 | set of dependencies is installed:: |
|
37 | 37 | |
|
38 | 38 | sudo apt-get install build-essential git libffi-dev python3-dev |
|
39 | 39 | |
|
40 | 40 | For Fedora and RHEL-derivatives, the following command will ensure that a |
|
41 | 41 | reasonable set of dependencies is installed:: |
|
42 | 42 | |
|
43 | 43 | sudo yum install gcc git libffi-devel python3-devel |
|
44 | 44 | |
|
45 | 45 | .. _installation-source: |
|
46 | 46 | |
|
47 | 47 | |
|
48 | 48 | Installation from repository source |
|
49 | 49 | ----------------------------------- |
|
50 | 50 | |
|
51 | 51 | To install Kallithea in a virtualenv using the stable branch of the development |
|
52 | 52 | repository, use the following commands in your bash shell:: |
|
53 | 53 | |
|
54 | 54 | hg clone https://kallithea-scm.org/repos/kallithea -u stable |
|
55 | 55 | cd kallithea |
|
56 | 56 | python3 -m venv ../kallithea-venv |
|
57 | 57 | . ../kallithea-venv/bin/activate |
|
58 | 58 | pip install --upgrade pip setuptools |
|
59 | 59 | pip install --upgrade -e . |
|
60 | 60 | python3 setup.py compile_catalog # for translation of the UI |
|
61 | 61 | |
|
62 | 62 | You can now proceed to :ref:`install-front-end`. |
|
63 | 63 | |
|
64 | 64 | .. _installation-virtualenv: |
|
65 | 65 | |
|
66 | 66 | |
|
67 | 67 | Installing a released version in a virtualenv |
|
68 | 68 | --------------------------------------------- |
|
69 | 69 | |
|
70 | 70 | It is highly recommended to use a separate virtualenv for installing Kallithea. |
|
71 | 71 | This way, all libraries required by Kallithea will be installed separately from your |
|
72 | 72 | main Python installation and other applications and things will be less |
|
73 | 73 | problematic when upgrading the system or Kallithea. |
|
74 | 74 | An additional benefit of virtualenv is that it doesn't require root privileges. |
|
75 | 75 | |
|
76 | 76 | - Assuming you have installed virtualenv, create a new virtual environment |
|
77 | 77 | for example, in `/srv/kallithea/venv`, using the venv command:: |
|
78 | 78 | |
|
79 | 79 | python3 -m venv /srv/kallithea/venv |
|
80 | 80 | |
|
81 | 81 | - Activate the virtualenv in your current shell session and make sure the |
|
82 | 82 | basic requirements are up-to-date by running the following commands in your |
|
83 | 83 | bash shell:: |
|
84 | 84 | |
|
85 | 85 | . /srv/kallithea/venv/bin/activate |
|
86 | 86 | pip install --upgrade pip setuptools |
|
87 | 87 | |
|
88 | 88 | .. note:: You can't use UNIX ``sudo`` to source the ``virtualenv`` script; it |
|
89 | 89 | will "activate" a shell that terminates immediately. It is also perfectly |
|
90 | 90 | acceptable (and desirable) to create a virtualenv as a normal user. |
|
91 | 91 | |
|
92 | 92 | - Make a folder for Kallithea data files, and configuration somewhere on the |
|
93 | 93 | filesystem. For example:: |
|
94 | 94 | |
|
95 | 95 | mkdir /srv/kallithea |
|
96 | 96 | |
|
97 | 97 | - Go into the created directory and run this command to install Kallithea:: |
|
98 | 98 | |
|
99 | 99 | pip install --upgrade kallithea |
|
100 | 100 | |
|
101 | 101 | .. note:: Some dependencies are optional. If you need them, install them in |
|
102 | 102 | the virtualenv too:: |
|
103 | 103 | |
|
104 | 104 | pip install --upgrade kallithea python-ldap python-pam psycopg2 |
|
105 | 105 | |
|
106 | 106 | This might require installation of development packages using your |
|
107 | 107 | distribution's package manager. |
|
108 | 108 | |
|
109 | 109 | Alternatively, download a .tar.gz from http://pypi.python.org/pypi/Kallithea, |
|
110 | 110 | extract it and install from source by running:: |
|
111 | 111 | |
|
112 | 112 | pip install --upgrade . |
|
113 | 113 | |
|
114 | 114 | - This will install Kallithea together with all other required |
|
115 | 115 | Python libraries into the activated virtualenv. |
|
116 | 116 | |
|
117 | 117 | You can now proceed to :ref:`install-front-end`. |
|
118 | 118 | |
|
119 | 119 | .. _installation-without-virtualenv: |
|
120 | 120 | |
|
121 | 121 | |
|
122 | 122 | Installing a released version without virtualenv |
|
123 | 123 | ------------------------------------------------ |
|
124 | 124 | |
|
125 | 125 | For installation without virtualenv, 'just' use:: |
|
126 | 126 | |
|
127 | 127 | pip install kallithea |
|
128 | 128 | |
|
129 | 129 | Note that this method requires root privileges and will install packages |
|
130 | 130 | globally without using the system's package manager. |
|
131 | 131 | |
|
132 | 132 | To install as a regular user in ``~/.local``, you can use:: |
|
133 | 133 | |
|
134 | 134 | pip install --user kallithea |
|
135 | 135 | |
|
136 | 136 | You can now proceed to :ref:`install-front-end`. |
|
137 | 137 | |
|
138 | 138 | .. _install-front-end: |
|
139 | 139 | |
|
140 | 140 | |
|
141 | 141 | Prepare front-end files |
|
142 | 142 | ----------------------- |
|
143 | 143 | |
|
144 |
Finally, the front-end files must be prepared. This |
|
|
145 | or later, which needs ``node.js`` (version 12 or later). Prepare the front-end | |
|
146 | by running:: | |
|
144 | Finally, the front-end files with CSS and JavaScript must be prepared. This | |
|
145 | depends on having some commands available in the shell search path: ``npm`` | |
|
146 | version 6 or later, and ``node.js`` (version 12 or later) available as | |
|
147 | ``node``. The installation method for these dependencies varies between | |
|
148 | operating systems and distributions. | |
|
149 | ||
|
150 | Prepare the front-end by running:: | |
|
147 | 151 | |
|
148 | 152 | kallithea-cli front-end-build |
|
149 | 153 | |
|
150 | 154 | You can now proceed to :ref:`setup`. |
@@ -1,236 +1,236 b'' | |||
|
1 | 1 | .. _overview: |
|
2 | 2 | |
|
3 | 3 | ===================== |
|
4 | 4 | Installation overview |
|
5 | 5 | ===================== |
|
6 | 6 | |
|
7 | 7 | Some overview and some details that can help understanding the options when |
|
8 | 8 | installing Kallithea. |
|
9 | 9 | |
|
10 | 10 | 1. **Prepare environment and external dependencies.** |
|
11 | 11 | Kallithea needs: |
|
12 | 12 | |
|
13 | 13 | * A filesystem where the Mercurial and Git repositories can be stored. |
|
14 | 14 | * A database where meta data can be stored. |
|
15 | 15 | * A Python environment where the Kallithea application and its dependencies |
|
16 | 16 | can be installed. |
|
17 | 17 | * A web server that can host the Kallithea web application using the WSGI |
|
18 | 18 | API. |
|
19 | 19 | |
|
20 | 20 | 2. **Install Kallithea software.** |
|
21 | 21 | This makes the ``kallithea-cli`` command line tool available. |
|
22 | 22 | |
|
23 | 23 | 3. **Prepare front-end files** |
|
24 |
Some front-end files must be fetched or created using ``npm`` |
|
|
25 | they can be served to the client as static files. | |
|
24 | Some front-end files must be fetched or created using ``npm`` and ``node`` | |
|
25 | tooling so they can be served to the client as static files. | |
|
26 | 26 | |
|
27 | 27 | 4. **Create low level configuration file.** |
|
28 | 28 | Use ``kallithea-cli config-create`` to create a ``.ini`` file with database |
|
29 | 29 | connection info, mail server information, configuration for the specified |
|
30 | 30 | web server, etc. |
|
31 | 31 | |
|
32 | 32 | 5. **Populate the database.** |
|
33 | 33 | Use ``kallithea-cli db-create`` with the ``.ini`` file to create the |
|
34 | 34 | database schema and insert the most basic information: the location of the |
|
35 | 35 | repository store and an initial local admin user. |
|
36 | 36 | |
|
37 | 37 | 6. **Configure the web server.** |
|
38 | 38 | The web server must invoke the WSGI entrypoint for the Kallithea software |
|
39 | 39 | using the ``.ini`` file (and thus the database). This makes the web |
|
40 | 40 | application available so the local admin user can log in and tweak the |
|
41 | 41 | configuration further. |
|
42 | 42 | |
|
43 | 43 | 7. **Configure users.** |
|
44 | 44 | The initial admin user can create additional local users, or configure how |
|
45 | 45 | users can be created and authenticated from other user directories. |
|
46 | 46 | |
|
47 | 47 | See the subsequent sections, the separate OS-specific instructions, and |
|
48 | 48 | :ref:`setup` for details on these steps. |
|
49 | 49 | |
|
50 | 50 | |
|
51 | 51 | Python environment |
|
52 | 52 | ------------------ |
|
53 | 53 | |
|
54 | 54 | **Kallithea** is written entirely in Python_ and requires Python version |
|
55 | 55 | 3.6 or higher. |
|
56 | 56 | |
|
57 | 57 | Given a Python installation, there are different ways of providing the |
|
58 | 58 | environment for running Python applications. Each of them pretty much |
|
59 | 59 | corresponds to a ``site-packages`` directory somewhere where packages can be |
|
60 | 60 | installed. |
|
61 | 61 | |
|
62 | 62 | Kallithea itself can be run from source or be installed, but even when running |
|
63 | 63 | from source, there are some dependencies that must be installed in the Python |
|
64 | 64 | environment used for running Kallithea. |
|
65 | 65 | |
|
66 | 66 | - Packages *could* be installed in Python's ``site-packages`` directory ... but |
|
67 | 67 | that would require running pip_ as root and it would be hard to uninstall or |
|
68 | 68 | upgrade and is probably not a good idea unless using a package manager. |
|
69 | 69 | |
|
70 | 70 | - Packages could also be installed in ``~/.local`` ... but that is probably |
|
71 | 71 | only a good idea if using a dedicated user per application or instance. |
|
72 | 72 | |
|
73 | 73 | - Finally, it can be installed in a virtualenv. That is a very lightweight |
|
74 | 74 | "container" where each Kallithea instance can get its own dedicated and |
|
75 | 75 | self-contained virtual environment. |
|
76 | 76 | |
|
77 | 77 | We recommend using virtualenv for installing Kallithea. |
|
78 | 78 | |
|
79 | 79 | |
|
80 | 80 | Locale environment |
|
81 | 81 | ------------------ |
|
82 | 82 | |
|
83 | 83 | In order to ensure a correct functioning of Kallithea with respect to non-ASCII |
|
84 | 84 | characters in user names, file paths, commit messages, etc., it is very |
|
85 | 85 | important that Kallithea is run with a correct `locale` configuration. |
|
86 | 86 | |
|
87 | 87 | On Unix, environment variables like ``LANG`` or ``LC_ALL`` can specify a language (like |
|
88 | 88 | ``en_US``) and encoding (like ``UTF-8``) to use for code points outside the ASCII |
|
89 | 89 | range. The flexibility of supporting multiple encodings of Unicode has the flip |
|
90 | 90 | side of having to specify which encoding to use - especially for Mercurial. |
|
91 | 91 | |
|
92 | 92 | It depends on the OS distribution and system configuration which locales are |
|
93 | 93 | available. For example, some Docker containers based on Debian default to only |
|
94 | 94 | supporting the ``C`` language, while other Linux environments have ``en_US`` but not |
|
95 | 95 | ``C``. The ``locale -a`` command will show which values are available on the |
|
96 | 96 | current system. Regardless of the actual language, you should normally choose a |
|
97 | 97 | locale that has the ``UTF-8`` encoding (note that spellings ``utf8``, ``utf-8``, |
|
98 | 98 | ``UTF8``, ``UTF-8`` are all referring to the same thing) |
|
99 | 99 | |
|
100 | 100 | For technical reasons, the locale configuration **must** be provided in the |
|
101 | 101 | environment in which Kallithea runs - it cannot be specified in the ``.ini`` file. |
|
102 | 102 | How to practically do this depends on the web server that is used and the way it |
|
103 | 103 | is started. For example, gearbox is often started by a normal user, either |
|
104 | 104 | manually or via a script. In this case, the required locale environment |
|
105 | 105 | variables can be provided directly in that user's environment or in the script. |
|
106 | 106 | However, web servers like Apache are often started at boot via an init script or |
|
107 | 107 | service file. Modifying the environment for this case would thus require |
|
108 | 108 | root/administrator privileges. Moreover, that environment would dictate the |
|
109 | 109 | settings for all web services running under that web server, Kallithea being |
|
110 | 110 | just one of them. Specifically in the case of Apache with ``mod_wsgi``, the |
|
111 | 111 | locale can be set for a specific service in its ``WSGIDaemonProcess`` directive, |
|
112 | 112 | using the ``lang`` parameter. |
|
113 | 113 | |
|
114 | 114 | |
|
115 | 115 | Installation methods |
|
116 | 116 | -------------------- |
|
117 | 117 | |
|
118 | 118 | Kallithea must be installed on a server. Kallithea is installed in a Python |
|
119 | 119 | environment so it can use packages that are installed there and make itself |
|
120 | 120 | available for other packages. |
|
121 | 121 | |
|
122 | 122 | Two different cases will pretty much cover the options for how it can be |
|
123 | 123 | installed. |
|
124 | 124 | |
|
125 | 125 | - The Kallithea source repository can be cloned and used -- it is kept stable and |
|
126 | 126 | can be used in production. The Kallithea maintainers use the development |
|
127 | 127 | branch in production. The advantage of installation from source and regularly |
|
128 | 128 | updating it is that you take advantage of the most recent improvements. Using |
|
129 | 129 | it directly from a DVCS also means that it is easy to track local customizations. |
|
130 | 130 | |
|
131 | 131 | Running ``pip install -e .`` in the source will use pip to install the |
|
132 | 132 | necessary dependencies in the Python environment and create a |
|
133 | 133 | ``.../site-packages/Kallithea.egg-link`` file there that points at the Kallithea |
|
134 | 134 | source. |
|
135 | 135 | |
|
136 | 136 | - Kallithea can also be installed from ready-made packages using a package manager. |
|
137 | 137 | The official released versions are available on PyPI_ and can be downloaded and |
|
138 | 138 | installed with all dependencies using ``pip install kallithea``. |
|
139 | 139 | |
|
140 | 140 | With this method, Kallithea is installed in the Python environment as any |
|
141 | 141 | other package, usually as a ``.../site-packages/Kallithea-X-py3.8.egg/`` |
|
142 | 142 | directory with Python files and everything else that is needed. |
|
143 | 143 | |
|
144 | 144 | (``pip install kallithea`` from a source tree will do pretty much the same |
|
145 | 145 | but build the Kallithea package itself locally instead of downloading it.) |
|
146 | 146 | |
|
147 | 147 | .. note:: |
|
148 | 148 | Kallithea includes front-end code that needs to be processed to prepare |
|
149 | 149 | static files that can be served at run time and used on the client side. The |
|
150 | 150 | tool npm_ is used to download external dependencies and orchestrate the |
|
151 | 151 | processing. The ``npm`` binary must thus be available at install time but is |
|
152 | 152 | not used at run time. |
|
153 | 153 | |
|
154 | 154 | |
|
155 | 155 | Web server |
|
156 | 156 | ---------- |
|
157 | 157 | |
|
158 | 158 | Kallithea is (primarily) a WSGI_ application that must be run from a web |
|
159 | 159 | server that serves WSGI applications over HTTP. |
|
160 | 160 | |
|
161 | 161 | Kallithea itself is not serving HTTP (or HTTPS); that is the web server's |
|
162 | 162 | responsibility. Kallithea does however need to know its own user facing URL |
|
163 | 163 | (protocol, address, port and path) for each HTTP request. Kallithea will |
|
164 | 164 | usually use its own HTML/cookie based authentication but can also be configured |
|
165 | 165 | to use web server authentication. |
|
166 | 166 | |
|
167 | 167 | There are several web server options: |
|
168 | 168 | |
|
169 | 169 | - Kallithea uses the Gearbox_ tool as command line interface. Gearbox provides |
|
170 | 170 | ``gearbox serve`` as a convenient way to launch a Python WSGI / web server |
|
171 | 171 | from the command line. That is perfect for development and evaluation. |
|
172 | 172 | Actual use in production might have different requirements and need extra |
|
173 | 173 | work to make it manageable as a scalable system service. |
|
174 | 174 | |
|
175 | 175 | Gearbox comes with its own built-in web server for development but Kallithea |
|
176 | 176 | defaults to using Waitress_. Gunicorn_ and Gevent_ are also options. These |
|
177 | 177 | web servers have different limited feature sets. |
|
178 | 178 | |
|
179 | 179 | The web server used by ``gearbox serve`` is configured in the ``.ini`` file. |
|
180 | 180 | Create it with ``config-create`` using for example ``http_server=waitress`` |
|
181 | 181 | to get a configuration starting point for your choice of web server. |
|
182 | 182 | |
|
183 | 183 | (Gearbox will do like ``paste`` and use the WSGI application entry point |
|
184 | 184 | ``kallithea.config.application:make_app`` as specified in ``setup.py``.) |
|
185 | 185 | |
|
186 | 186 | - `Apache httpd`_ can serve WSGI applications directly using mod_wsgi_ and a |
|
187 | 187 | simple Python file with the necessary configuration. This is a good option if |
|
188 | 188 | Apache is an option. |
|
189 | 189 | |
|
190 | 190 | - uWSGI_ is also a full web server with built-in WSGI module. Use |
|
191 | 191 | ``config-create`` with ``http_server=uwsgi`` to get a ``.ini`` file with |
|
192 | 192 | uWSGI configuration. |
|
193 | 193 | |
|
194 | 194 | - IIS_ can also server WSGI applications directly using isapi-wsgi_. |
|
195 | 195 | |
|
196 | 196 | - A `reverse HTTP proxy <https://en.wikipedia.org/wiki/Reverse_proxy>`_ |
|
197 | 197 | can be put in front of another web server which has WSGI support. |
|
198 | 198 | Such a layered setup can be complex but might in some cases be the right |
|
199 | 199 | option, for example to standardize on one internet-facing web server, to add |
|
200 | 200 | encryption or special authentication or for other security reasons, to |
|
201 | 201 | provide caching of static files, or to provide load balancing or fail-over. |
|
202 | 202 | Nginx_, Varnish_ and HAProxy_ are often used for this purpose, often in front |
|
203 | 203 | of a ``gearbox serve`` that somehow is wrapped as a service. |
|
204 | 204 | |
|
205 | 205 | The best option depends on what you are familiar with and the requirements for |
|
206 | 206 | performance and stability. Also, keep in mind that Kallithea mainly is serving |
|
207 | 207 | dynamically generated pages from a relatively slow Python process. Kallithea is |
|
208 | 208 | also often used inside organizations with a limited amount of users and thus no |
|
209 | 209 | continuous hammering from the internet. |
|
210 | 210 | |
|
211 | 211 | .. note:: |
|
212 | 212 | Kallithea, the libraries it uses, and Python itself do in several places use |
|
213 | 213 | simple caching in memory. Caches and memory are not always released in a way |
|
214 | 214 | that is suitable for long-running processes. They might appear to be leaking |
|
215 | 215 | memory. The worker processes should thus regularly be restarted - for |
|
216 | 216 | example after 1000 requests and/or one hour. This can usually be done by the |
|
217 | 217 | web server or the tool used for running it as a system service. |
|
218 | 218 | |
|
219 | 219 | |
|
220 | 220 | .. _Python: http://www.python.org/ |
|
221 | 221 | .. _Gunicorn: http://gunicorn.org/ |
|
222 | 222 | .. _Gevent: http://www.gevent.org/ |
|
223 | 223 | .. _Waitress: https://docs.pylonsproject.org/projects/waitress/ |
|
224 | 224 | .. _Gearbox: https://turbogears.readthedocs.io/en/latest/turbogears/gearbox.html |
|
225 | 225 | .. _PyPI: https://pypi.python.org/pypi |
|
226 | 226 | .. _Apache httpd: http://httpd.apache.org/ |
|
227 | 227 | .. _mod_wsgi: https://modwsgi.readthedocs.io/ |
|
228 | 228 | .. _isapi-wsgi: https://github.com/hexdump42/isapi-wsgi |
|
229 | 229 | .. _uWSGI: https://uwsgi-docs.readthedocs.io/ |
|
230 | 230 | .. _nginx: http://nginx.org/en/ |
|
231 | 231 | .. _iis: http://en.wikipedia.org/wiki/Internet_Information_Services |
|
232 | 232 | .. _pip: http://en.wikipedia.org/wiki/Pip_%28package_manager%29 |
|
233 | 233 | .. _WSGI: http://en.wikipedia.org/wiki/Web_Server_Gateway_Interface |
|
234 | 234 | .. _HAProxy: http://www.haproxy.org/ |
|
235 | 235 | .. _Varnish: https://www.varnish-cache.org/ |
|
236 | 236 | .. _npm: https://www.npmjs.com/ |
General Comments 0
You need to be logged in to leave comments.
Login now