First, you will need to create a RhodeCode configuration file. Run the following command to do this:
paster make-config RhodeCode production.ini
Next, you need to create the databases used by RhodeCode. I recommend that you use sqlite (default) or postgresql. If you choose a database other than the default ensure you properly adjust the db url in your production.ini configuration file to use this other database. Create the databases by running the following command:
paster setup-app production.ini
This will prompt you for a “root” path. This “root” path is the location where RhodeCode will store all of its repositories on the current machine. After entering this “root” path setup-app will also prompt you for a username and password for the initial admin account which setup-app sets up for you.
You are now ready to use RhodeCode, to run it simply execute:
paster serve production.ini
Try copying your own mercurial repository into the “root” directory you are using, then from within the RhodeCode web application choose Admin > repositories. Then choose Add New Repository. Add the repository you copied into the root. Test that you can browse your repository from within RhodeCode and then try cloning your repository from RhodeCode with:
hg clone http://127.0.0.1:5000/<repository name>
where repository name is replaced by the name of your repository.
RhodeCode currently only hosts repositories using http and https. (The addition of ssh hosting is a planned future feature.) However you can easily use ssh in parallel with RhodeCode. (Repository access via ssh is a standard “out of the box” feature of mercurial and you can use this to access any of the repositories that RhodeCode is hosting. See PublishingRepositories)
RhodeCode repository structures are kept in directories with the same name as the project. When using repository groups, each group is a subdirectory. This allows you to easily use ssh for accessing repositories.
In order to use ssh you need to make sure that your web-server and the users login accounts have the correct permissions set on the appropriate directories. (Note that these permissions are independent of any permissions you have set up using the RhodeCode web interface.)
If your main directory (the same as set in RhodeCode settings) is for example set to /home/hg and the repository you are using is named rhodecode, then to clone via ssh you should run:
hg clone ssh://user@server.com/home/hg/rhodecode
Using other external tools such as mercurial-server or using ssh key based authentication is fully supported.
Note: In an advanced setup, in order for your ssh access to use the same permissions as set up via the RhodeCode web interface, you can create an authentication hook to connect to the rhodecode db and runs check functions for permissions against that.
Starting from version 1.1 the whoosh index can be build by using the paster command make-index. To use make-index you must specify the configuration file that stores the location of the index. You may specify the location of the repositories (–repo-location). If not specified, this value is retrieved from the RhodeCode database. This was required prior to 1.2. Starting from version 1.2 it is also possible to specify a comma separated list of repositories (–index-only) to build index only on chooses repositories skipping any other found in repos location
You may optionally pass the option -f to enable a full index rebuild. Without the -f option, indexing will run always in “incremental” mode.
For an incremental index build use:
paster make-index production.ini
For a full index rebuild use:
paster make-index production.ini -f
building index just for chosen repositories is possible with such command:
paster make-index production.ini --index-only=vcs,rhodecode
In order to do periodical index builds and keep your index always up to date. It’s recommended to do a crontab entry for incremental indexing. An example entry might look like this:
/path/to/python/bin/paster make-index /path/to/rhodecode/production.ini
When using incremental mode (the default) whoosh will check the last modification date of each file and add it to be reindexed if a newer file is available. The indexing daemon checks for any removed files and removes them from index.
If you want to rebuild index from scratch, you can use the -f flag as above, or in the admin panel you can check build from scratch flag.
RhodeCode starting from version 1.1 supports ldap authentication. In order to use LDAP, you have to install the python-ldap package. This package is available via pypi, so you can install it by running
using easy_install:
easy_install python-ldap
using pip:
pip install python-ldap
Note
python-ldap requires some certain libs on your system, so before installing it check that you have at least openldap, and sasl libraries.
LDAP settings are located in admin->ldap section,
Here’s a typical ldap setup:
Connection settings
Enable LDAP = checked
Host = host.example.org
Port = 389
Account = <account>
Password = <password>
Connection Security = LDAPS connection
Certificate Checks = DEMAND
Search settings
Base DN = CN=users,DC=host,DC=example,DC=org
LDAP Filter = (&(objectClass=user)(!(objectClass=computer)))
LDAP Search Scope = SUBTREE
Attribute mappings
Login Attribute = uid
First Name Attribute = firstName
Last Name Attribute = lastName
E-mail Attribute = mail
Defines the connection to LDAP server
How SSL certificates verification is handled - this is only useful when Enable LDAPS is enabled. Only DEMAND or HARD offer full SSL security while the other options are susceptible to man-in-the-middle attacks. SSL certificates can be installed to /etc/openldap/cacerts so that the DEMAND or HARD options can be used with self-signed certificates or certificates that do not have traceable certificates of authority.
This limits how far LDAP will search for a matching object.
The LDAP record attribute that will be matched as the USERNAME or ACCOUNT used to connect to RhodeCode. This will be added to LDAP Filter for locating the User object. If LDAP Filter is specified as “LDAPFILTER”, Login Attribute is specified as “uid” and the user has connected as “jsmith” then the LDAP Filter will be augmented as below
(&(LDAPFILTER)(uid=jsmith))
If all data are entered correctly, and python-ldap is properly installed users should be granted access to RhodeCode with ldap accounts. At this time user information is copied from LDAP into the RhodeCode user database. This means that updates of an LDAP user object may not be reflected as a user update in RhodeCode.
If You have problems with LDAP access and believe You entered correct information check out the RhodeCode logs, any error messages sent from LDAP will be saved there.
RhodeCode can use Microsoft Active Directory for user authentication. This is done through an LDAP or LDAPS connection to Active Directory. The following LDAP configuration settings are typical for using Active Directory
Base DN = OU=SBSUsers,OU=Users,OU=MyBusiness,DC=v3sys,DC=local
Login Attribute = sAMAccountName
First Name Attribute = givenName
Last Name Attribute = sn
E-mail Attribute = mail
All other LDAP settings will likely be site-specific and should be appropriately configured.
Hooks can be managed in similar way to this used in .hgrc files. To access hooks setting click advanced setup on Hooks section of Mercurial Settings in Admin.
There are 4 built in hooks that cannot be changed (only enable/disable by checkboxes on previos section). To add another custom hook simply fill in first section with <name>.<hook_type> and the second one with hook path. Example hooks can be found at rhodecode.lib.hooks.
Since version 1.1 celery is configured by the rhodecode ini configuration files. Simply set use_celery=true in the ini file then add / change the configuration variables inside the ini file.
Remember that the ini files use the format with ‘.’ not with ‘_’ like celery. So for example setting BROKER_HOST in celery means setting broker.host in the config file.
In order to start using celery run:
paster celeryd <configfile.ini>
Note
Make sure you run this command from the same virtualenv, and with the same user that rhodecode runs.
There are two ways to enable https:
Sample config for nginx using proxy:
server {
listen 80;
server_name hg.myserver.com;
access_log /var/log/nginx/rhodecode.access.log;
error_log /var/log/nginx/rhodecode.error.log;
location / {
root /var/www/rhodecode/rhodecode/public/;
if (!-f $request_filename){
proxy_pass http://127.0.0.1:5000;
}
#this is important if you want to use https !!!
proxy_set_header X-Url-Scheme $scheme;
include /etc/nginx/proxy.conf;
}
}
Here’s the proxy.conf. It’s tuned so it will not timeout on long pushes or large pushes:
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Host $http_host;
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.
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>
Additional tutorial http://wiki.pylonshq.com/display/pylonscookbook/Apache+as+a+reverse+proxy+for+Pylons
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
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.
Some example init.d scripts can be found here, for debian and gentoo:
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. |
Q: | Long lasting push timeouts? |
---|---|
A: | Make sure you set a longer timeouts in your proxy/fcgi settings, timeouts are caused by https server and not RhodeCode. |
Q: | Large pushes timeouts? |
---|---|
A: | Make sure you set a proper max_body_size for the http server. |
Q: | Apache doesn’t pass basicAuth on pull/push? |
---|---|
A: | Make sure you added WSGIPassAuthorization true. |
For further questions search the Issues tracker, or post a message in the google group rhodecode