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

André Domarques, 2013-11-14 18:44

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