Project

General

Profile

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

Alex Nnm, 2016-01-05 14:22

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