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

André Domarques, 2013-09-12 07:50

1 1 André Domarques
h1. HowTo Install Redmine 2 integrated with Gitolite 2 on Debian Wheezy with Apache and Phusion Passenger
2 1 André Domarques
3 5 André Domarques
h2. About
4 1 André Domarques
5 1 André Domarques
A quick step-by-step for install Redmine and Gitolite plugin on Debian Wheezy mainly using default packages.
6 1 André Domarques
7 5 André Domarques
If I missed something, "let me know":http://www.redmine.org/users/85560
8 1 André Domarques
9 1 André Domarques
h2. Required packages
10 1 André Domarques
11 1 André Domarques
<pre>apt-get -y install sudo ssh bzip2 zip unzip apache2 libapache2-mod-passenger mysql-server libmysqlclient-dev ruby ruby1.9.1-dev git git-core gitolite libmagickcore-dev libmagickwand-dev</pre>
12 1 André Domarques
13 1 André Domarques
h2. Users and ssh-key
14 1 André Domarques
15 1 André Domarques
Create an user for Redmine and another for Gitolite:
16 1 André Domarques
17 1 André Domarques
<pre>adduser --system --shell /bin/bash --gecos 'Git Administrator' --group --disabled-password --home /opt/gitolite git
18 1 André Domarques
adduser --system --shell /bin/bash --gecos 'Redmine Administrator' --group --disabled-password --home /opt/redmine redmine</pre>
19 1 André Domarques
20 9 André Domarques
Generate a ssh-key for *redmine* user. This user will be used as admin of Gitolite. The name of key should be *gitolite_admin_id_rsa*.
21 1 André Domarques
22 1 André Domarques
<pre>sudo su - redmine
23 8 André Domarques
ssh-keygen -t rsa -N '' -f ~/.ssh/gitolite_admin_id_rsa
24 1 André Domarques
exit</pre>
25 1 André Domarques
26 1 André Domarques
h2. Configuring Gitolite
27 1 André Domarques
28 1 André Domarques
<pre>dpkg-reconfigure gitolite</pre>
29 1 André Domarques
30 1 André Domarques
Type data bellow:
31 1 André Domarques
32 5 André Domarques
* user: git
33 5 André Domarques
* repos path: /opt/gitolite
34 8 André Domarques
* admin ssh-key: /opt/redmine/.ssh/gitolite_admin_id_rsa.pub
35 1 André Domarques
36 3 André Domarques
{{collapse(Note about SSH)
37 2 André Domarques
38 7 André Domarques
If you try to connect gitolite (user: git) using redmine user via ssh, will be prompted password... OMG! See what happens:
39 1 André Domarques
40 4 André Domarques
<pre>redmine@redmine:~$ ssh -v git@localhost
41 1 André Domarques
...
42 1 André Domarques
The authenticity of host 'localhost (::1)' can't be established.
43 1 André Domarques
ECDSA key fingerprint is d5:da:b9:10:c4:9b:51:75:65:f3:64:81:b5:6c:1a:1a.
44 1 André Domarques
Are you sure you want to continue connecting (yes/no)? yes
45 1 André Domarques
...
46 1 André Domarques
...
47 1 André Domarques
*debug1: Trying private key: /opt/redmine/.ssh/id_rsa*
48 1 André Domarques
*debug1: Trying private key: /opt/redmine/.ssh/id_dsa*
49 1 André Domarques
*debug1: Trying private key: /opt/redmine/.ssh/id_ecdsa*
50 1 André Domarques
debug1: Next authentication method: password
51 4 André Domarques
git@localhost's password:</pre>
52 1 André Domarques
53 1 André Domarques
You can solve this by simply creating a symbolic link:
54 1 André Domarques
55 8 André Domarques
<pre>ln -s /opt/redmine/.ssh/gitolite_admin_id_rsa /opt/redmine/.ssh/id_rsa</pre>
56 1 André Domarques
57 1 André Domarques
Or even using ssh -i identity_file (check http://unixhelp.ed.ac.uk/CGI/man-cgi?ssh+1 for more details)
58 2 André Domarques
59 1 André Domarques
}}
60 1 André Domarques
61 4 André Domarques
h2. Visudo configuration
62 1 André Domarques
63 1 André Domarques
<pre>visudo</pre>
64 1 André Domarques
65 1 André Domarques
Add the following lines:
66 1 André Domarques
67 1 André Domarques
<pre># temp - remove after installation
68 1 André Domarques
redmine    ALL=(ALL)      NOPASSWD:ALL
69 1 André Domarques
70 1 André Domarques
# redmine gitolite integration
71 1 André Domarques
redmine    ALL=(git)      NOPASSWD:ALL
72 1 André Domarques
git        ALL=(redmine)  NOPASSWD:ALL</pre>
73 1 André Domarques
74 1 André Domarques
Note that redmine user will be able to run root commands, but this is just to simplify the next steps, remove that line after installation.
75 1 André Domarques
76 1 André Domarques
h2. Redmine installation
77 1 André Domarques
78 1 André Domarques
The installation and configuration is like the official documentation. Simply reproducing to maintain the flow on this how-to.
79 1 André Domarques
80 1 André Domarques
<pre>sudo su - redmine
81 1 André Domarques
cd ~
82 1 André Domarques
wget http://rubyforge.org/frs/download.php/77023/redmine-2.3.2.tar.gz
83 1 André Domarques
tar zxf redmine-2.3.2.tar.gz
84 1 André Domarques
mv redmine-2.3.2/* .
85 1 André Domarques
rm -Rf redmine-2.3.2
86 1 André Domarques
</pre>
87 1 André Domarques
88 1 André Domarques
h3. Create database and user
89 1 André Domarques
90 1 André Domarques
<pre>mysql -u root -p
91 1 André Domarques
92 1 André Domarques
CREATE DATABASE redmine CHARACTER SET utf8;
93 1 André Domarques
CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'redmine';
94 1 André Domarques
GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';</pre>
95 1 André Domarques
96 1 André Domarques
h3. Configure database and email
97 1 André Domarques
98 1 André Domarques
<pre>cd /opt/redmine/config
99 1 André Domarques
cp database.yml.example database.yml
100 1 André Domarques
cp configuration.yml.example configuration.yml</pre>
101 1 André Domarques
102 1 André Domarques
Check more at: 
103 1 André Domarques
* http://www.redmine.org/projects/redmine/wiki/RedmineInstall#Step-3-Database-connection-configuration
104 1 André Domarques
* http://www.redmine.org/projects/redmine/wiki/RedmineInstall#Configuration
105 1 André Domarques
106 1 André Domarques
Create plugin assets directory
107 1 André Domarques
108 1 André Domarques
<pre>cd ~
109 1 André Domarques
mkdir public/plugin_assets
110 1 André Domarques
</pre>
111 1 André Domarques
112 1 André Domarques
Now finish the installation.
113 1 André Domarques
114 1 André Domarques
<pre>sudo gem install bundler
115 1 André Domarques
bundle install --without development test postgresql sqlite
116 1 André Domarques
rake generate_secret_token
117 1 André Domarques
RAILS_ENV=production rake db:migrate
118 1 André Domarques
RAILS_ENV=production rake redmine:load_default_data</pre>
119 1 André Domarques
120 1 André Domarques
h2. Redmine Gitolite integration
121 1 André Domarques
122 1 André Domarques
The plugin used on this how-to is the fork of jbox-web, you can get more information at:
123 4 André Domarques
* http://www.redmine.org/plugins/redmine-gitolite
124 4 André Domarques
* http://jbox-web.github.io/redmine_git_hosting/
125 4 André Domarques
* https://github.com/jbox-web/redmine_git_hosting
126 1 André Domarques
127 1 André Domarques
Download.
128 1 André Domarques
129 1 André Domarques
<pre>cd ~/plugins
130 1 André Domarques
git clone https://github.com/jbox-web/redmine_git_hosting.git</pre>
131 1 André Domarques
132 1 André Domarques
Install. It's necessary to run bundle again to install some new gems required by redmine_git_hosting plugin.
133 1 André Domarques
134 1 André Domarques
<pre>cd ~
135 1 André Domarques
bundle install
136 1 André Domarques
RAILS_ENV=production rake redmine:plugins:migrate
137 1 André Domarques
rake redmine_git_hosting:install_scripts RAILS_ENV=production WEB_USER=redmine</pre>
138 1 André Domarques
139 1 André Domarques
h2. Apache mod_passenger configuration
140 1 André Domarques
141 1 André Domarques
Create a symbolic link.
142 1 André Domarques
143 1 André Domarques
<pre>su root
144 1 André Domarques
cd /var/www
145 1 André Domarques
ln -s /opt/redmine/public redmine</pre>
146 1 André Domarques
147 4 André Domarques
Configure the site.
148 1 André Domarques
149 1 André Domarques
<pre>vi /etc/apache2/sites-available/redmine</pre>
150 4 André Domarques
151 4 André Domarques
With following content:
152 4 André Domarques
153 4 André Domarques
<pre>RailsBaseURI /redmine
154 1 André Domarques
PassengerUserSwitching on
155 1 André Domarques
PassengerUser redmine
156 4 André Domarques
PassengerGroup redmine</pre>
157 1 André Domarques
158 1 André Domarques
Enable the site and restart apache.
159 1 André Domarques
160 1 André Domarques
<pre>a2ensite redmine
161 1 André Domarques
service apache2 restart</pre>
162 1 André Domarques
163 1 André Domarques
164 1 André Domarques
{{collapse(Environment details)
165 1 André Domarques
166 1 André Domarques
Debian Wheezy (netinst - only with basic packages plus ssh server)
167 1 André Domarques
168 5 André Domarques
<pre>cat /etc/debian_version
169 1 André Domarques
170 5 André Domarques
7.1</pre>
171 1 André Domarques
172 5 André Domarques
<pre>uname -a
173 1 André Domarques
174 5 André Domarques
Linux redmine 3.2.0-4-amd64 #1 SMP Debian 3.2.46-1+deb7u1 x86_64 GNU/Linux)</pre>
175 1 André Domarques
176 5 André Domarques
<pre>cat /etc/hostname
177 1 André Domarques
178 5 André Domarques
redmine</pre>
179 1 André Domarques
180 5 André Domarques
<pre>dpkg -l
181 5 André Domarques
182 5 André Domarques
ii  apache2                            2.2.22-13
183 1 André Domarques
ii  git                                1:1.7.10.4-1+wheezy1
184 1 André Domarques
ii  gitolite                           2.3-1
185 1 André Domarques
ii  libapache2-mod-passenger           3.0.13debian-1
186 1 André Domarques
ii  libmagickcore-dev                  8:6.7.7.10-5+deb7u2
187 1 André Domarques
ii  libmagickwand-dev                  8:6.7.7.10-5+deb7u2
188 1 André Domarques
ii  mysql-server                       5.5.31+dfsg-0+wheezy1
189 1 André Domarques
ii  ruby1.9.1-dev                      1.9.3.194-8.1+deb7u1
190 1 André Domarques
</pre>
191 1 André Domarques
192 5 André Domarques
<pre>gem env
193 1 André Domarques
194 5 André Domarques
RubyGems Environment:
195 1 André Domarques
  - RUBYGEMS VERSION: 1.8.23
196 1 André Domarques
  - RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [x86_64-linux]
197 1 André Domarques
  - INSTALLATION DIRECTORY: /var/lib/gems/1.9.1
198 1 André Domarques
  - RUBY EXECUTABLE: /usr/bin/ruby1.9.1
199 1 André Domarques
  - EXECUTABLE DIRECTORY: /usr/local/bin
200 1 André Domarques
  - RUBYGEMS PLATFORMS:
201 1 André Domarques
    - ruby
202 1 André Domarques
    - x86_64-linux
203 1 André Domarques
  - GEM PATHS:
204 1 André Domarques
     - /var/lib/gems/1.9.1
205 1 André Domarques
     - /opt/redmine/.gem/ruby/1.9.1
206 1 André Domarques
  - GEM CONFIGURATION:
207 1 André Domarques
     - :update_sources => true
208 1 André Domarques
     - :verbose => true
209 1 André Domarques
     - :benchmark => false
210 1 André Domarques
     - :backtrace => false
211 1 André Domarques
     - :bulk_threshold => 1000
212 1 André Domarques
  - REMOTE SOURCES:
213 1 André Domarques
     - http://rubygems.org/</pre>
214 1 André Domarques
}}
215 1 André Domarques
216 6 André Domarques
Hope this helps =D.