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

Revision 16 (André Domarques, 2015-01-08 19:57) → Revision 17/19 (André Domarques, 2015-01-08 19:59)

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": 

 h3. Last update 

 <pre>Date: 2015-01-08 
 Sumary: Updated to Redmine *2.6.0* and redmine_git_hosting *0.7.9*. 
 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 

 h3. Configuring Gitolite 

 <pre>dpkg-reconfigure gitolite</pre> 

 Type data bellow: 

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

 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/ /opt/redmine/.ssh/</pre> 

 Or even using ssh -i identity_file (check for more details) 

 h3. Visudo configuration 


 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 ~ 
 tar zxf redmine-2.6.0.tar.gz 
 mv redmine-2.6.0/* . 
 rm -Rf redmine-2.6.0 

 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:  

 h4. Finishing the installation 

 Create plugin assets directory 

 <pre>cd ~ 
 mkdir public/plugin_assets 

 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: 

 h4. Download 

 <pre>cd ~/plugins 
 git clone 
 git clone 
 cd redmine_git_hosting 
 git checkout v0.7.9</pre> 

 h4. Create symlinks 

 The current version of the plugin (0.7.9) 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/ /opt/redmine/plugins/redmine_git_hosting/ssh_keys/</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 

 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 

 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: 

 # 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 

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

 h5. Set the available repositories 

 Administration > Settings > 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 

 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 

 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: 

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

 h4. Plugin  

 You also must check, regarding the plugin: 

 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 


 <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 


 <pre>dpkg -l 

 ii    apache2                              2.2.22-13+deb7u3 
 ii    git                                  1: 
 ii    gitolite                             2.3-1 
 ii    libapache2-mod-passenger             3.0.13debian-1+deb7u2 
 ii    imagemagick                          8: 
 ii    mysql-server                         5.5.40-0+wheezy1 
 ii    ruby-dev                             1:1.9.3 

 <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 
     - ruby 
     - x86_64-linux 
   - GEM PATHS: 
      - /var/lib/gems/1.9.1 
      - /opt/redmine/.gem/ruby/1.9.1 
      - :update_sources => true 
      - :verbose => true 
      - :benchmark => false 
      - :backtrace => false 
      - :bulk_threshold => 1000 

 Hope this helps =D.