Changeset - 662173ba1846
[Not reviewed]
beta
0 1 0
Augusto Herrmann - 14 years ago 2011-10-13 03:01:35
augusto.herrmann@planejamento.gov.br
Improvements to mod_wsgi setup documentation.
1 file changed with 30 insertions and 2 deletions:
0 comments (0 inline, 0 general)
docs/setup.rst
Show inline comments
 
@@ -422,50 +422,50 @@ pushes or large pushes::
 
    proxy_set_header            X-Real-IP $remote_addr;
 
    proxy_set_header            X-Forwarded-For $proxy_add_x_forwarded_for;
 
    proxy_set_header            Proxy-host $proxy_host;
 
    client_max_body_size        400m;
 
    client_body_buffer_size     128k;
 
    proxy_buffering             off;
 
    proxy_connect_timeout       7200;
 
    proxy_send_timeout          7200;
 
    proxy_read_timeout          7200;
 
    proxy_buffers               8 32k;
 
 
 
Also, when using root path with nginx you might set the static files to false
 
in the production.ini file::
 

	
 
    [app:main]
 
      use = egg:rhodecode
 
      full_stack = true
 
      static_files = false
 
      lang=en
 
      cache_dir = %(here)s/data
 

	
 
In order to not have the statics served by the application. This improves speed.
 

	
 

	
 
Apache virtual host example
 
---------------------------
 
Apache virtual host reverse proxy example
 
-----------------------------------------
 

	
 
Here is a sample configuration file for apache using proxy::
 

	
 
    <VirtualHost *:80>
 
            ServerName hg.myserver.com
 
            ServerAlias hg.myserver.com
 
    
 
            <Proxy *>
 
              Order allow,deny
 
              Allow from all
 
            </Proxy>
 
    
 
            #important !
 
            #Directive to properly generate url (clone url) for pylons
 
            ProxyPreserveHost On
 
    
 
            #rhodecode instance
 
            ProxyPass / http://127.0.0.1:5000/
 
            ProxyPassReverse / http://127.0.0.1:5000/
 
            
 
            #to enable https use line below
 
            #SetEnvIf X-Url-Scheme https HTTPS=1
 
            
 
    </VirtualHost> 
 
@@ -482,64 +482,92 @@ Apache subdirectory part::
 

	
 
    <Location /<someprefix> >
 
      ProxyPass http://127.0.0.1:5000/<someprefix>
 
      ProxyPassReverse http://127.0.0.1:5000/<someprefix>
 
      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 = /<someprefix> 
 

	
 

	
 
then change <someprefix> into your choosen prefix
 

	
 
Apache's WSGI config
 
--------------------
 

	
 
Alternatively, RhodeCode 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
 
- Create a wsgi dispatch script, like the one below. Make sure you
 
  check the paths correctly point to where you installed RhodeCode
 
  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.
 

	
 
Here is a sample excerpt from an Apache Virtual Host configuration file::
 

	
 
    WSGIDaemonProcess pylons user=www-data group=www-data processes=1 \
 
        threads=4 \
 
        python-path=/home/web/rhodecode/pyenv/lib/python2.6/site-packages
 
    WSGIScriptAlias / /home/web/rhodecode/dispatch.wsgi
 

	
 
Example wsgi dispatch script::
 

	
 
    import os
 
    os.environ["HGENCODING"] = "UTF-8"
 
    os.environ['PYTHON_EGG_CACHE'] = '/home/web/rhodecode/.egg-cache'
 
    
 
    # sometimes it's needed to set the curent dir
 
    os.chdir('/home/web/rhodecode/') 
 

	
 
    import site
 
    site.addsitedir("/home/web/rhodecode/pyenv/lib/python2.6/site-packages")
 
    
 
    from paste.deploy import loadapp
 
    from paste.script.util.logging_config import fileConfig
 

	
 
    fileConfig('/home/web/rhodecode/production.ini')
 
    application = loadapp('config:/home/web/rhodecode/production.ini')
 

	
 
Note: when using mod_wsgi you'll need to install the same version of
 
Mercurial that's inside RhodeCode's virtualenv also on the system's Python
 
environment.
 

	
 

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

	
 
Some example init.d scripts can be found here, for debian and gentoo:
 

	
 
https://rhodecode.org/rhodecode/files/tip/init.d
 

	
 

	
 
Troubleshooting
 
---------------
 

	
 
:Q: **Missing static files?**
 
:A: Make sure either to set the `static_files = true` in the .ini file or
 
   double check the root path for your http setup. It should point to 
 
   for example:
 
   /home/my-virtual-python/lib/python2.6/site-packages/rhodecode/public
 
   
 
| 
 

	
 
:Q: **Can't install celery/rabbitmq**
 
:A: Don't worry RhodeCode works without them too. No extra setup is required.
 

	
 
|
0 comments (0 inline, 0 general)