Project

General

Profile

HowTo Install Redmine 30x on Ubuntu 1404 with Apache2 Phusion Passenger MySQL Subversion and Git (Gitolite) » History » Version 6

Antoine Rodriguez, 2015-09-22 17:24
removed phpmyadmin from the first apt-get install as it is not needed and is potential security risk

1 5 Redmine Geist
h1. HowTo Install Redmine 3.0.x on Ubuntu 14.04 with Apache2, Phusion Passenger, MySQL, Subversion and Git (Gitolite)
2 3 Redmine Geist
3
{{toc}}
4
5
Based on "Debian HowTo":http://www.redmine.org/projects/redmine/wiki/HowTo_Install_Redmine_2_integrated_with_Gitolite_2_on_Debian_Wheezy_with_Apache_and_Phusion_Passenger from "André Domarques":http://www.redmine.org/users/85560
6
7
h2. Installing dependencies
8
9
<pre>
10
sudo apt-get update && sudo apt-get upgrade -y
11
12 6 Antoine Rodriguez
sudo apt-get install apache2 php5 libapache2-mod-php5 mysql-server php5-mysql libapache2-mod-perl2 libcurl4-openssl-dev libssl-dev apache2-prefork-dev libapr1-dev libaprutil1-dev libmysqlclient-dev libmagickcore-dev libmagickwand-dev curl git-core gitolite patch build-essential bison zlib1g-dev libssl-dev libxml2-dev libxml2-dev sqlite3 libsqlite3-dev autotools-dev libxslt1-dev libyaml-0-2 autoconf automake libreadline6-dev libyaml-dev libtool imagemagick apache2-utils ssh zip libicu-dev libssh2-1 libssh2-1-dev cmake libgpg-error-dev subversion libapache2-svn
13 3 Redmine Geist
</pre>
14
15
I don't know if every package needed, but it works.
16
17
h2. Configure Subversion
18
19
<pre>
20
sudo mkdir -p /var/lib/svn
21
sudo chown -R www-data:www-data /var/lib/svn
22
sudo a2enmod dav_svn
23
</pre>
24
25
Open config file
26
<pre>
27
sudo nano /etc/apache2/mods-enabled/dav_svn.conf
28
</pre>
29
30
Uncomment following lines
31
32
<pre>
33
<Location /svn>
34
	DAV svn
35
	SVNParentPath /var/lib/svn
36
    AuthType Basic
37
    AuthName "My repository"
38
    AuthUserFile /etc/apache2/dav_svn.passwd
39
	AuthzSVNAccessFile /etc/apache2/dav_svn.authz
40
	<LimitExcept GET PROFIND OPTIONS REPORT>
41
	Require valid-user
42
	</LimitExcept>
43
</Location>
44
</pre>
45
46
<pre>
47
sudo a2enmod authz_svn
48
</pre>
49
50
Add the redmine user for reading from repository
51
<pre>
52
sudo htpasswd -c /etc/apache2/dav_svn.passwd redmine
53
54
sudo service apache2 restart
55
</pre>
56
57
Create the repository
58
<pre>
59
sudo svnadmin create --fs-type fsfs /var/lib/svn/my_repository
60
sudo chown -R www-data:www-data /var/lib/svn
61
</pre>
62
63
Open file for configuration of repository access
64
<pre>
65
sudo nano /etc/apache2/dav_svn.authz
66
</pre>
67
68
Add access rights for redmine to the repository in the config file
69
<pre>
70
[my_repository:/]
71
redmine = r
72
</pre>
73
74
h2. Installing Ruby
75
76
<pre>
77
sudo apt-get install software-properties-common
78
sudo add-apt-repository ppa:brightbox/ruby-ng
79
sudo apt-get update
80
sudo apt-get -y install ruby2.1 ruby-switch ruby2.1-dev ri2.1 libruby2.1 libssl-dev zlib1g-dev
81
sudo ruby-switch --set ruby2.1
82
sudo ruby-switch --set ruby2.1
83
</pre>
84
85
h2. Users and SSH keys
86
87
h3. Users
88
89
Create an user for Redmine (redmine) and another for Gitolite (git):
90
91
<pre>
92
sudo adduser --system --shell /bin/bash --gecos 'Git Administrator' --group --disabled-password --home /opt/gitolite git
93
sudo adduser --system --shell /bin/bash --gecos 'Redmine Administrator' --group --disabled-password --home /opt/redmine redmine
94
</pre>
95
96
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.
97
<pre>
98
sudo su - redmine
99
ssh-keygen -t rsa -N '' -f ~/.ssh/redmine_gitolite_admin_id_rsa
100
exit
101
</pre>
102
103
h3. Configuring Gitolite
104
105 4 Redmine Geist
<pre>sudo dpkg-reconfigure gitolite</pre>
106 3 Redmine Geist
107
Type data bellow:
108
* user: git
109
* repos path: /opt/gitolite
110
* admin ssh-key: /opt/redmine/.ssh/redmine_gitolite_admin_id_rsa.pub
111
112
h3. Visudo configuration
113
114 4 Redmine Geist
<pre>sudo visudo</pre>
115 3 Redmine Geist
116
Add the following lines:
117
118
<pre>
119
# temp - *REMOVE* after installation
120
redmine    ALL=(ALL)      NOPASSWD:ALL
121
122
# redmine gitolite integration
123
redmine    ALL=(git)      NOPASSWD:ALL
124
git        ALL=(redmine)  NOPASSWD:ALL
125
</pre>
126
127
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.
128
129
h2. Installing of Redmine
130
131
h3. Prerequist
132
133
<pre>
134
sudo su - redmine
135
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
136
curl -sSL https://get.rvm.io | bash -s stable
137
exit
138
</pre>
139
140
Its necessary to logout and login again
141
142
<pre>
143
sudo su - redmine
144
rvm install 2.1.4
145
exit
146
</pre>
147
148
h3. Redmine
149
150
Exampe for version 3.0.4, change the version number for other releases
151
152
<pre>
153
sudo su - redmine
154
wget http://www.redmine.org/releases/redmine-3.0.4.tar.gz
155
tar zxf redmine-3.0.4.tar.gz
156
rm redmine-3.0.4.tar.gz
157
ln -s /opt/redmine/redmine-3.0.4 redmine
158
exit
159
</pre>
160
161
h3. MySQL
162
163
<pre>
164
sudo mysql -u root -p
165
</pre>
166
167
Execute following lines to MySQL
168
169
<pre>
170
CREATE DATABASE redmine character SET utf8;
171
CREATE user 'redmine'@'localhost' IDENTIFIED BY 'my_password';
172
GRANT ALL privileges ON redmine.* TO 'redmine'@'localhost';
173
exit
174
</pre>
175
176
Configure Redmine database connection
177
178
<pre>
179
sudo su - redmine
180
sudo cp redmine/config/database.yml.example redmine/config/database.yml
181
</pre>
182
183
Open database config file
184
185
<pre>
186
sudo nano redmine/config/database.yml
187
</pre>
188
189
Change the username and the password in the config file
190
191
<pre>
192
database.yml:
193
production:
194
 adapter: mysql2
195
 database: redmine
196
 host: localhost
197
 username: redmine
198
 password: my_password
199
 encoding: utf8
200
</pre>
201
202
h3. Configuration
203
204
<pre>
205
gem install bundler
206
cd redmine/
207
bundle install --without development test postgresql sqlite
208
rake generate_secret_token
209
RAILS_ENV=production rake db:migrate 
210
RAILS_ENV=production rake redmine:load_default_data
211
exit
212
</pre>
213
214
h2. Redmine Git Hosting
215
216
h3. Download
217
218
Exampe for version 1.1.1, change the version number for other releases
219
220
<pre>
221
sudo su - redmine
222
cd /opt/redmine/redmine/plugins
223
git clone https://github.com/jbox-web/redmine_bootstrap_kit.git
224
git clone https://github.com/jbox-web/redmine_git_hosting.git
225
cd redmine_git_hosting
226
git checkout 1.1.1
227
</pre>
228
229
h3. Configure
230
231
<pre>
232
ln -s /opt/redmine/.ssh/redmine_gitolite_admin_id_rsa /opt/redmine/redmine/plugins/redmine_git_hosting/ssh_keys/redmine_gitolite_admin_id_rsa
233
ln -s /opt/redmine/.ssh/redmine_gitolite_admin_id_rsa.pub /opt/redmine/redmine/plugins/redmine_git_hosting/ssh_keys/redmine_gitolite_admin_id_rsa.pub
234
ln -s /opt/redmine/.ssh/redmine_gitolite_admin_id_rsa /opt/redmine/.ssh/id_rsa
235
ln -s /opt/redmine/.ssh/redmine_gitolite_admin_id_rsa.pub /opt/redmine/.ssh/id_rsa.pub
236
</pre>
237
238
h3. Configure GL_GITCONFIG_KEYS
239
240
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.
241
242
<pre>
243
sudo su - git
244
sed -i 's/$GL_GITCONFIG_KEYS = ""/$GL_GITCONFIG_KEYS = ".*"/g' /opt/gitolite/.gitolite.rc
245
exit
246
</pre>
247
248
h3. Configure Automatic Repository Initialization
249
250
To configure the new feature "Automatic Repository Initialization" (optional), is necessary to customize the gitolite.conf file.
251
252
<pre>
253
cd ~
254
git clone git@localhost:gitolite-admin.git
255
cd gitolite-admin
256
</pre>
257
258
Open gitolite config file
259
260
<pre>
261
nano conf/gitolite.conf
262
</pre>
263
264
Add following config
265
266
<pre>
267
repo    @all
268
	RW+    = admin
269
</pre>
270
271
<pre>
272
git config --global user.email "you@example.com"
273
git config --global user.name "Your Name"
274
git commit -m 'Automatic Repository Initialization' conf/gitolite.conf
275
git push
276
cd ~
277
rm -rf gitolite-admin
278
</pre>
279
280
Remember that this repository will be managed by redmine and their plugin.
281
282
h3. Installation
283
284
<pre>
285
cd redmine
286
bundle install --without development test postgresql sqlite
287
RAILS_ENV=production rake redmine:plugins:migrate
288
RAILS_ENV=production rake redmine_git_hosting:update_repositories
289
RAILS_ENV=production rake redmine_git_hosting:fetch_changesets
290
RAILS_ENV=production rake redmine_git_hosting:restore_default_settings
291
RAILS_ENV=production rake redmine_git_hosting:install_hook_files
292
RAILS_ENV=production rake redmine_git_hosting:install_hook_parameters
293
RAILS_ENV=production rake redmine_git_hosting:install_gitolite_hooks
294
exit
295
</pre>
296
297
h2. Remove redmine root access
298
299 4 Redmine Geist
<pre>sudo visudo</pre>
300 3 Redmine Geist
301
_REMOVE_ following entry
302
303
<pre>
304
# temp - *REMOVE* after installation
305
redmine    ALL=(ALL)      NOPASSWD:ALL
306
</pre>
307
308
h2. Installing Phusion Passenger
309
310
h3. Add repository
311
312
Add repository for Phusion Passenger
313
314
<pre>
315
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7
316
sudo apt-get install apt-transport-https ca-certificates
317
</pre>
318
319
Open repository config file
320
321
<pre>
322
sudo nano /etc/apt/sources.list.d/passenger.list
323
</pre>
324
325
Add following repository source
326
327
<pre>
328
deb https://oss-binaries.phusionpassenger.com/apt/passenger trusty main
329
</pre>
330
331
<pre>
332
sudo chown root: /etc/apt/sources.list.d/passenger.list
333
sudo chmod 600 /etc/apt/sources.list.d/passenger.list
334
</pre>
335
336
h3. Installing
337
338
<pre>
339
sudo apt-get update
340
sudo apt-get install libapache2-mod-passenger
341
</pre>
342
343
h3. Configuration
344
345
Open passenger config file
346
347
<pre>
348
sudo nano /etc/apache2/mods-available/passenger.conf
349
</pre>
350
351
Add following line to passenger config file
352
353
<pre>
354
PassengerUserSwitching on
355
PassengerUser redmine
356
PassengerGroup redmine
357
</pre>
358
359
Open apache2 config file
360
361
<pre>
362
sudo nano /etc/apache2/sites-available/000-default.conf
363
</pre>
364
365
Add following part to apache2 config file
366
<pre>
367
<Directory /var/www/html/redmine>
368
    RailsBaseURI /redmine
369
    PassengerResolveSymlinksInDocumentRoot on
370
</Directory>
371
</pre>
372
373
<pre>
374
sudo a2enmod passenger
375
sudo ln -s /opt/redmine/redmine/public/ /var/www/html/redmine
376
sudo service apache2 restart
377
</pre>
378
379
h2. Start Redmine
380
381
Remine should now available at your host
382
383
<pre>
384
http://your_ip_or_fqdn/redmine
385
</pre>
386
387
Login data:
388
Username: admin
389
Password: admin
390
391
h2. Redmine configuration
392
393
Configure the Redmine default URL (*important*):
394
395
Administration > Settings > General
396
http://your_ip_or_fqdn/redmine/settings?tab=general
397
398
This is set, by default, to localhost:3000, change it to your IP or FQDN. your_ip_or_fqdn/redmine/
399
400
h3. Set the available repositories
401
402
Administration > Settings > Repositories
403
http://your_ip_or_fqdn/redmine/settings?tab=repositories
404
405
Uncheck what you don't have installed on your system. Just to avoid unnecessary log message.
406
407
Enable xitolite for using the Redmine Git Hosting plugin
408
409
h2. Redmine Git Hosting Plugin
410
411
h3. First of all, check the configuration
412
413
Administration > Redmine Git Hosting Plugin > Config Test
414
http://your_ip_or_fqdn/redmine/settings/plugin/redmine_git_hosting?tab=gitolite_config_test
415
416
Ensure if all settings are correct (users, paths, versions etc.). 
417
418
h3. Set your IP or FQDN to SSH, HTTP and/or HTTPS
419
420
Administration > Redmine Git Hosting Plugin > Access
421
http://your_ip_or_fqdn/redmine/settings/plugin/redmine_git_hosting?tab=gitolite_config_access
422
423
Administration > Redmine Git Hosting Plugin > Hooks
424
http://your_ip_or_fqdn/redmine/settings/plugin/redmine_git_hosting?tab=gitolite_config_hooks
425
426
Hooks: http://your_ip_or_fqdn/redmine
427
428
Those settings will be also used on git operations (clone, pull, push etc.).
429
430
h2. e-Mail configuration
431
432
Example for smtp and encryption
433
434
Open redmine config file
435
436
<pre>
437
sudo nano /usr/share/redmine/config/configuration.yml
438
</pre>
439
440
Add following to redmine config file
441
442
<pre>
443
# Outgoing email settings
444
445
production:
446
  email_delivery:
447
    delivery_method: :smtp
448
    smtp_settings:
449
      enable_starttls_auto: true
450
      address: smtp.host.com
451
      port: 587
452
      domain: host.com
453
      authentication: :login
454
      user_name: myname
455
      password: mypassword
456
</pre>
457
458
You can check the e-Mail config in web interface with testmail function
459
460
h2. Autoupdate Subversion repository view
461
462
In the project archive settings over web interface its needed to enable the web service for project archives and generate a api key
463
464
The following cronjob updates redmine to current subversion changesets every 15 minutes
465
466
<pre>
467
sudo crontab -e
468
</pre>
469
470
Add the cronjob
471
472
<pre>
473
*/15 *    * * * curl "http://yourhost/redmine/sys/fetch_changesets?key=APIKEY" > /dev/null
474
</pre>
475 1 Redmine Geist
476
If your hosting does not offer cron job configuration then you can use external services like these:
477
https://www.easycron.com.
478 4 Redmine Geist
479
h2. SSL, HTTPS and Smart-HTTPS (Git)
480
481
h3. Own certificate
482
483
Create Private Key
484
485
<pre>
486
sudo mkdir /etc/apache2/ssl
487
cd /etc/apache2/ssl
488
sudo openssl genrsa -des3 -out server.key 1024
489
</pre>
490
491
Create CSR (Certificate Signing Request)
492
493
<pre>
494
cd /etc/apache2/ssl
495
sudo openssl req -new -key server.key -out server.csr
496
</pre>
497
498
Remove of the passphrase vom private key
499
500
<pre>
501
cd /etc/apache2/ssl
502
sudo cp server.key server.key.org
503
sudo openssl rsa -in server.key.org -out server.key
504
</pre>
505
506
Generate selfsigned certificate
507
508
<pre>
509
cd /etc/apache2/ssl
510
sudo openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
511
</pre>
512
513
h3. Configuration of apache2
514
515
Enable SSL module
516
517
<pre>sudo a2enmod ssl</pre>
518
519
Modification of apache2 configuration
520
521
<pre>sudo nano /etc/apache2/sites-available/default-ssl.conf</pre>
522
523
Following config is needed:
524
525
<pre>
526
<IfModule mod_ssl.c>
527
        ...
528
        <VirtualHost _default_:443>
529
                ServerAdmin webmaster@localhost
530
                DocumentRoot /var/www/html
531
                ErrorLog ${APACHE_LOG_DIR}/error.log
532
                CustomLog ${APACHE_LOG_DIR}/access.log combined
533
                SSLEngine on
534
                SSLCertificateFile      /etc/apache2/ssl/server.crt
535
                SSLCertificateKeyFile /etc/apache2/ssl/server.key
536
                <Directory /var/www/html/redmine>
537
                        RailsBaseURI /redmine
538
                        PassengerResolveSymlinksInDocumentRoot on
539
                </Directory>
540
        </VirtualHost>
541
        ...
542
    </IfModule>
543
</pre>
544
545
Activate the new configuration
546
547
<pre>sudo a2ensite default-ssl</pre>
548
549
h3. Smart-HTTPS client (Git)
550
551
For the client is needed to disable certificate verification. With Git bash:
552
553
<pre>git config --global http.sslverify false</pre>
554
555
*Caution:* This can be a security risk at access to foreign repositorys!
556 3 Redmine Geist
557
h1. Troubleshooting
558
559
h2. Logs
560
561
If you have some trouble during the installation, you can check the following files:
562
563
* /opt/gitolite/.gitolite/logs/gitolite-`date +%Y\-%m`.log
564
* /opt/redmine/log/git_hosting.log
565
* /var/log/apache2/error.log
566
567
If you use multitail:
568
569
multitail /opt/gitolite/.gitolite/logs/gitolite-`date +%Y\-%m`.log /opt/redmine/log/git_hosting.log /var/log/apache2/error.log