📜 ⬆️ ⬇️

Rhodecode + Redmine - an inexpensive and functional replacement of hosting software projects on the side

Introduction


There are enterprises where Internet access is severely limited or not permanent, I do not envy these guys. Sometimes, as in my case, the enterprise security policy does not allow to store the source code of the products being developed on someone else’s equipment. In addition, I dare to suggest that not every group of developers has enough opportunities provided for example bitbucket . These problems can be solved, for example, with a bunch of RhodeCode and Redmine .

Goals



Products Used


After some thought and on the basis of some experience, a set of tools was identified to achieve the goals set:

  1. Version Control - Mercurial
  2. Project Management - Redmine
  3. Version Control System Repositories - RhodeCode
  4. Well, it will start all this on Debian

Step 0: Install debian (or ubuntu)


Everything described below was done on debian squezee in the base installation.
On ubuntu (10.04 LTS) it should be unchanged, since their package base is similar.
')

Step 1: Install RhodeCode


Install the necessary packages for easy_install and virtualenv:

aptitude install python-setuptools python-dev python-virtualenv

Using virtualenv, create a new virtual environment:

virtualenv --no-site-packages /var/www/rhodecode-venv

A new virtual environment will be created in the / var / www / rhodecode-venv directory.
Activate the virtual environment with the command:

source /var/www/rhodecode-venv/bin/activate

Create a directory for rhodecode, for example:

mkdir /var/www/rhodecode; cd /var/www/rhodecode

To install RhodeCode, run the following command:

easy_install rhodecode

At this stage, the easy_install script will install all the necessary dependencies for RhodeCode in a virtual environment, including the latest stable version of mercurial.

Step 2: Configure RhodeCode


Create the RhodeCode configuration file:

paster make-config RhodeCode production.ini

This configuration file contains various settings for RhodeCode, for example, proxy port, email, use of static files, cache, celery settings and logging. By default, SQLite is used as the database.

Create a database by running the following command:

paster setup-app production.ini

At the script request, enter the path to the directory where RhodeCode will host the database:

/var/www/rhodecode/

Next, enter the username, password, and email to the application administrator account. The database creation command will create all the necessary tables and an administrator account.

For our configuration, you need to add the following lines in production.ini:

1) in the [app: main] section:

  filter-with = proxy-prefix
 force_https = true 

2) at the end of the file:

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

Leave the virtual environment:

deactivate

Create the /etc/init.d/rhodecode-daemon startup script:

 #! / bin / sh -e
 ########################################
 #### THIS IS A DEBIAN INIT.D SCRIPT ####
 ########################################
 ### BEGIN INIT INFO
 # Provides: rhodecode          
 # Required-Start: $ all
 # Required-Stop: $ all
 # Default-Start: 2 3 4 5
 # Default-Stop: 0 1 6
 # Short-Description: starts instance of rhodecode
 # Description: starts instance of rhodecode using start-stop-daemon
 ### END INIT INFO
 APP_NAME = "rhodecode"
 APP_HOMEDIR = "/ var / www"
 APP_PATH = "$ APP_HOMEDIR / $ APP_NAME"
 CONF_NAME = "production.ini"
 PID_PATH = "$ APP_PATH / $ APP_NAME.pid"
 LOG_PATH = "$ APP_PATH / $ APP_NAME.log"
 PYTHON_PATH = "/ var / www / rhodecode-venv"
 RUN_AS = "www-data"
 DAEMON = "$ PYTHON_PATH / bin / paster"
 DAEMON_OPTS = "serve --daemon \
   --user = $ RUN_AS \
   --group = $ RUN_AS \
   --pid-file = $ PID_PATH \
   --log-file = $ LOG_PATH $ APP_PATH / $ CONF_NAME "
 start () {
   echo "Starting $ APP_NAME"
   PYTHON_EGG_CACHE = "/ tmp" start-stop-daemon -d $ APP_PATH \
       --start --quiet \
       --pidfile $ PID_PATH \
       --user $ RUN_AS \
       --exec $ DAEMON - $ DAEMON_OPTS
 }
 stop () {
   echo "Stopping $ APP_NAME"
   start-stop-daemon -d $ APP_PATH \
       --stop --quiet \
       --pidfile $ PID_PATH ||  echo "$ APP_NAME - Not running!"
   if [-f $ PID_PATH];  then
     rm $ PID_PATH
   fi
 }
 case "$ 1" in
   start)
     start
     ;;
   stop)
     stop
     ;;
   restart)
     echo "Restarting $ APP_NAME"
     ### stop ###
     stop
     wait
     ### start ###
     start
     ;;
   *)
     echo "Usage: $ 0 {start | stop | restart}"
     exit 1
 esac 

Assign the necessary access rights:

  chmod a + x /etc/init.d/rhodecode-daemon 
 chown www-data: www-data -R / var / www / rhodecode 

To run the script automatically, run:

insserv rhodecode-daemon

Step 3: Install Redmine


In the squeeze-backports version of redmine newer, install it.

Include in /etc/apt/sources.list:

 deb http://backports.debian.org/debian-backports squeeze-backports main contrib non-free 

Run in console:

  aptitude update
 aptitude -t squeeze-backports install redmine mercurial 

The installation process will display the database selection dialog. I preferred sqlite, make your choice.

Create a link in the / var / www directory:

  ln -s / usr / share / redmine / public / var / www / redmine
 chown -R www-data: www-data / var / www / redmine 

Step 4: configure apache


Install apache mod passenger to run redmine:

aptitude install libapache2-mod-passenger

Create a private key and certificate:

openssl req -new -x509 -days 355 -keyout your.domain.ru.key -out your.domain.ru.pem

Common Name should be exactly the same as your server domain name.

Delete password:

  cp your.domain.ru.key your.domain.ru.key.orig
 openssl rsa -in your.domain.ru.key.orig -out your.domain.ru.key
 rm your.domain.ru.key.orig 

Copy to / etc / ssl:

cp your.domain.ru.pem /etc/ssl/certs/; cp your.domain.ru.key /etc/ssl/private/

Include the necessary modules:

  a2enmod ssl
 a2enmod proxy
 a2enmod proxy_http 

In the file / etc / apache2 / sites-available / default-ssl replace:

  SSLCertificateFile /etc/ssl/certs/your.domain.ru.pem
 SSLCertificateKeyFile /etc/ssl/private/your.domain.ru.key 

We enter in the main section (VirtualHost) of the same file line:

1) for redmine:

RailsBaseURI /redmine

2) for rhodecode:
  <Location /hg > ProxyPass http://127.0.0.1:5000/hg ProxyPassReverse http://127.0.0.1:5000/hg SetEnvIf X-Url-Scheme https HTTPS=1 </Location> 

Replace the contents of the / etc / apache2 / sites-available / default file with:

 <VirtualHost *:80> ServerName your.domain.ru Redirect permanent / https://your.domain.ru/ </VirtualHost> 

Enable the default-ssl configuration:

a2ensite default-ssl

Run rhodecode:

service rhodecode-daemon start

Restart apache:

service apache2 restart

Result


RhodeCode is available at:
  https://your.domain.ru/hg password set in step 2 

Redmine is available at:
  https://your.domain.ru/redmine admin admin, password admin 

Forced https everywhere.

Bibliography


  1. HowTo Install Redmine using Debian package.
  2. RhodeCode 1.3.3 documentation. Installation.
  3. RhodeCode 1.3.3 documentation. Setup.
  4. A simple way to configure Apache to work on HTTPS in Debian.


UPD: To fix the error of the Redmine integration with the repository created in Rhodecode, install the version of mercurial (2.0.1) from squezee-backports:
  aptitude -t squeeze-backports install mercurial 

Source: https://habr.com/ru/post/140917/


All Articles