Show More
@@ -1,222 +1,224 b'' | |||||
1 | .. _overview: |
|
1 | .. _overview: | |
2 |
|
2 | |||
3 | ===================== |
|
3 | ===================== | |
4 | Installation overview |
|
4 | Installation overview | |
5 | ===================== |
|
5 | ===================== | |
6 |
|
6 | |||
7 | Some overview and some details that can help understanding the options when |
|
7 | Some overview and some details that can help understanding the options when | |
8 | installing Kallithea. |
|
8 | installing Kallithea. | |
9 |
|
9 | |||
10 | 1. **Prepare environment and external dependencies.** |
|
10 | 1. **Prepare environment and external dependencies.** | |
11 | Kallithea needs: |
|
11 | Kallithea needs: | |
12 |
|
12 | |||
13 | * A filesystem where the Mercurial and Git repositories can be stored. |
|
13 | * A filesystem where the Mercurial and Git repositories can be stored. | |
14 | * A database where meta data can be stored. |
|
14 | * A database where meta data can be stored. | |
15 | * A Python environment where the Kallithea application and its dependencies |
|
15 | * A Python environment where the Kallithea application and its dependencies | |
16 | can be installed. |
|
16 | can be installed. | |
17 | * A web server that can host the Kallithea web application using the WSGI |
|
17 | * A web server that can host the Kallithea web application using the WSGI | |
18 | API. |
|
18 | API. | |
19 |
|
19 | |||
20 | 2. **Install Kallithea software.** |
|
20 | 2. **Install Kallithea software.** | |
21 | This makes the ``kallithea-cli`` command line tool available. |
|
21 | This makes the ``kallithea-cli`` command line tool available. | |
22 |
|
22 | |||
23 | 3. **Create low level configuration file.** |
|
23 | 3. **Create low level configuration file.** | |
24 | Use ``kallithea-cli config-create`` to create a ``.ini`` file with database |
|
24 | Use ``kallithea-cli config-create`` to create a ``.ini`` file with database | |
25 | connection info, mail server information, configuration for the specified |
|
25 | connection info, mail server information, configuration for the specified | |
26 | web server, etc. |
|
26 | web server, etc. | |
27 |
|
27 | |||
28 | 4. **Populate the database.** |
|
28 | 4. **Populate the database.** | |
29 | Use ``kallithea-cli db-create`` with the ``.ini`` file to create the |
|
29 | Use ``kallithea-cli db-create`` with the ``.ini`` file to create the | |
30 | database schema and insert the most basic information: the location of the |
|
30 | database schema and insert the most basic information: the location of the | |
31 | repository store and an initial local admin user. |
|
31 | repository store and an initial local admin user. | |
32 |
|
32 | |||
33 | 5. **Configure the web server.** |
|
33 | 5. **Configure the web server.** | |
34 | The web server must invoke the WSGI entrypoint for the Kallithea software |
|
34 | The web server must invoke the WSGI entrypoint for the Kallithea software | |
35 | using the ``.ini`` file (and thus the database). This makes the web |
|
35 | using the ``.ini`` file (and thus the database). This makes the web | |
36 | application available so the local admin user can log in and tweak the |
|
36 | application available so the local admin user can log in and tweak the | |
37 | configuration further. |
|
37 | configuration further. | |
38 |
|
38 | |||
39 | 6. **Configure users.** |
|
39 | 6. **Configure users.** | |
40 | The initial admin user can create additional local users, or configure how |
|
40 | The initial admin user can create additional local users, or configure how | |
41 | users can be created and authenticated from other user directories. |
|
41 | users can be created and authenticated from other user directories. | |
42 |
|
42 | |||
43 | See the subsequent sections, the separate OS-specific instructions, and |
|
43 | See the subsequent sections, the separate OS-specific instructions, and | |
44 | :ref:`setup` for details on these steps. |
|
44 | :ref:`setup` for details on these steps. | |
45 |
|
45 | |||
46 |
|
46 | |||
47 | Python environment |
|
47 | Python environment | |
48 | ------------------ |
|
48 | ------------------ | |
49 |
|
49 | |||
50 | **Kallithea** is written entirely in Python_ and requires Python version |
|
50 | **Kallithea** is written entirely in Python_ and requires Python version | |
51 | 3.6 or higher. |
|
51 | 3.6 or higher. | |
52 |
|
52 | |||
53 | Given a Python installation, there are different ways of providing the |
|
53 | Given a Python installation, there are different ways of providing the | |
54 | environment for running Python applications. Each of them pretty much |
|
54 | environment for running Python applications. Each of them pretty much | |
55 | corresponds to a ``site-packages`` directory somewhere where packages can be |
|
55 | corresponds to a ``site-packages`` directory somewhere where packages can be | |
56 | installed. |
|
56 | installed. | |
57 |
|
57 | |||
58 | Kallithea itself can be run from source or be installed, but even when running |
|
58 | Kallithea itself can be run from source or be installed, but even when running | |
59 | from source, there are some dependencies that must be installed in the Python |
|
59 | from source, there are some dependencies that must be installed in the Python | |
60 | environment used for running Kallithea. |
|
60 | environment used for running Kallithea. | |
61 |
|
61 | |||
62 | - Packages *could* be installed in Python's ``site-packages`` directory ... but |
|
62 | - Packages *could* be installed in Python's ``site-packages`` directory ... but | |
63 | that would require running pip_ as root and it would be hard to uninstall or |
|
63 | that would require running pip_ as root and it would be hard to uninstall or | |
64 | upgrade and is probably not a good idea unless using a package manager. |
|
64 | upgrade and is probably not a good idea unless using a package manager. | |
65 |
|
65 | |||
66 | - Packages could also be installed in ``~/.local`` ... but that is probably |
|
66 | - Packages could also be installed in ``~/.local`` ... but that is probably | |
67 | only a good idea if using a dedicated user per application or instance. |
|
67 | only a good idea if using a dedicated user per application or instance. | |
68 |
|
68 | |||
69 | - Finally, it can be installed in a virtualenv. That is a very lightweight |
|
69 | - Finally, it can be installed in a virtualenv. That is a very lightweight | |
70 | "container" where each Kallithea instance can get its own dedicated and |
|
70 | "container" where each Kallithea instance can get its own dedicated and | |
71 | self-contained virtual environment. |
|
71 | self-contained virtual environment. | |
72 |
|
72 | |||
73 | We recommend using virtualenv for installing Kallithea. |
|
73 | We recommend using virtualenv for installing Kallithea. | |
74 |
|
74 | |||
75 |
|
75 | |||
76 | Locale environment |
|
76 | Locale environment | |
77 | ------------------ |
|
77 | ------------------ | |
78 |
|
78 | |||
79 | In order to ensure a correct functioning of Kallithea with respect to non-ASCII |
|
79 | In order to ensure a correct functioning of Kallithea with respect to non-ASCII | |
80 | characters in user names, file paths, commit messages, etc., it is very |
|
80 | characters in user names, file paths, commit messages, etc., it is very | |
81 | important that Kallithea is run with a correct `locale` configuration. |
|
81 | important that Kallithea is run with a correct `locale` configuration. | |
82 |
|
82 | |||
83 | On Unix, environment variables like ``LANG`` or ``LC_ALL`` can specify a language (like |
|
83 | On Unix, environment variables like ``LANG`` or ``LC_ALL`` can specify a language (like | |
84 | ``en_US``) and encoding (like ``UTF-8``) to use for code points outside the ASCII |
|
84 | ``en_US``) and encoding (like ``UTF-8``) to use for code points outside the ASCII | |
85 | range. The flexibility of supporting multiple encodings of Unicode has the flip |
|
85 | range. The flexibility of supporting multiple encodings of Unicode has the flip | |
86 | side of having to specify which encoding to use - especially for Mercurial. |
|
86 | side of having to specify which encoding to use - especially for Mercurial. | |
87 |
|
87 | |||
88 | It depends on the OS distribution and system configuration which locales are |
|
88 | It depends on the OS distribution and system configuration which locales are | |
89 | available. For example, some Docker containers based on Debian default to only |
|
89 | available. For example, some Docker containers based on Debian default to only | |
90 | supporting the ``C`` language, while other Linux environments have ``en_US`` but not |
|
90 | supporting the ``C`` language, while other Linux environments have ``en_US`` but not | |
91 | ``C``. The ``locale -a`` command will show which values are available on the |
|
91 | ``C``. The ``locale -a`` command will show which values are available on the | |
92 | current system. Regardless of the actual language, you should normally choose a |
|
92 | current system. Regardless of the actual language, you should normally choose a | |
93 | locale that has the ``UTF-8`` encoding (note that spellings ``utf8``, ``utf-8``, |
|
93 | locale that has the ``UTF-8`` encoding (note that spellings ``utf8``, ``utf-8``, | |
94 | ``UTF8``, ``UTF-8`` are all referring to the same thing) |
|
94 | ``UTF8``, ``UTF-8`` are all referring to the same thing) | |
95 |
|
95 | |||
96 | For technical reasons, the locale configuration **must** be provided in the |
|
96 | For technical reasons, the locale configuration **must** be provided in the | |
97 | environment in which Kallithea runs - it cannot be specified in the ``.ini`` file. |
|
97 | environment in which Kallithea runs - it cannot be specified in the ``.ini`` file. | |
98 | How to practically do this depends on the web server that is used and the way it |
|
98 | How to practically do this depends on the web server that is used and the way it | |
99 | is started. For example, gearbox is often started by a normal user, either |
|
99 | is started. For example, gearbox is often started by a normal user, either | |
100 | manually or via a script. In this case, the required locale environment |
|
100 | manually or via a script. In this case, the required locale environment | |
101 | variables can be provided directly in that user's environment or in the script. |
|
101 | variables can be provided directly in that user's environment or in the script. | |
102 | However, web servers like Apache are often started at boot via an init script or |
|
102 | However, web servers like Apache are often started at boot via an init script or | |
103 | service file. Modifying the environment for this case would thus require |
|
103 | service file. Modifying the environment for this case would thus require | |
104 | root/administrator privileges. Moreover, that environment would dictate the |
|
104 | root/administrator privileges. Moreover, that environment would dictate the | |
105 | settings for all web services running under that web server, Kallithea being |
|
105 | settings for all web services running under that web server, Kallithea being | |
106 | just one of them. Specifically in the case of Apache with ``mod_wsgi``, the |
|
106 | just one of them. Specifically in the case of Apache with ``mod_wsgi``, the | |
107 | locale can be set for a specific service in its ``WSGIDaemonProcess`` directive, |
|
107 | locale can be set for a specific service in its ``WSGIDaemonProcess`` directive, | |
108 | using the ``lang`` parameter. |
|
108 | using the ``lang`` parameter. | |
109 |
|
109 | |||
110 |
|
110 | |||
111 | Installation methods |
|
111 | Installation methods | |
112 | -------------------- |
|
112 | -------------------- | |
113 |
|
113 | |||
114 | Kallithea must be installed on a server. Kallithea is installed in a Python |
|
114 | Kallithea must be installed on a server. Kallithea is installed in a Python | |
115 | environment so it can use packages that are installed there and make itself |
|
115 | environment so it can use packages that are installed there and make itself | |
116 | available for other packages. |
|
116 | available for other packages. | |
117 |
|
117 | |||
118 | Two different cases will pretty much cover the options for how it can be |
|
118 | Two different cases will pretty much cover the options for how it can be | |
119 | installed. |
|
119 | installed. | |
120 |
|
120 | |||
121 | - The Kallithea source repository can be cloned and used -- it is kept stable and |
|
121 | - The Kallithea source repository can be cloned and used -- it is kept stable and | |
122 | can be used in production. The Kallithea maintainers use the development |
|
122 | can be used in production. The Kallithea maintainers use the development | |
123 | branch in production. The advantage of installation from source and regularly |
|
123 | branch in production. The advantage of installation from source and regularly | |
124 | updating it is that you take advantage of the most recent improvements. Using |
|
124 | updating it is that you take advantage of the most recent improvements. Using | |
125 | it directly from a DVCS also means that it is easy to track local customizations. |
|
125 | it directly from a DVCS also means that it is easy to track local customizations. | |
126 |
|
126 | |||
127 | Running ``pip install -e .`` in the source will use pip to install the |
|
127 | Running ``pip install -e .`` in the source will use pip to install the | |
128 | necessary dependencies in the Python environment and create a |
|
128 | necessary dependencies in the Python environment and create a | |
129 | ``.../site-packages/Kallithea.egg-link`` file there that points at the Kallithea |
|
129 | ``.../site-packages/Kallithea.egg-link`` file there that points at the Kallithea | |
130 | source. |
|
130 | source. | |
131 |
|
131 | |||
132 | - Kallithea can also be installed from ready-made packages using a package manager. |
|
132 | - Kallithea can also be installed from ready-made packages using a package manager. | |
133 | The official released versions are available on PyPI_ and can be downloaded and |
|
133 | The official released versions are available on PyPI_ and can be downloaded and | |
134 | installed with all dependencies using ``pip install kallithea``. |
|
134 | installed with all dependencies using ``pip install kallithea``. | |
135 |
|
135 | |||
136 | With this method, Kallithea is installed in the Python environment as any |
|
136 | With this method, Kallithea is installed in the Python environment as any | |
137 | other package, usually as a ``.../site-packages/Kallithea-X-py3.8.egg/`` |
|
137 | other package, usually as a ``.../site-packages/Kallithea-X-py3.8.egg/`` | |
138 | directory with Python files and everything else that is needed. |
|
138 | directory with Python files and everything else that is needed. | |
139 |
|
139 | |||
140 | (``pip install kallithea`` from a source tree will do pretty much the same |
|
140 | (``pip install kallithea`` from a source tree will do pretty much the same | |
141 | but build the Kallithea package itself locally instead of downloading it.) |
|
141 | but build the Kallithea package itself locally instead of downloading it.) | |
142 |
|
142 | |||
143 | .. note:: |
|
143 | .. note:: | |
144 |
Kallithea includes front-end code that needs to be processed |
|
144 | Kallithea includes front-end code that needs to be processed to prepare | |
145 | The tool npm_ is used to download external dependencies and orchestrate the |
|
145 | static files that can be served at run time and used on the client side. The | |
146 | processing. The ``npm`` binary must thus be available. |
|
146 | tool npm_ is used to download external dependencies and orchestrate the | |
|
147 | processing. The ``npm`` binary must thus be available at install time but is | |||
|
148 | not used at run time. | |||
147 |
|
149 | |||
148 |
|
150 | |||
149 | Web server |
|
151 | Web server | |
150 | ---------- |
|
152 | ---------- | |
151 |
|
153 | |||
152 | Kallithea is (primarily) a WSGI_ application that must be run from a web |
|
154 | Kallithea is (primarily) a WSGI_ application that must be run from a web | |
153 | server that serves WSGI applications over HTTP. |
|
155 | server that serves WSGI applications over HTTP. | |
154 |
|
156 | |||
155 | Kallithea itself is not serving HTTP (or HTTPS); that is the web server's |
|
157 | Kallithea itself is not serving HTTP (or HTTPS); that is the web server's | |
156 | responsibility. Kallithea does however need to know its own user facing URL |
|
158 | responsibility. Kallithea does however need to know its own user facing URL | |
157 | (protocol, address, port and path) for each HTTP request. Kallithea will |
|
159 | (protocol, address, port and path) for each HTTP request. Kallithea will | |
158 | usually use its own HTML/cookie based authentication but can also be configured |
|
160 | usually use its own HTML/cookie based authentication but can also be configured | |
159 | to use web server authentication. |
|
161 | to use web server authentication. | |
160 |
|
162 | |||
161 | There are several web server options: |
|
163 | There are several web server options: | |
162 |
|
164 | |||
163 | - Kallithea uses the Gearbox_ tool as command line interface. Gearbox provides |
|
165 | - Kallithea uses the Gearbox_ tool as command line interface. Gearbox provides | |
164 | ``gearbox serve`` as a convenient way to launch a Python WSGI / web server |
|
166 | ``gearbox serve`` as a convenient way to launch a Python WSGI / web server | |
165 | from the command line. That is perfect for development and evaluation. |
|
167 | from the command line. That is perfect for development and evaluation. | |
166 | Actual use in production might have different requirements and need extra |
|
168 | Actual use in production might have different requirements and need extra | |
167 | work to make it manageable as a scalable system service. |
|
169 | work to make it manageable as a scalable system service. | |
168 |
|
170 | |||
169 | Gearbox comes with its own built-in web server for development but Kallithea |
|
171 | Gearbox comes with its own built-in web server for development but Kallithea | |
170 | defaults to using Waitress_. Gunicorn_ and Gevent_ are also options. These |
|
172 | defaults to using Waitress_. Gunicorn_ and Gevent_ are also options. These | |
171 | web servers have different limited feature sets. |
|
173 | web servers have different limited feature sets. | |
172 |
|
174 | |||
173 | The web server used by ``gearbox serve`` is configured in the ``.ini`` file. |
|
175 | The web server used by ``gearbox serve`` is configured in the ``.ini`` file. | |
174 | Create it with ``config-create`` using for example ``http_server=waitress`` |
|
176 | Create it with ``config-create`` using for example ``http_server=waitress`` | |
175 | to get a configuration starting point for your choice of web server. |
|
177 | to get a configuration starting point for your choice of web server. | |
176 |
|
178 | |||
177 | (Gearbox will do like ``paste`` and use the WSGI application entry point |
|
179 | (Gearbox will do like ``paste`` and use the WSGI application entry point | |
178 | ``kallithea.config.middleware:make_app`` as specified in ``setup.py``.) |
|
180 | ``kallithea.config.middleware:make_app`` as specified in ``setup.py``.) | |
179 |
|
181 | |||
180 | - `Apache httpd`_ can serve WSGI applications directly using mod_wsgi_ and a |
|
182 | - `Apache httpd`_ can serve WSGI applications directly using mod_wsgi_ and a | |
181 | simple Python file with the necessary configuration. This is a good option if |
|
183 | simple Python file with the necessary configuration. This is a good option if | |
182 | Apache is an option. |
|
184 | Apache is an option. | |
183 |
|
185 | |||
184 | - uWSGI_ is also a full web server with built-in WSGI module. Use |
|
186 | - uWSGI_ is also a full web server with built-in WSGI module. Use | |
185 | ``config-create`` with ``http_server=uwsgi`` to get a ``.ini`` file with |
|
187 | ``config-create`` with ``http_server=uwsgi`` to get a ``.ini`` file with | |
186 | uWSGI configuration. |
|
188 | uWSGI configuration. | |
187 |
|
189 | |||
188 | - IIS_ can also server WSGI applications directly using isapi-wsgi_. |
|
190 | - IIS_ can also server WSGI applications directly using isapi-wsgi_. | |
189 |
|
191 | |||
190 | - A `reverse HTTP proxy <https://en.wikipedia.org/wiki/Reverse_proxy>`_ |
|
192 | - A `reverse HTTP proxy <https://en.wikipedia.org/wiki/Reverse_proxy>`_ | |
191 | can be put in front of another web server which has WSGI support. |
|
193 | can be put in front of another web server which has WSGI support. | |
192 | Such a layered setup can be complex but might in some cases be the right |
|
194 | Such a layered setup can be complex but might in some cases be the right | |
193 | option, for example to standardize on one internet-facing web server, to add |
|
195 | option, for example to standardize on one internet-facing web server, to add | |
194 | encryption or special authentication or for other security reasons, to |
|
196 | encryption or special authentication or for other security reasons, to | |
195 | provide caching of static files, or to provide load balancing or fail-over. |
|
197 | provide caching of static files, or to provide load balancing or fail-over. | |
196 | Nginx_, Varnish_ and HAProxy_ are often used for this purpose, often in front |
|
198 | Nginx_, Varnish_ and HAProxy_ are often used for this purpose, often in front | |
197 | of a ``gearbox serve`` that somehow is wrapped as a service. |
|
199 | of a ``gearbox serve`` that somehow is wrapped as a service. | |
198 |
|
200 | |||
199 | The best option depends on what you are familiar with and the requirements for |
|
201 | The best option depends on what you are familiar with and the requirements for | |
200 | performance and stability. Also, keep in mind that Kallithea mainly is serving |
|
202 | performance and stability. Also, keep in mind that Kallithea mainly is serving | |
201 | dynamically generated pages from a relatively slow Python process. Kallithea is |
|
203 | dynamically generated pages from a relatively slow Python process. Kallithea is | |
202 | also often used inside organizations with a limited amount of users and thus no |
|
204 | also often used inside organizations with a limited amount of users and thus no | |
203 | continuous hammering from the internet. |
|
205 | continuous hammering from the internet. | |
204 |
|
206 | |||
205 |
|
207 | |||
206 | .. _Python: http://www.python.org/ |
|
208 | .. _Python: http://www.python.org/ | |
207 | .. _Gunicorn: http://gunicorn.org/ |
|
209 | .. _Gunicorn: http://gunicorn.org/ | |
208 | .. _Gevent: http://www.gevent.org/ |
|
210 | .. _Gevent: http://www.gevent.org/ | |
209 | .. _Waitress: http://waitress.readthedocs.org/en/latest/ |
|
211 | .. _Waitress: http://waitress.readthedocs.org/en/latest/ | |
210 | .. _Gearbox: http://turbogears.readthedocs.io/en/latest/turbogears/gearbox.html |
|
212 | .. _Gearbox: http://turbogears.readthedocs.io/en/latest/turbogears/gearbox.html | |
211 | .. _PyPI: https://pypi.python.org/pypi |
|
213 | .. _PyPI: https://pypi.python.org/pypi | |
212 | .. _Apache httpd: http://httpd.apache.org/ |
|
214 | .. _Apache httpd: http://httpd.apache.org/ | |
213 | .. _mod_wsgi: https://code.google.com/p/modwsgi/ |
|
215 | .. _mod_wsgi: https://code.google.com/p/modwsgi/ | |
214 | .. _isapi-wsgi: https://github.com/hexdump42/isapi-wsgi |
|
216 | .. _isapi-wsgi: https://github.com/hexdump42/isapi-wsgi | |
215 | .. _uWSGI: https://uwsgi-docs.readthedocs.org/en/latest/ |
|
217 | .. _uWSGI: https://uwsgi-docs.readthedocs.org/en/latest/ | |
216 | .. _nginx: http://nginx.org/en/ |
|
218 | .. _nginx: http://nginx.org/en/ | |
217 | .. _iis: http://en.wikipedia.org/wiki/Internet_Information_Services |
|
219 | .. _iis: http://en.wikipedia.org/wiki/Internet_Information_Services | |
218 | .. _pip: http://en.wikipedia.org/wiki/Pip_%28package_manager%29 |
|
220 | .. _pip: http://en.wikipedia.org/wiki/Pip_%28package_manager%29 | |
219 | .. _WSGI: http://en.wikipedia.org/wiki/Web_Server_Gateway_Interface |
|
221 | .. _WSGI: http://en.wikipedia.org/wiki/Web_Server_Gateway_Interface | |
220 | .. _HAProxy: http://www.haproxy.org/ |
|
222 | .. _HAProxy: http://www.haproxy.org/ | |
221 | .. _Varnish: https://www.varnish-cache.org/ |
|
223 | .. _Varnish: https://www.varnish-cache.org/ | |
222 | .. _npm: https://www.npmjs.com/ |
|
224 | .. _npm: https://www.npmjs.com/ |
@@ -1,646 +1,648 b'' | |||||
1 | .. _setup: |
|
1 | .. _setup: | |
2 |
|
2 | |||
3 | ===== |
|
3 | ===== | |
4 | Setup |
|
4 | Setup | |
5 | ===== |
|
5 | ===== | |
6 |
|
6 | |||
7 |
|
7 | |||
8 | Setting up Kallithea |
|
8 | Setting up Kallithea | |
9 | -------------------- |
|
9 | -------------------- | |
10 |
|
10 | |||
11 | First, you will need to create a Kallithea configuration file. Run the |
|
11 | First, you will need to create a Kallithea configuration file. Run the | |
12 | following command to do so:: |
|
12 | following command to do so:: | |
13 |
|
13 | |||
14 | kallithea-cli config-create my.ini |
|
14 | kallithea-cli config-create my.ini | |
15 |
|
15 | |||
16 | This will create the file ``my.ini`` in the current directory. This |
|
16 | This will create the file ``my.ini`` in the current directory. This | |
17 | configuration file contains the various settings for Kallithea, e.g. |
|
17 | configuration file contains the various settings for Kallithea, e.g. | |
18 | proxy port, email settings, usage of static files, cache, Celery |
|
18 | proxy port, email settings, usage of static files, cache, Celery | |
19 | settings, and logging. Extra settings can be specified like:: |
|
19 | settings, and logging. Extra settings can be specified like:: | |
20 |
|
20 | |||
21 | kallithea-cli config-create my.ini host=8.8.8.8 "[handler_console]" formatter=color_formatter |
|
21 | kallithea-cli config-create my.ini host=8.8.8.8 "[handler_console]" formatter=color_formatter | |
22 |
|
22 | |||
23 | Next, you need to create the databases used by Kallithea. It is recommended to |
|
23 | Next, you need to create the databases used by Kallithea. It is recommended to | |
24 | use PostgreSQL or SQLite (default). If you choose a database other than the |
|
24 | use PostgreSQL or SQLite (default). If you choose a database other than the | |
25 | default, ensure you properly adjust the database URL in your ``my.ini`` |
|
25 | default, ensure you properly adjust the database URL in your ``my.ini`` | |
26 | configuration file to use this other database. Kallithea currently supports |
|
26 | configuration file to use this other database. Kallithea currently supports | |
27 | PostgreSQL, SQLite and MariaDB/MySQL databases. Create the database by running |
|
27 | PostgreSQL, SQLite and MariaDB/MySQL databases. Create the database by running | |
28 | the following command:: |
|
28 | the following command:: | |
29 |
|
29 | |||
30 | kallithea-cli db-create -c my.ini |
|
30 | kallithea-cli db-create -c my.ini | |
31 |
|
31 | |||
32 | This will prompt you for a "root" path. This "root" path is the location where |
|
32 | This will prompt you for a "root" path. This "root" path is the location where | |
33 | Kallithea will store all of its repositories on the current machine. After |
|
33 | Kallithea will store all of its repositories on the current machine. After | |
34 | entering this "root" path ``db-create`` will also prompt you for a username |
|
34 | entering this "root" path ``db-create`` will also prompt you for a username | |
35 | and password for the initial admin account which ``db-create`` sets |
|
35 | and password for the initial admin account which ``db-create`` sets | |
36 | up for you. |
|
36 | up for you. | |
37 |
|
37 | |||
38 | The ``db-create`` values can also be given on the command line. |
|
38 | The ``db-create`` values can also be given on the command line. | |
39 | Example:: |
|
39 | Example:: | |
40 |
|
40 | |||
41 | kallithea-cli db-create -c my.ini --user=nn --password=secret --email=nn@example.com --repos=/srv/repos |
|
41 | kallithea-cli db-create -c my.ini --user=nn --password=secret --email=nn@example.com --repos=/srv/repos | |
42 |
|
42 | |||
43 | The ``db-create`` command will create all needed tables and an |
|
43 | The ``db-create`` command will create all needed tables and an | |
44 | admin account. When choosing a root path you can either use a new |
|
44 | admin account. When choosing a root path you can either use a new | |
45 | empty location, or a location which already contains existing |
|
45 | empty location, or a location which already contains existing | |
46 | repositories. If you choose a location which contains existing |
|
46 | repositories. If you choose a location which contains existing | |
47 | repositories Kallithea will add all of the repositories at the chosen |
|
47 | repositories Kallithea will add all of the repositories at the chosen | |
48 | location to its database. (Note: make sure you specify the correct |
|
48 | location to its database. (Note: make sure you specify the correct | |
49 | path to the root). |
|
49 | path to the root). | |
50 |
|
50 | |||
51 | .. note:: the given path for Mercurial_ repositories **must** be write |
|
51 | .. note:: the given path for Mercurial_ repositories **must** be write | |
52 | accessible for the application. It's very important since |
|
52 | accessible for the application. It's very important since | |
53 | the Kallithea web interface will work without write access, |
|
53 | the Kallithea web interface will work without write access, | |
54 | but when trying to do a push it will fail with permission |
|
54 | but when trying to do a push it will fail with permission | |
55 | denied errors unless it has write access. |
|
55 | denied errors unless it has write access. | |
56 |
|
56 | |||
57 | Finally, prepare the front-end by running:: |
|
57 | Finally, the front-end files must be prepared. This requires ``npm`` version 6 | |
|
58 | or later, which needs ``node.js`` (version 12 or later). Prepare the front-end | |||
|
59 | by running:: | |||
58 |
|
60 | |||
59 | kallithea-cli front-end-build |
|
61 | kallithea-cli front-end-build | |
60 |
|
62 | |||
61 | You are now ready to use Kallithea. To run it simply execute:: |
|
63 | You are now ready to use Kallithea. To run it simply execute:: | |
62 |
|
64 | |||
63 | gearbox serve -c my.ini |
|
65 | gearbox serve -c my.ini | |
64 |
|
66 | |||
65 | - This command runs the Kallithea server. The web app should be available at |
|
67 | - This command runs the Kallithea server. The web app should be available at | |
66 | http://127.0.0.1:5000. The IP address and port is configurable via the |
|
68 | http://127.0.0.1:5000. The IP address and port is configurable via the | |
67 | configuration file created in the previous step. |
|
69 | configuration file created in the previous step. | |
68 | - Log in to Kallithea using the admin account created when running ``db-create``. |
|
70 | - Log in to Kallithea using the admin account created when running ``db-create``. | |
69 | - The default permissions on each repository is read, and the owner is admin. |
|
71 | - The default permissions on each repository is read, and the owner is admin. | |
70 | Remember to update these if needed. |
|
72 | Remember to update these if needed. | |
71 | - In the admin panel you can toggle LDAP, anonymous, and permissions |
|
73 | - In the admin panel you can toggle LDAP, anonymous, and permissions | |
72 | settings, as well as edit more advanced options on users and |
|
74 | settings, as well as edit more advanced options on users and | |
73 | repositories. |
|
75 | repositories. | |
74 |
|
76 | |||
75 |
|
77 | |||
76 | Internationalization (i18n support) |
|
78 | Internationalization (i18n support) | |
77 | ----------------------------------- |
|
79 | ----------------------------------- | |
78 |
|
80 | |||
79 | The Kallithea web interface is automatically displayed in the user's preferred |
|
81 | The Kallithea web interface is automatically displayed in the user's preferred | |
80 | language, as indicated by the browser. Thus, different users may see the |
|
82 | language, as indicated by the browser. Thus, different users may see the | |
81 | application in different languages. If the requested language is not available |
|
83 | application in different languages. If the requested language is not available | |
82 | (because the translation file for that language does not yet exist or is |
|
84 | (because the translation file for that language does not yet exist or is | |
83 | incomplete), English is used. |
|
85 | incomplete), English is used. | |
84 |
|
86 | |||
85 | If you want to disable automatic language detection and instead configure a |
|
87 | If you want to disable automatic language detection and instead configure a | |
86 | fixed language regardless of user preference, set ``i18n.enabled = false`` and |
|
88 | fixed language regardless of user preference, set ``i18n.enabled = false`` and | |
87 | specify another language by setting ``i18n.lang`` in the Kallithea |
|
89 | specify another language by setting ``i18n.lang`` in the Kallithea | |
88 | configuration file. |
|
90 | configuration file. | |
89 |
|
91 | |||
90 |
|
92 | |||
91 | Using Kallithea with SSH |
|
93 | Using Kallithea with SSH | |
92 | ------------------------ |
|
94 | ------------------------ | |
93 |
|
95 | |||
94 | Kallithea supports repository access via SSH key based authentication. |
|
96 | Kallithea supports repository access via SSH key based authentication. | |
95 | This means: |
|
97 | This means: | |
96 |
|
98 | |||
97 | - repository URLs like ``ssh://kallithea@example.com/name/of/repository`` |
|
99 | - repository URLs like ``ssh://kallithea@example.com/name/of/repository`` | |
98 |
|
100 | |||
99 | - all network traffic for both read and write happens over the SSH protocol on |
|
101 | - all network traffic for both read and write happens over the SSH protocol on | |
100 | port 22, without using HTTP/HTTPS nor the Kallithea WSGI application |
|
102 | port 22, without using HTTP/HTTPS nor the Kallithea WSGI application | |
101 |
|
103 | |||
102 | - encryption and authentication protocols are managed by the system's ``sshd`` |
|
104 | - encryption and authentication protocols are managed by the system's ``sshd`` | |
103 | process, with all users using the same Kallithea system user (e.g. |
|
105 | process, with all users using the same Kallithea system user (e.g. | |
104 | ``kallithea``) when connecting to the SSH server, but with users' public keys |
|
106 | ``kallithea``) when connecting to the SSH server, but with users' public keys | |
105 | in the Kallithea system user's `.ssh/authorized_keys` file granting each user |
|
107 | in the Kallithea system user's `.ssh/authorized_keys` file granting each user | |
106 | sandboxed access to the repositories. |
|
108 | sandboxed access to the repositories. | |
107 |
|
109 | |||
108 | - users and admins can manage SSH public keys in the web UI |
|
110 | - users and admins can manage SSH public keys in the web UI | |
109 |
|
111 | |||
110 | - in their SSH client configuration, users can configure how the client should |
|
112 | - in their SSH client configuration, users can configure how the client should | |
111 | control access to their SSH key - without passphrase, with passphrase, and |
|
113 | control access to their SSH key - without passphrase, with passphrase, and | |
112 | optionally with passphrase caching in the local shell session (``ssh-agent``). |
|
114 | optionally with passphrase caching in the local shell session (``ssh-agent``). | |
113 | This is standard SSH functionality, not something Kallithea provides or |
|
115 | This is standard SSH functionality, not something Kallithea provides or | |
114 | interferes with. |
|
116 | interferes with. | |
115 |
|
117 | |||
116 | - network communication between client and server happens in a bidirectional |
|
118 | - network communication between client and server happens in a bidirectional | |
117 | stateful stream, and will in some cases be faster than HTTP/HTTPS with several |
|
119 | stateful stream, and will in some cases be faster than HTTP/HTTPS with several | |
118 | stateless round-trips. |
|
120 | stateless round-trips. | |
119 |
|
121 | |||
120 | .. note:: At this moment, repository access via SSH has been tested on Unix |
|
122 | .. note:: At this moment, repository access via SSH has been tested on Unix | |
121 | only. Windows users that care about SSH are invited to test it and report |
|
123 | only. Windows users that care about SSH are invited to test it and report | |
122 | problems, ideally contributing patches that solve these problems. |
|
124 | problems, ideally contributing patches that solve these problems. | |
123 |
|
125 | |||
124 | Users and admins can upload SSH public keys (e.g. ``.ssh/id_rsa.pub``) through |
|
126 | Users and admins can upload SSH public keys (e.g. ``.ssh/id_rsa.pub``) through | |
125 | the web interface. The server's ``.ssh/authorized_keys`` file is automatically |
|
127 | the web interface. The server's ``.ssh/authorized_keys`` file is automatically | |
126 | maintained with an entry for each SSH key. Each entry will tell ``sshd`` to run |
|
128 | maintained with an entry for each SSH key. Each entry will tell ``sshd`` to run | |
127 | ``kallithea-cli`` with the ``ssh-serve`` sub-command and the right Kallithea user ID |
|
129 | ``kallithea-cli`` with the ``ssh-serve`` sub-command and the right Kallithea user ID | |
128 | when encountering the corresponding SSH key. |
|
130 | when encountering the corresponding SSH key. | |
129 |
|
131 | |||
130 | To enable SSH repository access, Kallithea must be configured with the path to |
|
132 | To enable SSH repository access, Kallithea must be configured with the path to | |
131 | the ``.ssh/authorized_keys`` file for the Kallithea user, and the path to the |
|
133 | the ``.ssh/authorized_keys`` file for the Kallithea user, and the path to the | |
132 | ``kallithea-cli`` command. Put something like this in the ``.ini`` file:: |
|
134 | ``kallithea-cli`` command. Put something like this in the ``.ini`` file:: | |
133 |
|
135 | |||
134 | ssh_enabled = true |
|
136 | ssh_enabled = true | |
135 | ssh_authorized_keys = /home/kallithea/.ssh/authorized_keys |
|
137 | ssh_authorized_keys = /home/kallithea/.ssh/authorized_keys | |
136 | kallithea_cli_path = /srv/kallithea/venv/bin/kallithea-cli |
|
138 | kallithea_cli_path = /srv/kallithea/venv/bin/kallithea-cli | |
137 |
|
139 | |||
138 | The SSH service must be running, and the Kallithea user account must be active |
|
140 | The SSH service must be running, and the Kallithea user account must be active | |
139 | (not necessarily with password access, but public key access must be enabled), |
|
141 | (not necessarily with password access, but public key access must be enabled), | |
140 | all file permissions must be set as sshd wants it, and ``authorized_keys`` must |
|
142 | all file permissions must be set as sshd wants it, and ``authorized_keys`` must | |
141 | be writeable by the Kallithea user. |
|
143 | be writeable by the Kallithea user. | |
142 |
|
144 | |||
143 | .. note:: The ``authorized_keys`` file will be rewritten from scratch on |
|
145 | .. note:: The ``authorized_keys`` file will be rewritten from scratch on | |
144 | each update. If it already exists with other data, Kallithea will not |
|
146 | each update. If it already exists with other data, Kallithea will not | |
145 | overwrite the existing ``authorized_keys``, and the server process will |
|
147 | overwrite the existing ``authorized_keys``, and the server process will | |
146 | instead throw an exception. The system administrator thus cannot ssh |
|
148 | instead throw an exception. The system administrator thus cannot ssh | |
147 | directly to the Kallithea user but must use su/sudo from another account. |
|
149 | directly to the Kallithea user but must use su/sudo from another account. | |
148 |
|
150 | |||
149 | If ``/home/kallithea/.ssh/`` (the directory of the path specified in the |
|
151 | If ``/home/kallithea/.ssh/`` (the directory of the path specified in the | |
150 | ``ssh_authorized_keys`` setting of the ``.ini`` file) does not exist as a |
|
152 | ``ssh_authorized_keys`` setting of the ``.ini`` file) does not exist as a | |
151 | directory, Kallithea will attempt to create it. If that path exists but is |
|
153 | directory, Kallithea will attempt to create it. If that path exists but is | |
152 | *not* a directory, or is not readable-writable-executable by the server |
|
154 | *not* a directory, or is not readable-writable-executable by the server | |
153 | process, the server process will raise an exception each time it attempts to |
|
155 | process, the server process will raise an exception each time it attempts to | |
154 | write the ``authorized_keys`` file. |
|
156 | write the ``authorized_keys`` file. | |
155 |
|
157 | |||
156 | .. note:: It is possible to configure the SSH server to look for authorized |
|
158 | .. note:: It is possible to configure the SSH server to look for authorized | |
157 | keys in multiple files, for example reserving ``ssh/authorized_keys`` to be |
|
159 | keys in multiple files, for example reserving ``ssh/authorized_keys`` to be | |
158 | used for normal SSH and with Kallithea using |
|
160 | used for normal SSH and with Kallithea using | |
159 | ``.ssh/authorized_keys_kallithea``. In ``/etc/ssh/sshd_config`` set |
|
161 | ``.ssh/authorized_keys_kallithea``. In ``/etc/ssh/sshd_config`` set | |
160 | ``AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys_kallithea`` |
|
162 | ``AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys_kallithea`` | |
161 | and restart sshd, and in ``my.ini`` set ``ssh_authorized_keys = |
|
163 | and restart sshd, and in ``my.ini`` set ``ssh_authorized_keys = | |
162 | /home/kallithea/.ssh/authorized_keys_kallithea``. Note that this new |
|
164 | /home/kallithea/.ssh/authorized_keys_kallithea``. Note that this new | |
163 | location will apply to all system users, and that multiple entries for the |
|
165 | location will apply to all system users, and that multiple entries for the | |
164 | same SSH key will shadow each other. |
|
166 | same SSH key will shadow each other. | |
165 |
|
167 | |||
166 | .. warning:: The handling of SSH access is steered directly by the command |
|
168 | .. warning:: The handling of SSH access is steered directly by the command | |
167 | specified in the ``authorized_keys`` file. There is no interaction with the |
|
169 | specified in the ``authorized_keys`` file. There is no interaction with the | |
168 | web UI. Once SSH access is correctly configured and enabled, it will work |
|
170 | web UI. Once SSH access is correctly configured and enabled, it will work | |
169 | regardless of whether the Kallithea web process is actually running. Hence, |
|
171 | regardless of whether the Kallithea web process is actually running. Hence, | |
170 | if you want to perform repository or server maintenance and want to fully |
|
172 | if you want to perform repository or server maintenance and want to fully | |
171 | disable all access to the repositories, disable SSH access by setting |
|
173 | disable all access to the repositories, disable SSH access by setting | |
172 | ``ssh_enabled = false`` in the correct ``.ini`` file (i.e. the ``.ini`` file |
|
174 | ``ssh_enabled = false`` in the correct ``.ini`` file (i.e. the ``.ini`` file | |
173 | specified in the ``authorized_keys`` file.) |
|
175 | specified in the ``authorized_keys`` file.) | |
174 |
|
176 | |||
175 | The ``authorized_keys`` file can be updated manually with ``kallithea-cli |
|
177 | The ``authorized_keys`` file can be updated manually with ``kallithea-cli | |
176 | ssh-update-authorized-keys -c my.ini``. This command is not needed in normal |
|
178 | ssh-update-authorized-keys -c my.ini``. This command is not needed in normal | |
177 | operation but is for example useful after changing SSH-related settings in the |
|
179 | operation but is for example useful after changing SSH-related settings in the | |
178 | ``.ini`` file or renaming that file. (The path to the ``.ini`` file is used in |
|
180 | ``.ini`` file or renaming that file. (The path to the ``.ini`` file is used in | |
179 | the generated ``authorized_keys`` file). |
|
181 | the generated ``authorized_keys`` file). | |
180 |
|
182 | |||
181 |
|
183 | |||
182 | Setting up Whoosh full text search |
|
184 | Setting up Whoosh full text search | |
183 | ---------------------------------- |
|
185 | ---------------------------------- | |
184 |
|
186 | |||
185 | Kallithea provides full text search of repositories using `Whoosh`__. |
|
187 | Kallithea provides full text search of repositories using `Whoosh`__. | |
186 |
|
188 | |||
187 | .. __: https://whoosh.readthedocs.io/en/latest/ |
|
189 | .. __: https://whoosh.readthedocs.io/en/latest/ | |
188 |
|
190 | |||
189 | For an incremental index build, run:: |
|
191 | For an incremental index build, run:: | |
190 |
|
192 | |||
191 | kallithea-cli index-create -c my.ini |
|
193 | kallithea-cli index-create -c my.ini | |
192 |
|
194 | |||
193 | For a full index rebuild, run:: |
|
195 | For a full index rebuild, run:: | |
194 |
|
196 | |||
195 | kallithea-cli index-create -c my.ini --full |
|
197 | kallithea-cli index-create -c my.ini --full | |
196 |
|
198 | |||
197 | The ``--repo-location`` option allows the location of the repositories to be overridden; |
|
199 | The ``--repo-location`` option allows the location of the repositories to be overridden; | |
198 | usually, the location is retrieved from the Kallithea database. |
|
200 | usually, the location is retrieved from the Kallithea database. | |
199 |
|
201 | |||
200 | The ``--index-only`` option can be used to limit the indexed repositories to a comma-separated list:: |
|
202 | The ``--index-only`` option can be used to limit the indexed repositories to a comma-separated list:: | |
201 |
|
203 | |||
202 | kallithea-cli index-create -c my.ini --index-only=vcs,kallithea |
|
204 | kallithea-cli index-create -c my.ini --index-only=vcs,kallithea | |
203 |
|
205 | |||
204 | To keep your index up-to-date it is necessary to do periodic index builds; |
|
206 | To keep your index up-to-date it is necessary to do periodic index builds; | |
205 | for this, it is recommended to use a crontab entry. Example:: |
|
207 | for this, it is recommended to use a crontab entry. Example:: | |
206 |
|
208 | |||
207 | 0 3 * * * /path/to/virtualenv/bin/kallithea-cli index-create -c /path/to/kallithea/my.ini |
|
209 | 0 3 * * * /path/to/virtualenv/bin/kallithea-cli index-create -c /path/to/kallithea/my.ini | |
208 |
|
210 | |||
209 | When using incremental mode (the default), Whoosh will check the last |
|
211 | When using incremental mode (the default), Whoosh will check the last | |
210 | modification date of each file and add it to be reindexed if a newer file is |
|
212 | modification date of each file and add it to be reindexed if a newer file is | |
211 | available. The indexing daemon checks for any removed files and removes them |
|
213 | available. The indexing daemon checks for any removed files and removes them | |
212 | from index. |
|
214 | from index. | |
213 |
|
215 | |||
214 | If you want to rebuild the index from scratch, you can use the ``-f`` flag as above, |
|
216 | If you want to rebuild the index from scratch, you can use the ``-f`` flag as above, | |
215 | or in the admin panel you can check the "build from scratch" checkbox. |
|
217 | or in the admin panel you can check the "build from scratch" checkbox. | |
216 |
|
218 | |||
217 |
|
219 | |||
218 | Integration with issue trackers |
|
220 | Integration with issue trackers | |
219 | ------------------------------- |
|
221 | ------------------------------- | |
220 |
|
222 | |||
221 | Kallithea provides a simple integration with issue trackers. It's possible |
|
223 | Kallithea provides a simple integration with issue trackers. It's possible | |
222 | to define a regular expression that will match an issue ID in commit messages, |
|
224 | to define a regular expression that will match an issue ID in commit messages, | |
223 | and have that replaced with a URL to the issue. |
|
225 | and have that replaced with a URL to the issue. | |
224 |
|
226 | |||
225 | This is achieved with following three variables in the ini file:: |
|
227 | This is achieved with following three variables in the ini file:: | |
226 |
|
228 | |||
227 | issue_pat = #(\d+) |
|
229 | issue_pat = #(\d+) | |
228 | issue_server_link = https://issues.example.com/{repo}/issue/\1 |
|
230 | issue_server_link = https://issues.example.com/{repo}/issue/\1 | |
229 | issue_sub = |
|
231 | issue_sub = | |
230 |
|
232 | |||
231 | ``issue_pat`` is the regular expression describing which strings in |
|
233 | ``issue_pat`` is the regular expression describing which strings in | |
232 | commit messages will be treated as issue references. The expression can/should |
|
234 | commit messages will be treated as issue references. The expression can/should | |
233 | have one or more parenthesized groups that can later be referred to in |
|
235 | have one or more parenthesized groups that can later be referred to in | |
234 | ``issue_server_link`` and ``issue_sub`` (see below). If you prefer, named groups |
|
236 | ``issue_server_link`` and ``issue_sub`` (see below). If you prefer, named groups | |
235 | can be used instead of simple parenthesized groups. |
|
237 | can be used instead of simple parenthesized groups. | |
236 |
|
238 | |||
237 | If the pattern should only match if it is preceded by whitespace, add the |
|
239 | If the pattern should only match if it is preceded by whitespace, add the | |
238 | following string before the actual pattern: ``(?:^|(?<=\s))``. |
|
240 | following string before the actual pattern: ``(?:^|(?<=\s))``. | |
239 | If the pattern should only match if it is followed by whitespace, add the |
|
241 | If the pattern should only match if it is followed by whitespace, add the | |
240 | following string after the actual pattern: ``(?:$|(?=\s))``. |
|
242 | following string after the actual pattern: ``(?:$|(?=\s))``. | |
241 | These expressions use lookbehind and lookahead assertions of the Python regular |
|
243 | These expressions use lookbehind and lookahead assertions of the Python regular | |
242 | expression module to avoid the whitespace to be part of the actual pattern, |
|
244 | expression module to avoid the whitespace to be part of the actual pattern, | |
243 | otherwise the link text will also contain that whitespace. |
|
245 | otherwise the link text will also contain that whitespace. | |
244 |
|
246 | |||
245 | Matched issue references are replaced with the link specified in |
|
247 | Matched issue references are replaced with the link specified in | |
246 | ``issue_server_link``, in which any backreferences are resolved. Backreferences |
|
248 | ``issue_server_link``, in which any backreferences are resolved. Backreferences | |
247 | can be ``\1``, ``\2``, ... or for named groups ``\g<groupname>``. |
|
249 | can be ``\1``, ``\2``, ... or for named groups ``\g<groupname>``. | |
248 | The special token ``{repo}`` is replaced with the full repository path |
|
250 | The special token ``{repo}`` is replaced with the full repository path | |
249 | (including repository groups), while token ``{repo_name}`` is replaced with the |
|
251 | (including repository groups), while token ``{repo_name}`` is replaced with the | |
250 | repository name (without repository groups). |
|
252 | repository name (without repository groups). | |
251 |
|
253 | |||
252 | The link text is determined by ``issue_sub``, which can be a string containing |
|
254 | The link text is determined by ``issue_sub``, which can be a string containing | |
253 | backreferences to the groups specified in ``issue_pat``. If ``issue_sub`` is |
|
255 | backreferences to the groups specified in ``issue_pat``. If ``issue_sub`` is | |
254 | empty, then the text matched by ``issue_pat`` is used verbatim. |
|
256 | empty, then the text matched by ``issue_pat`` is used verbatim. | |
255 |
|
257 | |||
256 | The example settings shown above match issues in the format ``#<number>``. |
|
258 | The example settings shown above match issues in the format ``#<number>``. | |
257 | This will cause the text ``#300`` to be transformed into a link: |
|
259 | This will cause the text ``#300`` to be transformed into a link: | |
258 |
|
260 | |||
259 | .. code-block:: html |
|
261 | .. code-block:: html | |
260 |
|
262 | |||
261 | <a href="https://issues.example.com/example_repo/issue/300">#300</a> |
|
263 | <a href="https://issues.example.com/example_repo/issue/300">#300</a> | |
262 |
|
264 | |||
263 | The following example transforms a text starting with either of 'pullrequest', |
|
265 | The following example transforms a text starting with either of 'pullrequest', | |
264 | 'pull request' or 'PR', followed by an optional space, then a pound character |
|
266 | 'pull request' or 'PR', followed by an optional space, then a pound character | |
265 | (#) and one or more digits, into a link with the text 'PR #' followed by the |
|
267 | (#) and one or more digits, into a link with the text 'PR #' followed by the | |
266 | digits:: |
|
268 | digits:: | |
267 |
|
269 | |||
268 | issue_pat = (pullrequest|pull request|PR) ?#(\d+) |
|
270 | issue_pat = (pullrequest|pull request|PR) ?#(\d+) | |
269 | issue_server_link = https://issues.example.com/\2 |
|
271 | issue_server_link = https://issues.example.com/\2 | |
270 | issue_sub = PR #\2 |
|
272 | issue_sub = PR #\2 | |
271 |
|
273 | |||
272 | The following example demonstrates how to require whitespace before the issue |
|
274 | The following example demonstrates how to require whitespace before the issue | |
273 | reference in order for it to be recognized, such that the text ``issue#123`` will |
|
275 | reference in order for it to be recognized, such that the text ``issue#123`` will | |
274 | not cause a match, but ``issue #123`` will:: |
|
276 | not cause a match, but ``issue #123`` will:: | |
275 |
|
277 | |||
276 | issue_pat = (?:^|(?<=\s))#(\d+) |
|
278 | issue_pat = (?:^|(?<=\s))#(\d+) | |
277 | issue_server_link = https://issues.example.com/\1 |
|
279 | issue_server_link = https://issues.example.com/\1 | |
278 | issue_sub = |
|
280 | issue_sub = | |
279 |
|
281 | |||
280 | If needed, more than one pattern can be specified by appending a unique suffix to |
|
282 | If needed, more than one pattern can be specified by appending a unique suffix to | |
281 | the variables. For example, also demonstrating the use of named groups:: |
|
283 | the variables. For example, also demonstrating the use of named groups:: | |
282 |
|
284 | |||
283 | issue_pat_wiki = wiki-(?P<pagename>\S+) |
|
285 | issue_pat_wiki = wiki-(?P<pagename>\S+) | |
284 | issue_server_link_wiki = https://wiki.example.com/\g<pagename> |
|
286 | issue_server_link_wiki = https://wiki.example.com/\g<pagename> | |
285 | issue_sub_wiki = WIKI-\g<pagename> |
|
287 | issue_sub_wiki = WIKI-\g<pagename> | |
286 |
|
288 | |||
287 | With these settings, wiki pages can be referenced as wiki-some-id, and every |
|
289 | With these settings, wiki pages can be referenced as wiki-some-id, and every | |
288 | such reference will be transformed into: |
|
290 | such reference will be transformed into: | |
289 |
|
291 | |||
290 | .. code-block:: html |
|
292 | .. code-block:: html | |
291 |
|
293 | |||
292 | <a href="https://wiki.example.com/some-id">WIKI-some-id</a> |
|
294 | <a href="https://wiki.example.com/some-id">WIKI-some-id</a> | |
293 |
|
295 | |||
294 | Refer to the `Python regular expression documentation`_ for more details about |
|
296 | Refer to the `Python regular expression documentation`_ for more details about | |
295 | the supported syntax in ``issue_pat``, ``issue_server_link`` and ``issue_sub``. |
|
297 | the supported syntax in ``issue_pat``, ``issue_server_link`` and ``issue_sub``. | |
296 |
|
298 | |||
297 |
|
299 | |||
298 | Hook management |
|
300 | Hook management | |
299 | --------------- |
|
301 | --------------- | |
300 |
|
302 | |||
301 | Hooks can be managed in similar way to that used in ``.hgrc`` files. |
|
303 | Hooks can be managed in similar way to that used in ``.hgrc`` files. | |
302 | To manage hooks, choose *Admin > Settings > Hooks*. |
|
304 | To manage hooks, choose *Admin > Settings > Hooks*. | |
303 |
|
305 | |||
304 | The built-in hooks cannot be modified, though they can be enabled or disabled in the *VCS* section. |
|
306 | The built-in hooks cannot be modified, though they can be enabled or disabled in the *VCS* section. | |
305 |
|
307 | |||
306 | To add another custom hook simply fill in the first textbox with |
|
308 | To add another custom hook simply fill in the first textbox with | |
307 | ``<name>.<hook_type>`` and the second with the hook path. Example hooks |
|
309 | ``<name>.<hook_type>`` and the second with the hook path. Example hooks | |
308 | can be found in ``kallithea.lib.hooks``. |
|
310 | can be found in ``kallithea.lib.hooks``. | |
309 |
|
311 | |||
310 |
|
312 | |||
311 | Changing default encoding |
|
313 | Changing default encoding | |
312 | ------------------------- |
|
314 | ------------------------- | |
313 |
|
315 | |||
314 | By default, Kallithea uses UTF-8 encoding. |
|
316 | By default, Kallithea uses UTF-8 encoding. | |
315 | This is configurable as ``default_encoding`` in the .ini file. |
|
317 | This is configurable as ``default_encoding`` in the .ini file. | |
316 | This affects many parts in Kallithea including user names, filenames, and |
|
318 | This affects many parts in Kallithea including user names, filenames, and | |
317 | encoding of commit messages. In addition Kallithea can detect if the ``chardet`` |
|
319 | encoding of commit messages. In addition Kallithea can detect if the ``chardet`` | |
318 | library is installed. If ``chardet`` is detected Kallithea will fallback to it |
|
320 | library is installed. If ``chardet`` is detected Kallithea will fallback to it | |
319 | when there are encode/decode errors. |
|
321 | when there are encode/decode errors. | |
320 |
|
322 | |||
321 | The Mercurial encoding is configurable as ``hgencoding``. It is similar to |
|
323 | The Mercurial encoding is configurable as ``hgencoding``. It is similar to | |
322 | setting the ``HGENCODING`` environment variable, but will override it. |
|
324 | setting the ``HGENCODING`` environment variable, but will override it. | |
323 |
|
325 | |||
324 |
|
326 | |||
325 | Celery configuration |
|
327 | Celery configuration | |
326 | -------------------- |
|
328 | -------------------- | |
327 |
|
329 | |||
328 | Kallithea can use the distributed task queue system Celery_ to run tasks like |
|
330 | Kallithea can use the distributed task queue system Celery_ to run tasks like | |
329 | cloning repositories or sending emails. |
|
331 | cloning repositories or sending emails. | |
330 |
|
332 | |||
331 | Kallithea will in most setups work perfectly fine out of the box (without |
|
333 | Kallithea will in most setups work perfectly fine out of the box (without | |
332 | Celery), executing all tasks in the web server process. Some tasks can however |
|
334 | Celery), executing all tasks in the web server process. Some tasks can however | |
333 | take some time to run and it can be better to run such tasks asynchronously in |
|
335 | take some time to run and it can be better to run such tasks asynchronously in | |
334 | a separate process so the web server can focus on serving web requests. |
|
336 | a separate process so the web server can focus on serving web requests. | |
335 |
|
337 | |||
336 | For installation and configuration of Celery, see the `Celery documentation`_. |
|
338 | For installation and configuration of Celery, see the `Celery documentation`_. | |
337 | Note that Celery requires a message broker service like RabbitMQ_ (recommended) |
|
339 | Note that Celery requires a message broker service like RabbitMQ_ (recommended) | |
338 | or Redis_. |
|
340 | or Redis_. | |
339 |
|
341 | |||
340 | The use of Celery is configured in the Kallithea ini configuration file. |
|
342 | The use of Celery is configured in the Kallithea ini configuration file. | |
341 | To enable it, simply set:: |
|
343 | To enable it, simply set:: | |
342 |
|
344 | |||
343 | use_celery = true |
|
345 | use_celery = true | |
344 |
|
346 | |||
345 | and add or change the ``celery.*`` configuration variables. |
|
347 | and add or change the ``celery.*`` configuration variables. | |
346 |
|
348 | |||
347 | Configuration settings are prefixed with 'celery.', so for example setting |
|
349 | Configuration settings are prefixed with 'celery.', so for example setting | |
348 | `broker_url` in Celery means setting `celery.broker_url` in the configuration |
|
350 | `broker_url` in Celery means setting `celery.broker_url` in the configuration | |
349 | file. |
|
351 | file. | |
350 |
|
352 | |||
351 | To start the Celery process, run:: |
|
353 | To start the Celery process, run:: | |
352 |
|
354 | |||
353 | kallithea-cli celery-run -c my.ini |
|
355 | kallithea-cli celery-run -c my.ini | |
354 |
|
356 | |||
355 | Extra options to the Celery worker can be passed after ``--`` - see ``-- -h`` |
|
357 | Extra options to the Celery worker can be passed after ``--`` - see ``-- -h`` | |
356 | for more info. |
|
358 | for more info. | |
357 |
|
359 | |||
358 | .. note:: |
|
360 | .. note:: | |
359 | Make sure you run this command from the same virtualenv, and with the same |
|
361 | Make sure you run this command from the same virtualenv, and with the same | |
360 | user that Kallithea runs. |
|
362 | user that Kallithea runs. | |
361 |
|
363 | |||
362 |
|
364 | |||
363 | HTTPS support |
|
365 | HTTPS support | |
364 | ------------- |
|
366 | ------------- | |
365 |
|
367 | |||
366 | Kallithea will by default generate URLs based on the WSGI environment. |
|
368 | Kallithea will by default generate URLs based on the WSGI environment. | |
367 |
|
369 | |||
368 | Alternatively, you can use some special configuration settings to control |
|
370 | Alternatively, you can use some special configuration settings to control | |
369 | directly which scheme/protocol Kallithea will use when generating URLs: |
|
371 | directly which scheme/protocol Kallithea will use when generating URLs: | |
370 |
|
372 | |||
371 | - With ``https_fixup = true``, the scheme will be taken from the |
|
373 | - With ``https_fixup = true``, the scheme will be taken from the | |
372 | ``X-Url-Scheme``, ``X-Forwarded-Scheme`` or ``X-Forwarded-Proto`` HTTP header |
|
374 | ``X-Url-Scheme``, ``X-Forwarded-Scheme`` or ``X-Forwarded-Proto`` HTTP header | |
373 | (default ``http``). |
|
375 | (default ``http``). | |
374 | - With ``force_https = true`` the default will be ``https``. |
|
376 | - With ``force_https = true`` the default will be ``https``. | |
375 | - With ``use_htsts = true``, Kallithea will set ``Strict-Transport-Security`` when using https. |
|
377 | - With ``use_htsts = true``, Kallithea will set ``Strict-Transport-Security`` when using https. | |
376 |
|
378 | |||
377 | .. _nginx_virtual_host: |
|
379 | .. _nginx_virtual_host: | |
378 |
|
380 | |||
379 |
|
381 | |||
380 | Nginx virtual host example |
|
382 | Nginx virtual host example | |
381 | -------------------------- |
|
383 | -------------------------- | |
382 |
|
384 | |||
383 | Sample config for Nginx using proxy: |
|
385 | Sample config for Nginx using proxy: | |
384 |
|
386 | |||
385 | .. code-block:: nginx |
|
387 | .. code-block:: nginx | |
386 |
|
388 | |||
387 | upstream kallithea { |
|
389 | upstream kallithea { | |
388 | server 127.0.0.1:5000; |
|
390 | server 127.0.0.1:5000; | |
389 | # add more instances for load balancing |
|
391 | # add more instances for load balancing | |
390 | #server 127.0.0.1:5001; |
|
392 | #server 127.0.0.1:5001; | |
391 | #server 127.0.0.1:5002; |
|
393 | #server 127.0.0.1:5002; | |
392 | } |
|
394 | } | |
393 |
|
395 | |||
394 | ## gist alias |
|
396 | ## gist alias | |
395 | server { |
|
397 | server { | |
396 | listen 443; |
|
398 | listen 443; | |
397 | server_name gist.example.com; |
|
399 | server_name gist.example.com; | |
398 | access_log /var/log/nginx/gist.access.log; |
|
400 | access_log /var/log/nginx/gist.access.log; | |
399 | error_log /var/log/nginx/gist.error.log; |
|
401 | error_log /var/log/nginx/gist.error.log; | |
400 |
|
402 | |||
401 | ssl on; |
|
403 | ssl on; | |
402 | ssl_certificate gist.your.kallithea.server.crt; |
|
404 | ssl_certificate gist.your.kallithea.server.crt; | |
403 | ssl_certificate_key gist.your.kallithea.server.key; |
|
405 | ssl_certificate_key gist.your.kallithea.server.key; | |
404 |
|
406 | |||
405 | ssl_session_timeout 5m; |
|
407 | ssl_session_timeout 5m; | |
406 |
|
408 | |||
407 | ssl_protocols SSLv3 TLSv1; |
|
409 | ssl_protocols SSLv3 TLSv1; | |
408 | ssl_ciphers DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:EDH-RSA-DES-CBC3-SHA:AES256-SHA:DES-CBC3-SHA:AES128-SHA:RC4-SHA:RC4-MD5; |
|
410 | ssl_ciphers DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:EDH-RSA-DES-CBC3-SHA:AES256-SHA:DES-CBC3-SHA:AES128-SHA:RC4-SHA:RC4-MD5; | |
409 | ssl_prefer_server_ciphers on; |
|
411 | ssl_prefer_server_ciphers on; | |
410 |
|
412 | |||
411 | rewrite ^/(.+)$ https://kallithea.example.com/_admin/gists/$1; |
|
413 | rewrite ^/(.+)$ https://kallithea.example.com/_admin/gists/$1; | |
412 | rewrite (.*) https://kallithea.example.com/_admin/gists; |
|
414 | rewrite (.*) https://kallithea.example.com/_admin/gists; | |
413 | } |
|
415 | } | |
414 |
|
416 | |||
415 | server { |
|
417 | server { | |
416 | listen 443; |
|
418 | listen 443; | |
417 | server_name kallithea.example.com |
|
419 | server_name kallithea.example.com | |
418 | access_log /var/log/nginx/kallithea.access.log; |
|
420 | access_log /var/log/nginx/kallithea.access.log; | |
419 | error_log /var/log/nginx/kallithea.error.log; |
|
421 | error_log /var/log/nginx/kallithea.error.log; | |
420 |
|
422 | |||
421 | ssl on; |
|
423 | ssl on; | |
422 | ssl_certificate your.kallithea.server.crt; |
|
424 | ssl_certificate your.kallithea.server.crt; | |
423 | ssl_certificate_key your.kallithea.server.key; |
|
425 | ssl_certificate_key your.kallithea.server.key; | |
424 |
|
426 | |||
425 | ssl_session_timeout 5m; |
|
427 | ssl_session_timeout 5m; | |
426 |
|
428 | |||
427 | ssl_protocols SSLv3 TLSv1; |
|
429 | ssl_protocols SSLv3 TLSv1; | |
428 | ssl_ciphers DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:EDH-RSA-DES-CBC3-SHA:AES256-SHA:DES-CBC3-SHA:AES128-SHA:RC4-SHA:RC4-MD5; |
|
430 | ssl_ciphers DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:EDH-RSA-DES-CBC3-SHA:AES256-SHA:DES-CBC3-SHA:AES128-SHA:RC4-SHA:RC4-MD5; | |
429 | ssl_prefer_server_ciphers on; |
|
431 | ssl_prefer_server_ciphers on; | |
430 |
|
432 | |||
431 | ## uncomment root directive if you want to serve static files by nginx |
|
433 | ## uncomment root directive if you want to serve static files by nginx | |
432 | ## requires static_files = false in .ini file |
|
434 | ## requires static_files = false in .ini file | |
433 | #root /srv/kallithea/kallithea/kallithea/public; |
|
435 | #root /srv/kallithea/kallithea/kallithea/public; | |
434 | include /etc/nginx/proxy.conf; |
|
436 | include /etc/nginx/proxy.conf; | |
435 | location / { |
|
437 | location / { | |
436 | try_files $uri @kallithea; |
|
438 | try_files $uri @kallithea; | |
437 | } |
|
439 | } | |
438 |
|
440 | |||
439 | location @kallithea { |
|
441 | location @kallithea { | |
440 | proxy_pass http://127.0.0.1:5000; |
|
442 | proxy_pass http://127.0.0.1:5000; | |
441 | } |
|
443 | } | |
442 |
|
444 | |||
443 | } |
|
445 | } | |
444 |
|
446 | |||
445 | Here's the proxy.conf. It's tuned so it will not timeout on long |
|
447 | Here's the proxy.conf. It's tuned so it will not timeout on long | |
446 | pushes or large pushes:: |
|
448 | pushes or large pushes:: | |
447 |
|
449 | |||
448 | proxy_redirect off; |
|
450 | proxy_redirect off; | |
449 | proxy_set_header Host $host; |
|
451 | proxy_set_header Host $host; | |
450 | ## needed for container auth |
|
452 | ## needed for container auth | |
451 | #proxy_set_header REMOTE_USER $remote_user; |
|
453 | #proxy_set_header REMOTE_USER $remote_user; | |
452 | #proxy_set_header X-Forwarded-User $remote_user; |
|
454 | #proxy_set_header X-Forwarded-User $remote_user; | |
453 | proxy_set_header X-Url-Scheme $scheme; |
|
455 | proxy_set_header X-Url-Scheme $scheme; | |
454 | proxy_set_header X-Host $http_host; |
|
456 | proxy_set_header X-Host $http_host; | |
455 | proxy_set_header X-Real-IP $remote_addr; |
|
457 | proxy_set_header X-Real-IP $remote_addr; | |
456 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
|
458 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
457 | proxy_set_header Proxy-host $proxy_host; |
|
459 | proxy_set_header Proxy-host $proxy_host; | |
458 | proxy_buffering off; |
|
460 | proxy_buffering off; | |
459 | proxy_connect_timeout 7200; |
|
461 | proxy_connect_timeout 7200; | |
460 | proxy_send_timeout 7200; |
|
462 | proxy_send_timeout 7200; | |
461 | proxy_read_timeout 7200; |
|
463 | proxy_read_timeout 7200; | |
462 | proxy_buffers 8 32k; |
|
464 | proxy_buffers 8 32k; | |
463 | client_max_body_size 1024m; |
|
465 | client_max_body_size 1024m; | |
464 | client_body_buffer_size 128k; |
|
466 | client_body_buffer_size 128k; | |
465 | large_client_header_buffers 8 64k; |
|
467 | large_client_header_buffers 8 64k; | |
466 |
|
468 | |||
467 | .. _apache_virtual_host_reverse_proxy: |
|
469 | .. _apache_virtual_host_reverse_proxy: | |
468 |
|
470 | |||
469 |
|
471 | |||
470 | Apache virtual host reverse proxy example |
|
472 | Apache virtual host reverse proxy example | |
471 | ----------------------------------------- |
|
473 | ----------------------------------------- | |
472 |
|
474 | |||
473 | Here is a sample configuration file for Apache using proxy: |
|
475 | Here is a sample configuration file for Apache using proxy: | |
474 |
|
476 | |||
475 | .. code-block:: apache |
|
477 | .. code-block:: apache | |
476 |
|
478 | |||
477 | <VirtualHost *:80> |
|
479 | <VirtualHost *:80> | |
478 | ServerName kallithea.example.com |
|
480 | ServerName kallithea.example.com | |
479 |
|
481 | |||
480 | <Proxy *> |
|
482 | <Proxy *> | |
481 | # For Apache 2.4 and later: |
|
483 | # For Apache 2.4 and later: | |
482 | Require all granted |
|
484 | Require all granted | |
483 |
|
485 | |||
484 | # For Apache 2.2 and earlier, instead use: |
|
486 | # For Apache 2.2 and earlier, instead use: | |
485 | # Order allow,deny |
|
487 | # Order allow,deny | |
486 | # Allow from all |
|
488 | # Allow from all | |
487 | </Proxy> |
|
489 | </Proxy> | |
488 |
|
490 | |||
489 | #important ! |
|
491 | #important ! | |
490 | #Directive to properly generate url (clone url) for Kallithea |
|
492 | #Directive to properly generate url (clone url) for Kallithea | |
491 | ProxyPreserveHost On |
|
493 | ProxyPreserveHost On | |
492 |
|
494 | |||
493 | #kallithea instance |
|
495 | #kallithea instance | |
494 | ProxyPass / http://127.0.0.1:5000/ |
|
496 | ProxyPass / http://127.0.0.1:5000/ | |
495 | ProxyPassReverse / http://127.0.0.1:5000/ |
|
497 | ProxyPassReverse / http://127.0.0.1:5000/ | |
496 |
|
498 | |||
497 | #to enable https use line below |
|
499 | #to enable https use line below | |
498 | #SetEnvIf X-Url-Scheme https HTTPS=1 |
|
500 | #SetEnvIf X-Url-Scheme https HTTPS=1 | |
499 | </VirtualHost> |
|
501 | </VirtualHost> | |
500 |
|
502 | |||
501 | Additional tutorial |
|
503 | Additional tutorial | |
502 | http://pylonsbook.com/en/1.1/deployment.html#using-apache-to-proxy-requests-to-pylons |
|
504 | http://pylonsbook.com/en/1.1/deployment.html#using-apache-to-proxy-requests-to-pylons | |
503 |
|
505 | |||
504 | .. _apache_subdirectory: |
|
506 | .. _apache_subdirectory: | |
505 |
|
507 | |||
506 |
|
508 | |||
507 | Apache as subdirectory |
|
509 | Apache as subdirectory | |
508 | ---------------------- |
|
510 | ---------------------- | |
509 |
|
511 | |||
510 | Apache subdirectory part: |
|
512 | Apache subdirectory part: | |
511 |
|
513 | |||
512 | .. code-block:: apache |
|
514 | .. code-block:: apache | |
513 |
|
515 | |||
514 | <Location /PREFIX > |
|
516 | <Location /PREFIX > | |
515 | ProxyPass http://127.0.0.1:5000/PREFIX |
|
517 | ProxyPass http://127.0.0.1:5000/PREFIX | |
516 | ProxyPassReverse http://127.0.0.1:5000/PREFIX |
|
518 | ProxyPassReverse http://127.0.0.1:5000/PREFIX | |
517 | SetEnvIf X-Url-Scheme https HTTPS=1 |
|
519 | SetEnvIf X-Url-Scheme https HTTPS=1 | |
518 | </Location> |
|
520 | </Location> | |
519 |
|
521 | |||
520 | Besides the regular apache setup you will need to add the following line |
|
522 | Besides the regular apache setup you will need to add the following line | |
521 | into ``[app:main]`` section of your .ini file:: |
|
523 | into ``[app:main]`` section of your .ini file:: | |
522 |
|
524 | |||
523 | filter-with = proxy-prefix |
|
525 | filter-with = proxy-prefix | |
524 |
|
526 | |||
525 | Add the following at the end of the .ini file:: |
|
527 | Add the following at the end of the .ini file:: | |
526 |
|
528 | |||
527 | [filter:proxy-prefix] |
|
529 | [filter:proxy-prefix] | |
528 | use = egg:PasteDeploy#prefix |
|
530 | use = egg:PasteDeploy#prefix | |
529 | prefix = /PREFIX |
|
531 | prefix = /PREFIX | |
530 |
|
532 | |||
531 | then change ``PREFIX`` into your chosen prefix |
|
533 | then change ``PREFIX`` into your chosen prefix | |
532 |
|
534 | |||
533 | .. _apache_mod_wsgi: |
|
535 | .. _apache_mod_wsgi: | |
534 |
|
536 | |||
535 |
|
537 | |||
536 | Apache with mod_wsgi |
|
538 | Apache with mod_wsgi | |
537 | -------------------- |
|
539 | -------------------- | |
538 |
|
540 | |||
539 | Alternatively, Kallithea can be set up with Apache under mod_wsgi. For |
|
541 | Alternatively, Kallithea can be set up with Apache under mod_wsgi. For | |
540 | that, you'll need to: |
|
542 | that, you'll need to: | |
541 |
|
543 | |||
542 | - Install mod_wsgi. If using a Debian-based distro, you can install |
|
544 | - Install mod_wsgi. If using a Debian-based distro, you can install | |
543 | the package libapache2-mod-wsgi:: |
|
545 | the package libapache2-mod-wsgi:: | |
544 |
|
546 | |||
545 | aptitude install libapache2-mod-wsgi |
|
547 | aptitude install libapache2-mod-wsgi | |
546 |
|
548 | |||
547 | - Enable mod_wsgi:: |
|
549 | - Enable mod_wsgi:: | |
548 |
|
550 | |||
549 | a2enmod wsgi |
|
551 | a2enmod wsgi | |
550 |
|
552 | |||
551 | - Add global Apache configuration to tell mod_wsgi that Python only will be |
|
553 | - Add global Apache configuration to tell mod_wsgi that Python only will be | |
552 | used in the WSGI processes and shouldn't be initialized in the Apache |
|
554 | used in the WSGI processes and shouldn't be initialized in the Apache | |
553 | processes:: |
|
555 | processes:: | |
554 |
|
556 | |||
555 | WSGIRestrictEmbedded On |
|
557 | WSGIRestrictEmbedded On | |
556 |
|
558 | |||
557 | - Create a WSGI dispatch script, like the one below. Make sure you |
|
559 | - Create a WSGI dispatch script, like the one below. Make sure you | |
558 | check that the paths correctly point to where you installed Kallithea |
|
560 | check that the paths correctly point to where you installed Kallithea | |
559 | and its Python Virtual Environment. |
|
561 | and its Python Virtual Environment. | |
560 |
|
562 | |||
561 | .. code-block:: python |
|
563 | .. code-block:: python | |
562 |
|
564 | |||
563 | import os |
|
565 | import os | |
564 | os.environ['PYTHON_EGG_CACHE'] = '/srv/kallithea/.egg-cache' |
|
566 | os.environ['PYTHON_EGG_CACHE'] = '/srv/kallithea/.egg-cache' | |
565 |
|
567 | |||
566 | # sometimes it's needed to set the current dir |
|
568 | # sometimes it's needed to set the current dir | |
567 | os.chdir('/srv/kallithea/') |
|
569 | os.chdir('/srv/kallithea/') | |
568 |
|
570 | |||
569 | import site |
|
571 | import site | |
570 | site.addsitedir("/srv/kallithea/venv/lib/python3.7/site-packages") |
|
572 | site.addsitedir("/srv/kallithea/venv/lib/python3.7/site-packages") | |
571 |
|
573 | |||
572 | ini = '/srv/kallithea/my.ini' |
|
574 | ini = '/srv/kallithea/my.ini' | |
573 | from logging.config import fileConfig |
|
575 | from logging.config import fileConfig | |
574 | fileConfig(ini, {'__file__': ini, 'here': '/srv/kallithea'}) |
|
576 | fileConfig(ini, {'__file__': ini, 'here': '/srv/kallithea'}) | |
575 | from paste.deploy import loadapp |
|
577 | from paste.deploy import loadapp | |
576 | application = loadapp('config:' + ini) |
|
578 | application = loadapp('config:' + ini) | |
577 |
|
579 | |||
578 | Or using proper virtualenv activation: |
|
580 | Or using proper virtualenv activation: | |
579 |
|
581 | |||
580 | .. code-block:: python |
|
582 | .. code-block:: python | |
581 |
|
583 | |||
582 | activate_this = '/srv/kallithea/venv/bin/activate_this.py' |
|
584 | activate_this = '/srv/kallithea/venv/bin/activate_this.py' | |
583 | execfile(activate_this, dict(__file__=activate_this)) |
|
585 | execfile(activate_this, dict(__file__=activate_this)) | |
584 |
|
586 | |||
585 | import os |
|
587 | import os | |
586 | os.environ['HOME'] = '/srv/kallithea' |
|
588 | os.environ['HOME'] = '/srv/kallithea' | |
587 |
|
589 | |||
588 | ini = '/srv/kallithea/kallithea.ini' |
|
590 | ini = '/srv/kallithea/kallithea.ini' | |
589 | from logging.config import fileConfig |
|
591 | from logging.config import fileConfig | |
590 | fileConfig(ini, {'__file__': ini, 'here': '/srv/kallithea'}) |
|
592 | fileConfig(ini, {'__file__': ini, 'here': '/srv/kallithea'}) | |
591 | from paste.deploy import loadapp |
|
593 | from paste.deploy import loadapp | |
592 | application = loadapp('config:' + ini) |
|
594 | application = loadapp('config:' + ini) | |
593 |
|
595 | |||
594 | - Add the necessary ``WSGI*`` directives to the Apache Virtual Host configuration |
|
596 | - Add the necessary ``WSGI*`` directives to the Apache Virtual Host configuration | |
595 | file, like in the example below. Notice that the WSGI dispatch script created |
|
597 | file, like in the example below. Notice that the WSGI dispatch script created | |
596 | above is referred to with the ``WSGIScriptAlias`` directive. |
|
598 | above is referred to with the ``WSGIScriptAlias`` directive. | |
597 | The default locale settings Apache provides for web services are often not |
|
599 | The default locale settings Apache provides for web services are often not | |
598 | adequate, with `C` as the default language and `ASCII` as the encoding. |
|
600 | adequate, with `C` as the default language and `ASCII` as the encoding. | |
599 | Instead, use the ``lang`` parameter of ``WSGIDaemonProcess`` to specify a |
|
601 | Instead, use the ``lang`` parameter of ``WSGIDaemonProcess`` to specify a | |
600 | suitable locale. See also the :ref:`overview` section and the |
|
602 | suitable locale. See also the :ref:`overview` section and the | |
601 | `WSGIDaemonProcess documentation`_. |
|
603 | `WSGIDaemonProcess documentation`_. | |
602 |
|
604 | |||
603 | Apache will by default run as a special Apache user, on Linux systems |
|
605 | Apache will by default run as a special Apache user, on Linux systems | |
604 | usually ``www-data`` or ``apache``. If you need to have the repositories |
|
606 | usually ``www-data`` or ``apache``. If you need to have the repositories | |
605 | directory owned by a different user, use the user and group options to |
|
607 | directory owned by a different user, use the user and group options to | |
606 | WSGIDaemonProcess to set the name of the user and group. |
|
608 | WSGIDaemonProcess to set the name of the user and group. | |
607 |
|
609 | |||
608 | Once again, check that all paths are correctly specified. |
|
610 | Once again, check that all paths are correctly specified. | |
609 |
|
611 | |||
610 | .. code-block:: apache |
|
612 | .. code-block:: apache | |
611 |
|
613 | |||
612 | WSGIDaemonProcess kallithea processes=5 threads=1 maximum-requests=100 \ |
|
614 | WSGIDaemonProcess kallithea processes=5 threads=1 maximum-requests=100 \ | |
613 | python-home=/srv/kallithea/venv lang=C.UTF-8 |
|
615 | python-home=/srv/kallithea/venv lang=C.UTF-8 | |
614 | WSGIProcessGroup kallithea |
|
616 | WSGIProcessGroup kallithea | |
615 | WSGIScriptAlias / /srv/kallithea/dispatch.wsgi |
|
617 | WSGIScriptAlias / /srv/kallithea/dispatch.wsgi | |
616 | WSGIPassAuthorization On |
|
618 | WSGIPassAuthorization On | |
617 |
|
619 | |||
618 | Or if using a dispatcher WSGI script with proper virtualenv activation: |
|
620 | Or if using a dispatcher WSGI script with proper virtualenv activation: | |
619 |
|
621 | |||
620 | .. code-block:: apache |
|
622 | .. code-block:: apache | |
621 |
|
623 | |||
622 | WSGIDaemonProcess kallithea processes=5 threads=1 maximum-requests=100 lang=en_US.utf8 |
|
624 | WSGIDaemonProcess kallithea processes=5 threads=1 maximum-requests=100 lang=en_US.utf8 | |
623 | WSGIProcessGroup kallithea |
|
625 | WSGIProcessGroup kallithea | |
624 | WSGIScriptAlias / /srv/kallithea/dispatch.wsgi |
|
626 | WSGIScriptAlias / /srv/kallithea/dispatch.wsgi | |
625 | WSGIPassAuthorization On |
|
627 | WSGIPassAuthorization On | |
626 |
|
628 | |||
627 |
|
629 | |||
628 | Other configuration files |
|
630 | Other configuration files | |
629 | ------------------------- |
|
631 | ------------------------- | |
630 |
|
632 | |||
631 | A number of `example init.d scripts`__ can be found in |
|
633 | A number of `example init.d scripts`__ can be found in | |
632 | the ``init.d`` directory of the Kallithea source. |
|
634 | the ``init.d`` directory of the Kallithea source. | |
633 |
|
635 | |||
634 | .. __: https://kallithea-scm.org/repos/kallithea/files/tip/init.d/ . |
|
636 | .. __: https://kallithea-scm.org/repos/kallithea/files/tip/init.d/ . | |
635 |
|
637 | |||
636 |
|
638 | |||
637 | .. _python: http://www.python.org/ |
|
639 | .. _python: http://www.python.org/ | |
638 | .. _Python regular expression documentation: https://docs.python.org/2/library/re.html |
|
640 | .. _Python regular expression documentation: https://docs.python.org/2/library/re.html | |
639 | .. _Mercurial: https://www.mercurial-scm.org/ |
|
641 | .. _Mercurial: https://www.mercurial-scm.org/ | |
640 | .. _Celery: http://celeryproject.org/ |
|
642 | .. _Celery: http://celeryproject.org/ | |
641 | .. _Celery documentation: http://docs.celeryproject.org/en/latest/getting-started/index.html |
|
643 | .. _Celery documentation: http://docs.celeryproject.org/en/latest/getting-started/index.html | |
642 | .. _RabbitMQ: http://www.rabbitmq.com/ |
|
644 | .. _RabbitMQ: http://www.rabbitmq.com/ | |
643 | .. _Redis: http://redis.io/ |
|
645 | .. _Redis: http://redis.io/ | |
644 | .. _mercurial-server: http://www.lshift.net/mercurial-server.html |
|
646 | .. _mercurial-server: http://www.lshift.net/mercurial-server.html | |
645 | .. _PublishingRepositories: https://www.mercurial-scm.org/wiki/PublishingRepositories |
|
647 | .. _PublishingRepositories: https://www.mercurial-scm.org/wiki/PublishingRepositories | |
646 | .. _WSGIDaemonProcess documentation: https://modwsgi.readthedocs.io/en/develop/configuration-directives/WSGIDaemonProcess.html |
|
648 | .. _WSGIDaemonProcess documentation: https://modwsgi.readthedocs.io/en/develop/configuration-directives/WSGIDaemonProcess.html |
General Comments 0
You need to be logged in to leave comments.
Login now