Changeset - ee37a78c6950
[Not reviewed]
stable
0 1 0
Thomas De Schampheleire - 7 years ago 2019-05-10 21:05:21
thomas.de_schampheleire@nokia.com
docs: move Apache+mod_wsgi example code to the corresponding bullets

The documentation about Apache+mod_wsgi has bullet points with inline
snippets, yet the example WSGI dispatch script is placed at the bottom of
the section instead of near its corresponding bullet.

It seems more readable and more according to the logical setup flow to move
the code next to its bullet.

Due to the additional indentation required to 'attach' the code to the
bullet, this commit is best viewed with the 'ignore whitespace changes'
setting.
1 file changed with 44 insertions and 47 deletions:
0 comments (0 inline, 0 general)
docs/setup.rst
Show inline comments
 
@@ -454,134 +454,131 @@ Apache as subdirectory
 

	
 
Apache subdirectory part:
 

	
 
.. code-block:: apache
 

	
 
    <Location /PREFIX >
 
      ProxyPass http://127.0.0.1:5000/PREFIX
 
      ProxyPassReverse http://127.0.0.1:5000/PREFIX
 
      SetEnvIf X-Url-Scheme https HTTPS=1
 
    </Location>
 

	
 
Besides the regular apache setup you will need to add the following line
 
into ``[app:main]`` section of your .ini file::
 

	
 
    filter-with = proxy-prefix
 

	
 
Add the following at the end of the .ini file::
 

	
 
    [filter:proxy-prefix]
 
    use = egg:PasteDeploy#prefix
 
    prefix = /PREFIX
 

	
 
then change ``PREFIX`` into your chosen prefix
 

	
 
.. _apache_mod_wsgi:
 

	
 

	
 
Apache with mod_wsgi
 
--------------------
 

	
 
Alternatively, Kallithea can be set up with Apache under mod_wsgi. For
 
that, you'll need to:
 

	
 
- Install mod_wsgi. If using a Debian-based distro, you can install
 
  the package libapache2-mod-wsgi::
 

	
 
    aptitude install libapache2-mod-wsgi
 

	
 
- Enable mod_wsgi::
 

	
 
    a2enmod wsgi
 

	
 
- Add global Apache configuration to tell mod_wsgi that Python only will be
 
  used in the WSGI processes and shouldn't be initialized in the Apache
 
  processes::
 

	
 
    WSGIRestrictEmbedded On
 

	
 
- Create a wsgi dispatch script, like the one below. Make sure you
 
- Create a WSGI dispatch script, like the one below. Make sure you
 
  check that the paths correctly point to where you installed Kallithea
 
  and its Python Virtual Environment.
 
- Enable the ``WSGIScriptAlias`` directive for the WSGI dispatch script,
 
  as in the following example. Once again, check the paths are
 
  correctly specified.
 

	
 
  .. code-block:: python
 

	
 
Here is a sample excerpt from an Apache Virtual Host configuration file:
 
      import os
 
      os.environ['PYTHON_EGG_CACHE'] = '/srv/kallithea/.egg-cache'
 

	
 
.. code-block:: apache
 
      # sometimes it's needed to set the current dir
 
      os.chdir('/srv/kallithea/')
 

	
 
    WSGIDaemonProcess kallithea processes=5 threads=1 maximum-requests=100 \
 
        python-home=/srv/kallithea/venv
 
    WSGIProcessGroup kallithea
 
    WSGIScriptAlias / /srv/kallithea/dispatch.wsgi
 
    WSGIPassAuthorization On
 
      import site
 
      site.addsitedir("/srv/kallithea/venv/lib/python2.7/site-packages")
 

	
 
Or if using a dispatcher WSGI script with proper virtualenv activation:
 
      ini = '/srv/kallithea/my.ini'
 
      from logging.config import fileConfig
 
      fileConfig(ini)
 
      from paste.deploy import loadapp
 
      application = loadapp('config:' + ini)
 

	
 
.. code-block:: apache
 
  Or using proper virtualenv activation:
 

	
 
    WSGIDaemonProcess kallithea processes=5 threads=1 maximum-requests=100
 
    WSGIProcessGroup kallithea
 
    WSGIScriptAlias / /srv/kallithea/dispatch.wsgi
 
    WSGIPassAuthorization On
 
  .. code-block:: python
 

	
 
Apache will by default run as a special Apache user, on Linux systems
 
usually ``www-data`` or ``apache``. If you need to have the repositories
 
directory owned by a different user, use the user and group options to
 
WSGIDaemonProcess to set the name of the user and group.
 
      activate_this = '/srv/kallithea/venv/bin/activate_this.py'
 
      execfile(activate_this, dict(__file__=activate_this))
 

	
 
Example WSGI dispatch script:
 
      import os
 
      os.environ['HOME'] = '/srv/kallithea'
 

	
 
.. code-block:: python
 

	
 
    import os
 
    os.environ['PYTHON_EGG_CACHE'] = '/srv/kallithea/.egg-cache'
 
      ini = '/srv/kallithea/kallithea.ini'
 
      from logging.config import fileConfig
 
      fileConfig(ini)
 
      from paste.deploy import loadapp
 
      application = loadapp('config:' + ini)
 

	
 
    # sometimes it's needed to set the current dir
 
    os.chdir('/srv/kallithea/')
 
- Enable the ``WSGIScriptAlias`` directive for the WSGI dispatch script, as in
 
  the following example from an Apache Virtual Host configuration file. Once
 
  again, check the paths are correctly specified.
 

	
 
    import site
 
    site.addsitedir("/srv/kallithea/venv/lib/python2.7/site-packages")
 
  .. code-block:: apache
 

	
 
    ini = '/srv/kallithea/my.ini'
 
    from logging.config import fileConfig
 
    fileConfig(ini)
 
    from paste.deploy import loadapp
 
    application = loadapp('config:' + ini)
 
      WSGIDaemonProcess kallithea processes=5 threads=1 maximum-requests=100 \
 
          python-home=/srv/kallithea/venv
 
      WSGIProcessGroup kallithea
 
      WSGIScriptAlias / /srv/kallithea/dispatch.wsgi
 
      WSGIPassAuthorization On
 

	
 
Or using proper virtualenv activation:
 
  Or if using a dispatcher WSGI script with proper virtualenv activation:
 

	
 
.. code-block:: python
 
  .. code-block:: apache
 

	
 
    activate_this = '/srv/kallithea/venv/bin/activate_this.py'
 
    execfile(activate_this, dict(__file__=activate_this))
 

	
 
    import os
 
    os.environ['HOME'] = '/srv/kallithea'
 
      WSGIDaemonProcess kallithea processes=5 threads=1 maximum-requests=100
 
      WSGIProcessGroup kallithea
 
      WSGIScriptAlias / /srv/kallithea/dispatch.wsgi
 
      WSGIPassAuthorization On
 

	
 
    ini = '/srv/kallithea/kallithea.ini'
 
    from logging.config import fileConfig
 
    fileConfig(ini)
 
    from paste.deploy import loadapp
 
    application = loadapp('config:' + ini)
 
  Apache will by default run as a special Apache user, on Linux systems
 
  usually ``www-data`` or ``apache``. If you need to have the repositories
 
  directory owned by a different user, use the user and group options to
 
  WSGIDaemonProcess to set the name of the user and group.
 

	
 

	
 
Other configuration files
 
-------------------------
 

	
 
A number of `example init.d scripts`__ can be found in
 
the ``init.d`` directory of the Kallithea source.
 

	
 
.. __: https://kallithea-scm.org/repos/kallithea/files/tip/init.d/ .
 

	
 

	
 
.. _virtualenv: http://pypi.python.org/pypi/virtualenv
 
.. _python: http://www.python.org/
 
.. _Python regular expression documentation: https://docs.python.org/2/library/re.html
 
.. _Mercurial: https://www.mercurial-scm.org/
 
.. _Celery: http://celeryproject.org/
 
.. _Celery documentation: http://docs.celeryproject.org/en/latest/getting-started/index.html
 
.. _RabbitMQ: http://www.rabbitmq.com/
 
.. _Redis: http://redis.io/
 
.. _mercurial-server: http://www.lshift.net/mercurial-server.html
 
.. _PublishingRepositories: https://www.mercurial-scm.org/wiki/PublishingRepositories
0 comments (0 inline, 0 general)