Project

General

Profile

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

Nicolas Rodriguez, 2015-04-09 13:19

1 14 André Domarques
h2. HowTo Install Redmine 2 integrated with Gitolite 2 on Debian Wheezy with Apache and Phusion Passenger
2 1 André Domarques
3 14 André Domarques
h3. About
4 1 André Domarques
5
A quick step-by-step for install Redmine and Gitolite plugin on Debian Wheezy mainly using default packages.
6
7 5 André Domarques
If I missed something, "let me know":http://www.redmine.org/users/85560
8 1 André Domarques
9 14 André Domarques
h3. Last update
10 1 André Domarques
11 16 André Domarques
<pre>Date: 2015-01-08
12
Sumary: Updated to Redmine *2.6.0* and redmine_git_hosting *0.7.9*.
13 14 André Domarques
See doc history for more info and/or instructions for redmine_git_hosting 0.6.x (deprecated).</pre>
14 1 André Domarques
15 14 André Domarques
h3. Required packages
16 1 André Domarques
17 16 André Domarques
<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>
18 1 André Domarques
19 14 André Domarques
h3. Users and ssh-key
20 1 André Domarques
21 14 André Domarques
Create an user for Redmine (*redmine*) and another for Gitolite (*git*):
22
23 1 André Domarques
<pre>adduser --system --shell /bin/bash --gecos 'Git Administrator' --group --disabled-password --home /opt/gitolite git
24
adduser --system --shell /bin/bash --gecos 'Redmine Administrator' --group --disabled-password --home /opt/redmine redmine</pre>
25
26 14 André Domarques
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*.
27 8 André Domarques
28 14 André Domarques
<pre>su redmine
29
ssh-keygen -t rsa -N '' -f ~/.ssh/redmine_gitolite_admin_id_rsa
30 1 André Domarques
exit</pre>
31
32 14 André Domarques
h3. Configuring Gitolite
33 1 André Domarques
34
<pre>dpkg-reconfigure gitolite</pre>
35
36
Type data bellow:
37
38
* user: git
39
* repos path: /opt/gitolite
40 14 André Domarques
* admin ssh-key: /opt/redmine/.ssh/redmine_gitolite_admin_id_rsa.pub
41 5 André Domarques
42 14 André Domarques
h4. Note about SSH
43
44
Click bellow to expand.
45
46 1 André Domarques
{{collapse(Note about SSH)
47 4 André Domarques
48 14 André Domarques
If you try to connect gitolite (user: *git*) using *redmine* user via ssh, will be prompted password... See what happens:
49 1 André Domarques
50
<pre>redmine@redmine:~$ ssh -v git@localhost
51
...
52
The authenticity of host 'localhost (::1)' can't be established.
53
ECDSA key fingerprint is d5:da:b9:10:c4:9b:51:75:65:f3:64:81:b5:6c:1a:1a.
54
Are you sure you want to continue connecting (yes/no)? yes
55
...
56
...
57
*debug1: Trying private key: /opt/redmine/.ssh/id_rsa*
58
*debug1: Trying private key: /opt/redmine/.ssh/id_dsa*
59 4 André Domarques
*debug1: Trying private key: /opt/redmine/.ssh/id_ecdsa*
60 1 André Domarques
debug1: Next authentication method: password
61
git@localhost's password:</pre>
62
63 8 André Domarques
You can solve this by simply creating a symbolic link:
64 1 André Domarques
65 14 André Domarques
<pre>su redmine
66
ln -s /opt/redmine/.ssh/redmine_gitolite_admin_id_rsa /opt/redmine/.ssh/id_rsa
67
ln -s /opt/redmine/.ssh/redmine_gitolite_admin_id_rsa.pub /opt/redmine/.ssh/id_rsa.pub</pre>
68 1 André Domarques
69
Or even using ssh -i identity_file (check http://unixhelp.ed.ac.uk/CGI/man-cgi?ssh+1 for more details)
70
}}
71
72 14 André Domarques
h3. Visudo configuration
73 1 André Domarques
74
<pre>visudo</pre>
75
76
Add the following lines:
77
78 14 André Domarques
<pre># temp - *REMOVE* after installation
79 1 André Domarques
redmine    ALL=(ALL)      NOPASSWD:ALL
80
81
# redmine gitolite integration
82
redmine    ALL=(git)      NOPASSWD:ALL
83
git        ALL=(redmine)  NOPASSWD:ALL</pre>
84
85 14 André Domarques
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.
86 1 André Domarques
87 14 André Domarques
h3. Redmine installation
88 1 André Domarques
89
The installation and configuration is like the official documentation. Simply reproducing to maintain the flow on this how-to.
90
91 14 André Domarques
h4. Download
92
93 1 André Domarques
<pre>sudo su - redmine
94
cd ~
95 16 André Domarques
wget http://www.redmine.org/releases/redmine-2.6.0.tar.gz
96
tar zxf redmine-2.6.0.tar.gz
97
mv redmine-2.6.0/* .
98
rm -Rf redmine-2.6.0
99 1 André Domarques
</pre>
100
101 14 André Domarques
h4. Create database and user
102 1 André Domarques
103 14 André Domarques
<pre>mysql -u root -p -v -e "CREATE DATABASE redmine CHARACTER SET utf8;
104 1 André Domarques
CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'redmine';
105 14 André Domarques
GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';"</pre>
106 1 André Domarques
107 14 André Domarques
h4. Configure database and email
108 1 André Domarques
109
<pre>cd /opt/redmine/config
110
cp database.yml.example database.yml
111
cp configuration.yml.example configuration.yml</pre>
112
113
Check more at: 
114
* http://www.redmine.org/projects/redmine/wiki/RedmineInstall#Step-3-Database-connection-configuration
115
* http://www.redmine.org/projects/redmine/wiki/RedmineInstall#Configuration
116
117 14 André Domarques
h4. Finishing the installation
118
119 1 André Domarques
Create plugin assets directory
120
121
<pre>cd ~
122
mkdir public/plugin_assets
123
</pre>
124
125 14 André Domarques
Now, complete the installation.
126 1 André Domarques
127
<pre>sudo gem install bundler
128
bundle install --without development test postgresql sqlite
129
rake generate_secret_token
130
RAILS_ENV=production rake db:migrate
131
RAILS_ENV=production rake redmine:load_default_data</pre>
132
133 14 André Domarques
h3. Redmine Gitolite integration
134 1 André Domarques
135
The plugin used on this how-to is the fork of JBox Web, you can get more information at:
136 18 Nicolas Rodriguez
* http://redmine-git-hosting.io
137 1 André Domarques
138 14 André Domarques
h4. Download
139 1 André Domarques
140
<pre>cd ~/plugins
141 14 André Domarques
git clone https://github.com/jbox-web/redmine_bootstrap_kit.git
142 1 André Domarques
git clone https://github.com/jbox-web/redmine_git_hosting.git
143 14 André Domarques
cd redmine_git_hosting
144 16 André Domarques
git checkout v0.7.9</pre>
145 1 André Domarques
146 14 André Domarques
h4. Create symlinks
147 1 André Domarques
148 16 André Domarques
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:
149 14 André Domarques
150
<pre>ln -s /opt/redmine/.ssh/redmine_gitolite_admin_id_rsa /opt/redmine/plugins/redmine_git_hosting/ssh_keys/redmine_gitolite_admin_id_rsa
151
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>
152
153
h4. Configure GL_GITCONFIG_KEYS
154
155
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.
156
157
<pre>sudo su - git
158
sed -i 's/$GL_GITCONFIG_KEYS = ""/$GL_GITCONFIG_KEYS = ".*"/g' /opt/gitolite/.gitolite.rc
159
exit</pre>
160
161
h4. Configure Automatic Repository Initialization (optional)
162
163
To configure the new feature "Automatic Repository Initialization" (optional), is necessary to customize the gitolite.conf file.
164
165 1 André Domarques
<pre>cd ~
166 14 André Domarques
git clone git@localhost:gitolite-admin.git
167
cd gitolite-admin/
168
echo "repo    @all
169
        RW+    = admin" >> conf/gitolite.conf
170
git commit -m 'Automatic Repository Initialization' conf/gitolite.conf
171
git push
172
cd ~
173
rm -rf gitolite-admin</pre>
174
175
Remember that this repository will be managed by redmine and their plugin.
176
177
h4. Plugin installation
178
179
It's necessary to run bundle again to install some new gems required by the plugins.
180
181
<pre>cd ~
182
bundle install --without development
183 1 André Domarques
RAILS_ENV=production rake redmine:plugins:migrate
184 14 André Domarques
</pre>
185 1 André Domarques
186
187 14 André Domarques
h3. Apache mod_passenger configuration
188 1 André Domarques
189 14 André Domarques
Create a symbolic link, configure and enable the site and restart apache.
190
191 1 André Domarques
<pre>su root
192
cd /var/www
193 14 André Domarques
ln -s /opt/redmine/public redmine
194
echo "RailsBaseURI /redmine
195
PassengerUserSwitching on
196
PassengerUser redmine
197
PassengerGroup redmine" > /etc/apache2/sites-available/redmine
198
a2ensite redmine
199
service apache2 reload</pre>
200 1 André Domarques
201 14 André Domarques
h3. Post-install configuration tasks
202 1 André Domarques
203 14 André Domarques
Remember to remove the sudo temp configuration:
204 1 André Domarques
205 14 André Domarques
<pre>visudo
206
# temp - *REMOVE* after installation
207
redmine    ALL=(ALL)      NOPASSWD:ALL</pre>
208 1 André Domarques
209 14 André Domarques
You'll need to do some configuration on Redmine and git_hosting plugin.
210 1 André Domarques
211 14 André Domarques
h4. Redmine
212 1 André Domarques
213 14 André Domarques
Configure the Redmine default URL (*important*):
214 1 André Domarques
215 14 André Domarques
Administration > Settings > General
216
http://your_ip_or_fqdn/redmine/settings?tab=general
217 1 André Domarques
218 14 André Domarques
This is set, by default, to localhost:3000, change it to your IP or FQDN.
219
220
h5. Set the available repositories
221
222
Administration > Settings > Repositories
223
http://your_ip_or_fqdn/redmine/settings?tab=repositories
224
225
Uncheck what you don't have installed on your system. Just to avoid unnecessary log messages.
226
227
h4. Redmine Git Hosting Plugin
228
229
h5. First of all, check the configuration
230
231
Administration > Redmine Git Hosting Plugin > Config Test
232
http://your_ip_or_fqdn/redmine/settings/plugin/redmine_git_hosting?tab=gitolite_config_test
233
234
Ensure if all settings are correct (users, paths, versions etc.). 
235
236
h5. Set your IP or FQDN to SSH, HTTP and/or HTTPS
237
238
Administration > Redmine Git Hosting Plugin > Acess
239
http://your_ip_or_fqdn/redmine/settings/plugin/redmine_git_hosting?tab=gitolite_config_access
240
241
Those settings will be also used on git operations (clone, pull, push etc.).
242
243
h3. Troubleshooting
244
245
h4. Logs
246
247
If you have some trouble during the installation, you can check the following files:
248
249
* /opt/gitolite/.gitolite/logs/gitolite-`date +%Y\-%m`.log
250
* /opt/redmine/log/git_hosting.log
251
* /var/log/apache2/error.log
252
253
If you use multitail:
254
255
<pre>
256 15 André Domarques
multitail /opt/gitolite/.gitolite/logs/gitolite-`date +%Y\-%m`.log /opt/redmine/log/git_hosting.log /var/log/apache2/error.log
257 14 André Domarques
</pre>
258
259
h4. Plugin 
260
261
You also must check, regarding the plugin:
262
263
https://github.com/jbox-web/redmine_git_hosting/wiki/Troubleshooting
264
265
h4. Environment details
266
267
Click bellow to expand.
268
269 1 André Domarques
{{collapse(Environment details)
270 5 André Domarques
271 14 André Domarques
Debian Wheezy (netinst iso - installed only with basic packages and ssh server profiles)
272 5 André Domarques
273 1 André Domarques
<pre>cat /etc/debian_version
274 5 André Domarques
275 14 André Domarques
7.5</pre>
276 5 André Domarques
277
<pre>uname -a
278
279 14 André Domarques
Linux redmine 3.2.0-4-amd64 #1 SMP Debian 3.2.57-3+deb7u2 x86_64 GNU/Linux</pre>
280 1 André Domarques
281
<pre>cat /etc/hostname
282
283
redmine</pre>
284
285
<pre>dpkg -l
286 14 André Domarques
287 16 André Domarques
ii  apache2                            2.2.22-13+deb7u3
288 1 André Domarques
ii  git                                1:1.7.10.4-1+wheezy1
289 14 André Domarques
ii  gitolite                           2.3-1
290
ii  libapache2-mod-passenger           3.0.13debian-1+deb7u2
291 16 André Domarques
ii  imagemagick                        8:6.7.7.10-5+deb7u3
292
ii  mysql-server                       5.5.40-0+wheezy1
293 14 André Domarques
ii  ruby-dev                           1:1.9.3
294 1 André Domarques
</pre>
295
296
<pre>gem env
297
298
RubyGems Environment:
299
  - RUBYGEMS VERSION: 1.8.23
300
  - RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [x86_64-linux]
301
  - INSTALLATION DIRECTORY: /var/lib/gems/1.9.1
302
  - RUBY EXECUTABLE: /usr/bin/ruby1.9.1
303
  - EXECUTABLE DIRECTORY: /usr/local/bin
304
  - RUBYGEMS PLATFORMS:
305
    - ruby
306
    - x86_64-linux
307
  - GEM PATHS:
308
     - /var/lib/gems/1.9.1
309
     - /opt/redmine/.gem/ruby/1.9.1
310
  - GEM CONFIGURATION:
311 6 André Domarques
     - :update_sources => true
312 1 André Domarques
     - :verbose => true
313
     - :benchmark => false
314
     - :backtrace => false
315
     - :bulk_threshold => 1000
316
  - REMOTE SOURCES:
317
     - http://rubygems.org/</pre>
318
}}
319
320
Hope this helps =D.