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

André Domarques, 2013-09-12 05:56

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