Project

General

Profile

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

Askar K, 2015-11-11 01:27
sudo ruby-switch --set ruby2.1 was introduced twice

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
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
135
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
h3. Configure Automatic Repository Initialization
248
249
To configure the new feature "Automatic Repository Initialization" (optional), is necessary to customize the gitolite.conf file.
250
251
<pre>
252
cd ~
253
git clone git@localhost:gitolite-admin.git
254
cd gitolite-admin
255
</pre>
256
257
Open gitolite config file
258
259
<pre>
260
nano conf/gitolite.conf
261
</pre>
262
263
Add following config
264
265
<pre>
266
repo    @all
267
	RW+    = admin
268
</pre>
269
270
<pre>
271
git config --global user.email "you@example.com"
272
git config --global user.name "Your Name"
273
git commit -m 'Automatic Repository Initialization' conf/gitolite.conf
274
git push
275
cd ~
276
rm -rf gitolite-admin
277
</pre>
278
279
Remember that this repository will be managed by redmine and their plugin.
280
281
h3. Installation
282
283
<pre>
284
cd redmine
285
bundle install --without development test postgresql sqlite
286
RAILS_ENV=production rake redmine:plugins:migrate
287
RAILS_ENV=production rake redmine_git_hosting:update_repositories
288
RAILS_ENV=production rake redmine_git_hosting:fetch_changesets
289
RAILS_ENV=production rake redmine_git_hosting:restore_default_settings
290
RAILS_ENV=production rake redmine_git_hosting:install_hook_files
291
RAILS_ENV=production rake redmine_git_hosting:install_hook_parameters
292
RAILS_ENV=production rake redmine_git_hosting:install_gitolite_hooks
293
exit
294
</pre>
295
296
h2. Remove redmine root access
297
298 4 Redmine Geist
<pre>sudo visudo</pre>
299 3 Redmine Geist
300
_REMOVE_ following entry
301
302
<pre>
303
# temp - *REMOVE* after installation
304
redmine    ALL=(ALL)      NOPASSWD:ALL
305
</pre>
306
307
h2. Installing Phusion Passenger
308
309
h3. Add repository
310
311
Add repository for Phusion Passenger
312
313
<pre>
314
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7
315
sudo apt-get install apt-transport-https ca-certificates
316
</pre>
317
318
Open repository config file
319
320
<pre>
321
sudo nano /etc/apt/sources.list.d/passenger.list
322
</pre>
323
324
Add following repository source
325
326
<pre>
327
deb https://oss-binaries.phusionpassenger.com/apt/passenger trusty main
328
</pre>
329
330
<pre>
331
sudo chown root: /etc/apt/sources.list.d/passenger.list
332
sudo chmod 600 /etc/apt/sources.list.d/passenger.list
333
</pre>
334
335
h3. Installing
336
337
<pre>
338
sudo apt-get update
339
sudo apt-get install libapache2-mod-passenger
340
</pre>
341
342
h3. Configuration
343
344
Open passenger config file
345
346
<pre>
347
sudo nano /etc/apache2/mods-available/passenger.conf
348
</pre>
349
350
Add following line to passenger config file
351
352
<pre>
353
PassengerUserSwitching on
354
PassengerUser redmine
355
PassengerGroup redmine
356
</pre>
357
358
Open apache2 config file
359
360
<pre>
361
sudo nano /etc/apache2/sites-available/000-default.conf
362
</pre>
363
364
Add following part to apache2 config file
365
<pre>
366
<Directory /var/www/html/redmine>
367
    RailsBaseURI /redmine
368
    PassengerResolveSymlinksInDocumentRoot on
369
</Directory>
370
</pre>
371
372
<pre>
373
sudo a2enmod passenger
374
sudo ln -s /opt/redmine/redmine/public/ /var/www/html/redmine
375
sudo service apache2 restart
376
</pre>
377
378 7 Jürgen Depicker
Generate new secret:
379
<pre>
380
sudo su - redmine
381
cd redmine
382
rake generate_secret_token
383
rake db:migrate RAILS_ENV=production
384
rake redmine:plugins:migrate RAILS_ENV=production
385
rake tmp:cache:clear
386
rake tmp:sessions:clear
387
exit
388
</pre>
389
390
391 3 Redmine Geist
h2. Start Redmine
392
393
Remine should now available at your host
394
395
<pre>
396
http://your_ip_or_fqdn/redmine
397
</pre>
398
399
Login data:
400
Username: admin
401
Password: admin
402
403
h2. Redmine configuration
404
405
Configure the Redmine default URL (*important*):
406
407
Administration > Settings > General
408
http://your_ip_or_fqdn/redmine/settings?tab=general
409
410
This is set, by default, to localhost:3000, change it to your IP or FQDN. your_ip_or_fqdn/redmine/
411
412
h3. Set the available repositories
413
414
Administration > Settings > Repositories
415
http://your_ip_or_fqdn/redmine/settings?tab=repositories
416
417
Uncheck what you don't have installed on your system. Just to avoid unnecessary log message.
418
419
Enable xitolite for using the Redmine Git Hosting plugin
420
421
h2. Redmine Git Hosting Plugin
422
423
h3. First of all, check the configuration
424
425
Administration > Redmine Git Hosting Plugin > Config Test
426
http://your_ip_or_fqdn/redmine/settings/plugin/redmine_git_hosting?tab=gitolite_config_test
427
428
Ensure if all settings are correct (users, paths, versions etc.). 
429
430
h3. Set your IP or FQDN to SSH, HTTP and/or HTTPS
431
432
Administration > Redmine Git Hosting Plugin > Access
433
http://your_ip_or_fqdn/redmine/settings/plugin/redmine_git_hosting?tab=gitolite_config_access
434
435
Administration > Redmine Git Hosting Plugin > Hooks
436
http://your_ip_or_fqdn/redmine/settings/plugin/redmine_git_hosting?tab=gitolite_config_hooks
437
438
Hooks: http://your_ip_or_fqdn/redmine
439
440
Those settings will be also used on git operations (clone, pull, push etc.).
441
442
h2. e-Mail configuration
443
444
Example for smtp and encryption
445
446
Open redmine config file
447
448
<pre>
449
sudo nano /usr/share/redmine/config/configuration.yml
450
</pre>
451
452
Add following to redmine config file
453
454
<pre>
455
# Outgoing email settings
456
457
production:
458
  email_delivery:
459
    delivery_method: :smtp
460
    smtp_settings:
461
      enable_starttls_auto: true
462
      address: smtp.host.com
463
      port: 587
464
      domain: host.com
465
      authentication: :login
466
      user_name: myname
467
      password: mypassword
468
</pre>
469
470
You can check the e-Mail config in web interface with testmail function
471
472
h2. Autoupdate Subversion repository view
473
474
In the project archive settings over web interface its needed to enable the web service for project archives and generate a api key
475
476
The following cronjob updates redmine to current subversion changesets every 15 minutes
477
478
<pre>
479
sudo crontab -e
480
</pre>
481
482
Add the cronjob
483
484
<pre>
485
*/15 *    * * * curl "http://yourhost/redmine/sys/fetch_changesets?key=APIKEY" > /dev/null
486
</pre>
487 1 Redmine Geist
488
If your hosting does not offer cron job configuration then you can use external services like these:
489
https://www.easycron.com.
490 4 Redmine Geist
491
h2. SSL, HTTPS and Smart-HTTPS (Git)
492
493
h3. Own certificate
494
495
Create Private Key
496
497
<pre>
498
sudo mkdir /etc/apache2/ssl
499
cd /etc/apache2/ssl
500
sudo openssl genrsa -des3 -out server.key 1024
501
</pre>
502
503
Create CSR (Certificate Signing Request)
504
505
<pre>
506
cd /etc/apache2/ssl
507
sudo openssl req -new -key server.key -out server.csr
508
</pre>
509
510
Remove of the passphrase vom private key
511
512
<pre>
513
cd /etc/apache2/ssl
514
sudo cp server.key server.key.org
515
sudo openssl rsa -in server.key.org -out server.key
516
</pre>
517
518
Generate selfsigned certificate
519
520
<pre>
521
cd /etc/apache2/ssl
522
sudo openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
523
</pre>
524
525
h3. Configuration of apache2
526
527
Enable SSL module
528
529
<pre>sudo a2enmod ssl</pre>
530
531
Modification of apache2 configuration
532
533
<pre>sudo nano /etc/apache2/sites-available/default-ssl.conf</pre>
534
535
Following config is needed:
536
537
<pre>
538
<IfModule mod_ssl.c>
539
        ...
540
        <VirtualHost _default_:443>
541
                ServerAdmin webmaster@localhost
542
                DocumentRoot /var/www/html
543
                ErrorLog ${APACHE_LOG_DIR}/error.log
544
                CustomLog ${APACHE_LOG_DIR}/access.log combined
545
                SSLEngine on
546
                SSLCertificateFile      /etc/apache2/ssl/server.crt
547
                SSLCertificateKeyFile /etc/apache2/ssl/server.key
548
                <Directory /var/www/html/redmine>
549
                        RailsBaseURI /redmine
550
                        PassengerResolveSymlinksInDocumentRoot on
551
                </Directory>
552
        </VirtualHost>
553
        ...
554
    </IfModule>
555
</pre>
556
557
Activate the new configuration
558
559
<pre>sudo a2ensite default-ssl</pre>
560
561
h3. Smart-HTTPS client (Git)
562
563
For the client is needed to disable certificate verification. With Git bash:
564
565
<pre>git config --global http.sslverify false</pre>
566
567
*Caution:* This can be a security risk at access to foreign repositorys!
568 3 Redmine Geist
569
h1. Troubleshooting
570
571
h2. Logs
572
573
If you have some trouble during the installation, you can check the following files:
574
575
* /opt/gitolite/.gitolite/logs/gitolite-`date +%Y\-%m`.log
576
* /opt/redmine/log/git_hosting.log
577
* /var/log/apache2/error.log
578
579
If you use multitail:
580
581
multitail /opt/gitolite/.gitolite/logs/gitolite-`date +%Y\-%m`.log /opt/redmine/log/git_hosting.log /var/log/apache2/error.log