HowTo Install Redmine 2 integrated with Gitolite 2 on Debian Wheezy with Apache and Phusion Passenger » History » Version 16

Version 15 (André Domarques, 2014-09-12 14:31) → Version 16/19 (André Domarques, 2015-01-08 19:57)

h2. HowTo Install Redmine 2 integrated with Gitolite 2 on Debian Wheezy with Apache and Phusion Passenger

h3. About

A quick step-by-step for install Redmine and Gitolite plugin on Debian Wheezy mainly using default packages.

If I missed something, "let me know":http://www.redmine.org/users/85560

h3. Last update

<pre>Date: 2015-01-08 2014-09-12
Sumary: Updated to Redmine *2.6.0* *2.5.2* and redmine_git_hosting *0.7.9*. *0.7.7*.
See doc history for more info and/or instructions for redmine_git_hosting 0.6.x (deprecated).</pre>

h3. Required packages

<pre>aptitude update && aptitude -y install sudo ssh bzip2 zip unzip apache2 libapache2-mod-passenger mysql-server libmysqlclient-dev ruby ruby-dev git git-core gitolite imagemagick libmagickcore-dev libmagickwand-dev libicu-dev</pre>

h3. Users and ssh-key

Create an user for Redmine (*redmine*) and another for Gitolite (*git*):

<pre>adduser --system --shell /bin/bash --gecos 'Git Administrator' --group --disabled-password --home /opt/gitolite git
adduser --system --shell /bin/bash --gecos 'Redmine Administrator' --group --disabled-password --home /opt/redmine redmine</pre>

Generate a ssh-key for *redmine* user. This user will be used as admin of Gitolite. The name of key should be *redmine_gitolite_admin_id_rsa*.

<pre>su redmine
ssh-keygen -t rsa -N '' -f ~/.ssh/redmine_gitolite_admin_id_rsa
exit</pre>

h3. Configuring Gitolite

<pre>dpkg-reconfigure gitolite</pre>

Type data bellow:

* user: git
* repos path: /opt/gitolite
* admin ssh-key: /opt/redmine/.ssh/redmine_gitolite_admin_id_rsa.pub

h4. Note about SSH

Click bellow to expand.

{{collapse(Note about SSH)

If you try to connect gitolite (user: *git*) using *redmine* user via ssh, will be prompted password... See what happens:

<pre>redmine@redmine:~$ ssh -v git@localhost
...
The authenticity of host 'localhost (::1)' can't be established.
ECDSA key fingerprint is d5:da:b9:10:c4:9b:51:75:65:f3:64:81:b5:6c:1a:1a.
Are you sure you want to continue connecting (yes/no)? yes
...
...
*debug1: Trying private key: /opt/redmine/.ssh/id_rsa*
*debug1: Trying private key: /opt/redmine/.ssh/id_dsa*
*debug1: Trying private key: /opt/redmine/.ssh/id_ecdsa*
debug1: Next authentication method: password
git@localhost's password:</pre>

You can solve this by simply creating a symbolic link:

<pre>su redmine
ln -s /opt/redmine/.ssh/redmine_gitolite_admin_id_rsa /opt/redmine/.ssh/id_rsa
ln -s /opt/redmine/.ssh/redmine_gitolite_admin_id_rsa.pub /opt/redmine/.ssh/id_rsa.pub</pre>

Or even using ssh -i identity_file (check http://unixhelp.ed.ac.uk/CGI/man-cgi?ssh+1 for more details)
}}

h3. Visudo configuration

<pre>visudo</pre>

Add the following lines:

<pre># temp - *REMOVE* after installation
redmine ALL=(ALL) NOPASSWD:ALL

# redmine gitolite integration
redmine ALL=(git) NOPASSWD:ALL
git ALL=(redmine) NOPASSWD:ALL</pre>

Note that redmine user will be able to run root commands, but this is just to simplify the next steps. *REMOVE* this line after installation.

h3. Redmine installation

The installation and configuration is like the official documentation. Simply reproducing to maintain the flow on this how-to.

h4. Download

<pre>sudo su - redmine
cd ~
wget http://www.redmine.org/releases/redmine-2.6.0.tar.gz http://www.redmine.org/releases/redmine-2.5.2.tar.gz
tar zxf redmine-2.6.0.tar.gz redmine-2.5.2.tar.gz
mv redmine-2.6.0/* redmine-2.5.2/* .
rm -Rf redmine-2.6.0 redmine-2.5.2
</pre>

h4. Create database and user

<pre>mysql -u root -p -v -e "CREATE DATABASE redmine CHARACTER SET utf8;
CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'redmine';
GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';"</pre>

h4. Configure database and email

<pre>cd /opt/redmine/config
cp database.yml.example database.yml
cp configuration.yml.example configuration.yml</pre>

Check more at:
* http://www.redmine.org/projects/redmine/wiki/RedmineInstall#Step-3-Database-connection-configuration
* http://www.redmine.org/projects/redmine/wiki/RedmineInstall#Configuration

h4. Finishing the installation

Create plugin assets directory

<pre>cd ~
mkdir public/plugin_assets
</pre>

Now, complete the installation.

<pre>sudo gem install bundler
bundle install --without development test postgresql sqlite
rake generate_secret_token
RAILS_ENV=production rake db:migrate
RAILS_ENV=production rake redmine:load_default_data</pre>

h3. Redmine Gitolite integration

The plugin used on this how-to is the fork of JBox Web, you can get more information at:
* http://www.redmine.org/plugins/redmine_git_hosting
* http://jbox-web.github.io/redmine_git_hosting/
* https://github.com/jbox-web/redmine_git_hosting

h4. Download

<pre>cd ~/plugins
git clone https://github.com/jbox-web/redmine_bootstrap_kit.git
git clone https://github.com/jbox-web/redmine_git_hosting.git
cd redmine_git_hosting
git checkout v0.7.9</pre> v0.7.7&lt;/pre&gt;

h4. Create symlinks

The current version of the plugin (0.7.9) (0.7.7) now uses the directory /opt/redmine/plugins/redmine_git_hosting/ssh_keys/ to keep the ssh keys. So let's just create some symbolic links:

<pre>ln -s /opt/redmine/.ssh/redmine_gitolite_admin_id_rsa /opt/redmine/plugins/redmine_git_hosting/ssh_keys/redmine_gitolite_admin_id_rsa
ln -s /opt/redmine/.ssh/redmine_gitolite_admin_id_rsa.pub /opt/redmine/plugins/redmine_git_hosting/ssh_keys/redmine_gitolite_admin_id_rsa.pub</pre>

h4. Configure GL_GITCONFIG_KEYS

This version now use some hooks that, by default on gitolite *v2*, will be blocked by the var GL_GITCONFIG_KEYS. On gitolite *v3*, this var is named GIT_CONFIG_KEYS.

<pre>sudo su - git
sed -i 's/$GL_GITCONFIG_KEYS = ""/$GL_GITCONFIG_KEYS = ".*"/g' /opt/gitolite/.gitolite.rc
exit</pre>

h4. Configure Automatic Repository Initialization (optional)

To configure the new feature "Automatic Repository Initialization" (optional), is necessary to customize the gitolite.conf file.

<pre>cd ~
git clone git@localhost:gitolite-admin.git
cd gitolite-admin/
echo "repo @all
RW+ = admin" >> conf/gitolite.conf
git commit -m 'Automatic Repository Initialization' conf/gitolite.conf
git push
cd ~
rm -rf gitolite-admin</pre>

Remember that this repository will be managed by redmine and their plugin.

h4. Plugin installation

It's necessary to run bundle again to install some new gems required by the plugins.

<pre>cd ~
bundle install --without development
RAILS_ENV=production rake redmine:plugins:migrate
</pre>

h3. Apache mod_passenger configuration

Create a symbolic link, configure and enable the site and restart apache.

<pre>su root
cd /var/www
ln -s /opt/redmine/public redmine
echo "RailsBaseURI /redmine
PassengerUserSwitching on
PassengerUser redmine
PassengerGroup redmine" > /etc/apache2/sites-available/redmine
a2ensite redmine
service apache2 reload</pre>

h3. Post-install configuration tasks

Remember to remove the sudo temp configuration:

<pre>visudo
# temp - *REMOVE* after installation
redmine ALL=(ALL) NOPASSWD:ALL</pre>

You'll need to do some configuration on Redmine and git_hosting plugin.

h4. Redmine

Configure the Redmine default URL (*important*):

Administration > Settings > General
http://your_ip_or_fqdn/redmine/settings?tab=general

This is set, by default, to localhost:3000, change it to your IP or FQDN.

h5. Set the available repositories

Administration > Settings > Repositories
http://your_ip_or_fqdn/redmine/settings?tab=repositories

Uncheck what you don't have installed on your system. Just to avoid unnecessary log messages.

h4. Redmine Git Hosting Plugin

h5. First of all, check the configuration

Administration > Redmine Git Hosting Plugin > Config Test
http://your_ip_or_fqdn/redmine/settings/plugin/redmine_git_hosting?tab=gitolite_config_test

Ensure if all settings are correct (users, paths, versions etc.).

h5. Set your IP or FQDN to SSH, HTTP and/or HTTPS

Administration > Redmine Git Hosting Plugin > Acess
http://your_ip_or_fqdn/redmine/settings/plugin/redmine_git_hosting?tab=gitolite_config_access

Those settings will be also used on git operations (clone, pull, push etc.).

h3. Troubleshooting

h4. Logs

If you have some trouble during the installation, you can check the following files:

* /opt/gitolite/.gitolite/logs/gitolite-`date +%Y\-%m`.log
* /opt/redmine/log/git_hosting.log
* /var/log/apache2/error.log

If you use multitail:

<pre>
multitail /opt/gitolite/.gitolite/logs/gitolite-`date +%Y\-%m`.log /opt/redmine/log/git_hosting.log /var/log/apache2/error.log
</pre>

h4. Plugin

You also must check, regarding the plugin:

https://github.com/jbox-web/redmine_git_hosting/wiki/Troubleshooting

h4. Environment details

Click bellow to expand.

{{collapse(Environment details)

Debian Wheezy (netinst iso - installed only with basic packages and ssh server profiles)

<pre>cat /etc/debian_version

7.5</pre>

<pre>uname -a

Linux redmine 3.2.0-4-amd64 #1 SMP Debian 3.2.57-3+deb7u2 x86_64 GNU/Linux</pre>

<pre>cat /etc/hostname

redmine</pre>

<pre>dpkg -l

ii apache2 2.2.22-13+deb7u3 2.2.22-13+deb7u1
ii git 1:1.7.10.4-1+wheezy1
ii gitolite 2.3-1
ii libapache2-mod-passenger 3.0.13debian-1+deb7u2
ii imagemagick libmagickcore-dev 8:6.7.7.10-5+deb7u3
ii libmagickwand-dev 8:6.7.7.10-5+deb7u3
ii
mysql-server 5.5.40-0+wheezy1 5.5.37-0+wheezy1
ii ruby-dev 1:1.9.3
</pre>

<pre>gem env

RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23
- RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [x86_64-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.9.1
- RUBY EXECUTABLE: /usr/bin/ruby1.9.1
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/1.9.1
- /opt/redmine/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/</pre>
}}

Hope this helps =D.