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

Nicolas Rodriguez, 2015-04-09 13:20

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 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 14 André Domarques
h3. Last update
10 1 André Domarques
11 16 André Domarques
<pre>Date: 2015-01-08
12 16 André Domarques
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 14 André Domarques
23 1 André Domarques
<pre>adduser --system --shell /bin/bash --gecos 'Git Administrator' --group --disabled-password --home /opt/gitolite git
24 1 André Domarques
adduser --system --shell /bin/bash --gecos 'Redmine Administrator' --group --disabled-password --home /opt/redmine redmine</pre>
25 1 André Domarques
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 14 André Domarques
ssh-keygen -t rsa -N '' -f ~/.ssh/redmine_gitolite_admin_id_rsa
30 1 André Domarques
exit</pre>
31 1 André Domarques
32 14 André Domarques
h3. Configuring Gitolite
33 1 André Domarques
34 1 André Domarques
<pre>dpkg-reconfigure gitolite</pre>
35 1 André Domarques
36 1 André Domarques
Type data bellow:
37 1 André Domarques
38 1 André Domarques
* user: git
39 1 André Domarques
* 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 14 André Domarques
44 14 André Domarques
Click bellow to expand.
45 14 André Domarques
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 1 André Domarques
<pre>redmine@redmine:~$ ssh -v git@localhost
51 1 André Domarques
...
52 1 André Domarques
The authenticity of host 'localhost (::1)' can't be established.
53 1 André Domarques
ECDSA key fingerprint is d5:da:b9:10:c4:9b:51:75:65:f3:64:81:b5:6c:1a:1a.
54 1 André Domarques
Are you sure you want to continue connecting (yes/no)? yes
55 1 André Domarques
...
56 1 André Domarques
...
57 1 André Domarques
*debug1: Trying private key: /opt/redmine/.ssh/id_rsa*
58 1 André Domarques
*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 1 André Domarques
git@localhost's password:</pre>
62 1 André Domarques
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 14 André Domarques
ln -s /opt/redmine/.ssh/redmine_gitolite_admin_id_rsa /opt/redmine/.ssh/id_rsa
67 14 André Domarques
ln -s /opt/redmine/.ssh/redmine_gitolite_admin_id_rsa.pub /opt/redmine/.ssh/id_rsa.pub</pre>
68 1 André Domarques
69 1 André Domarques
Or even using ssh -i identity_file (check http://unixhelp.ed.ac.uk/CGI/man-cgi?ssh+1 for more details)
70 1 André Domarques
}}
71 1 André Domarques
72 14 André Domarques
h3. Visudo configuration
73 1 André Domarques
74 1 André Domarques
<pre>visudo</pre>
75 1 André Domarques
76 1 André Domarques
Add the following lines:
77 1 André Domarques
78 14 André Domarques
<pre># temp - *REMOVE* after installation
79 1 André Domarques
redmine    ALL=(ALL)      NOPASSWD:ALL
80 1 André Domarques
81 1 André Domarques
# redmine gitolite integration
82 1 André Domarques
redmine    ALL=(git)      NOPASSWD:ALL
83 1 André Domarques
git        ALL=(redmine)  NOPASSWD:ALL</pre>
84 1 André Domarques
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 1 André Domarques
The installation and configuration is like the official documentation. Simply reproducing to maintain the flow on this how-to.
90 1 André Domarques
91 14 André Domarques
h4. Download
92 14 André Domarques
93 1 André Domarques
<pre>sudo su - redmine
94 1 André Domarques
cd ~
95 16 André Domarques
wget http://www.redmine.org/releases/redmine-2.6.0.tar.gz
96 16 André Domarques
tar zxf redmine-2.6.0.tar.gz
97 16 André Domarques
mv redmine-2.6.0/* .
98 16 André Domarques
rm -Rf redmine-2.6.0
99 1 André Domarques
</pre>
100 1 André Domarques
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 1 André Domarques
<pre>cd /opt/redmine/config
110 1 André Domarques
cp database.yml.example database.yml
111 1 André Domarques
cp configuration.yml.example configuration.yml</pre>
112 1 André Domarques
113 1 André Domarques
Check more at: 
114 1 André Domarques
* http://www.redmine.org/projects/redmine/wiki/RedmineInstall#Step-3-Database-connection-configuration
115 1 André Domarques
* http://www.redmine.org/projects/redmine/wiki/RedmineInstall#Configuration
116 1 André Domarques
117 14 André Domarques
h4. Finishing the installation
118 14 André Domarques
119 1 André Domarques
Create plugin assets directory
120 1 André Domarques
121 1 André Domarques
<pre>cd ~
122 1 André Domarques
mkdir public/plugin_assets
123 1 André Domarques
</pre>
124 1 André Domarques
125 14 André Domarques
Now, complete the installation.
126 1 André Domarques
127 1 André Domarques
<pre>sudo gem install bundler
128 1 André Domarques
bundle install --without development test postgresql sqlite
129 1 André Domarques
rake generate_secret_token
130 1 André Domarques
RAILS_ENV=production rake db:migrate
131 1 André Domarques
RAILS_ENV=production rake redmine:load_default_data</pre>
132 1 André Domarques
133 14 André Domarques
h3. Redmine Gitolite integration
134 1 André Domarques
135 1 André Domarques
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 1 André Domarques
<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 14 André Domarques
<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 14 André Domarques
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 14 André Domarques
153 14 André Domarques
h4. Configure GL_GITCONFIG_KEYS
154 14 André Domarques
155 14 André Domarques
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 14 André Domarques
157 14 André Domarques
<pre>sudo su - git
158 14 André Domarques
sed -i 's/$GL_GITCONFIG_KEYS = ""/$GL_GITCONFIG_KEYS = ".*"/g' /opt/gitolite/.gitolite.rc
159 14 André Domarques
exit</pre>
160 14 André Domarques
161 14 André Domarques
h4. Configure Automatic Repository Initialization (optional)
162 14 André Domarques
163 14 André Domarques
To configure the new feature "Automatic Repository Initialization" (optional), is necessary to customize the gitolite.conf file.
164 14 André Domarques
165 1 André Domarques
<pre>cd ~
166 14 André Domarques
git clone git@localhost:gitolite-admin.git
167 14 André Domarques
cd gitolite-admin/
168 14 André Domarques
echo "repo    @all
169 14 André Domarques
        RW+    = admin" >> conf/gitolite.conf
170 14 André Domarques
git commit -m 'Automatic Repository Initialization' conf/gitolite.conf
171 14 André Domarques
git push
172 14 André Domarques
cd ~
173 14 André Domarques
rm -rf gitolite-admin</pre>
174 14 André Domarques
175 14 André Domarques
Remember that this repository will be managed by redmine and their plugin.
176 14 André Domarques
177 14 André Domarques
h4. Plugin installation
178 14 André Domarques
179 14 André Domarques
It's necessary to run bundle again to install some new gems required by the plugins.
180 14 André Domarques
181 14 André Domarques
<pre>cd ~
182 14 André Domarques
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 1 André Domarques
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 14 André Domarques
191 1 André Domarques
<pre>su root
192 1 André Domarques
cd /var/www
193 14 André Domarques
ln -s /opt/redmine/public redmine
194 14 André Domarques
echo "RailsBaseURI /redmine
195 14 André Domarques
PassengerUserSwitching on
196 14 André Domarques
PassengerUser redmine
197 14 André Domarques
PassengerGroup redmine" > /etc/apache2/sites-available/redmine
198 14 André Domarques
a2ensite redmine
199 14 André Domarques
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 14 André Domarques
# temp - *REMOVE* after installation
207 14 André Domarques
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 14 André Domarques
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 14 André Domarques
220 14 André Domarques
h5. Set the available repositories
221 14 André Domarques
222 14 André Domarques
Administration > Settings > Repositories
223 14 André Domarques
http://your_ip_or_fqdn/redmine/settings?tab=repositories
224 14 André Domarques
225 14 André Domarques
Uncheck what you don't have installed on your system. Just to avoid unnecessary log messages.
226 14 André Domarques
227 14 André Domarques
h4. Redmine Git Hosting Plugin
228 14 André Domarques
229 14 André Domarques
h5. First of all, check the configuration
230 14 André Domarques
231 14 André Domarques
Administration > Redmine Git Hosting Plugin > Config Test
232 14 André Domarques
http://your_ip_or_fqdn/redmine/settings/plugin/redmine_git_hosting?tab=gitolite_config_test
233 14 André Domarques
234 14 André Domarques
Ensure if all settings are correct (users, paths, versions etc.). 
235 14 André Domarques
236 14 André Domarques
h5. Set your IP or FQDN to SSH, HTTP and/or HTTPS
237 14 André Domarques
238 14 André Domarques
Administration > Redmine Git Hosting Plugin > Acess
239 14 André Domarques
http://your_ip_or_fqdn/redmine/settings/plugin/redmine_git_hosting?tab=gitolite_config_access
240 14 André Domarques
241 14 André Domarques
Those settings will be also used on git operations (clone, pull, push etc.).
242 14 André Domarques
243 14 André Domarques
h3. Troubleshooting
244 14 André Domarques
245 14 André Domarques
h4. Logs
246 14 André Domarques
247 14 André Domarques
If you have some trouble during the installation, you can check the following files:
248 14 André Domarques
249 14 André Domarques
* /opt/gitolite/.gitolite/logs/gitolite-`date +%Y\-%m`.log
250 14 André Domarques
* /opt/redmine/log/git_hosting.log
251 14 André Domarques
* /var/log/apache2/error.log
252 14 André Domarques
253 14 André Domarques
If you use multitail:
254 14 André Domarques
255 14 André Domarques
<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 14 André Domarques
259 14 André Domarques
h4. Plugin 
260 14 André Domarques
261 14 André Domarques
You also must check, regarding the plugin:
262 14 André Domarques
263 19 Nicolas Rodriguez
http://redmine-git-hosting.io/troubleshooting/
264 14 André Domarques
265 14 André Domarques
h4. Environment details
266 14 André Domarques
267 14 André Domarques
Click bellow to expand.
268 14 André Domarques
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 5 André Domarques
<pre>uname -a
278 5 André Domarques
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 1 André Domarques
<pre>cat /etc/hostname
282 1 André Domarques
283 1 André Domarques
redmine</pre>
284 1 André Domarques
285 1 André Domarques
<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 14 André Domarques
ii  libapache2-mod-passenger           3.0.13debian-1+deb7u2
291 16 André Domarques
ii  imagemagick                        8:6.7.7.10-5+deb7u3
292 16 André Domarques
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 1 André Domarques
296 1 André Domarques
<pre>gem env
297 1 André Domarques
298 1 André Domarques
RubyGems Environment:
299 1 André Domarques
  - RUBYGEMS VERSION: 1.8.23
300 1 André Domarques
  - RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [x86_64-linux]
301 1 André Domarques
  - INSTALLATION DIRECTORY: /var/lib/gems/1.9.1
302 1 André Domarques
  - RUBY EXECUTABLE: /usr/bin/ruby1.9.1
303 1 André Domarques
  - EXECUTABLE DIRECTORY: /usr/local/bin
304 1 André Domarques
  - RUBYGEMS PLATFORMS:
305 1 André Domarques
    - ruby
306 1 André Domarques
    - x86_64-linux
307 1 André Domarques
  - GEM PATHS:
308 1 André Domarques
     - /var/lib/gems/1.9.1
309 1 André Domarques
     - /opt/redmine/.gem/ruby/1.9.1
310 1 André Domarques
  - GEM CONFIGURATION:
311 6 André Domarques
     - :update_sources => true
312 1 André Domarques
     - :verbose => true
313 1 André Domarques
     - :benchmark => false
314 1 André Domarques
     - :backtrace => false
315 1 André Domarques
     - :bulk_threshold => 1000
316 1 André Domarques
  - REMOTE SOURCES:
317 1 André Domarques
     - http://rubygems.org/</pre>
318 1 André Domarques
}}
319 1 André Domarques
320 1 André Domarques
Hope this helps =D.