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