Project

General

Profile

Redmine 203 with Subversion and LDAP Authentication (for Redmine and Subversion through Redmine) on Centos 6 i386 - detailed » History » Version 7

Hung Nguyen Vu, 2012-08-30 10:28
This works on both i386 and x64

1 7 Hung Nguyen Vu
h1. Redmine 2.0.3 on Centos 6.3
2 2 Sven Nosse
3
{{>toc}}
4
5
h2. Introduction
6
7 6 Hung Nguyen Vu
Our company was using the BITNAMI stack with Redmine and Subversion for our production environment. So the goal was about changing the server and migrating the data from Redmine 1.4 to Redmine 2.0.3 including getting all repositories and permissions preserved. 
8 1 Sven Nosse
9 6 Hung Nguyen Vu
I've tried to avoid webrick but rather use the fastCGI Module for Apache2. 
10
11
12
Second was converting the built-in accounts from the database to LDAP (ActiveDirectory). This is the result of 2 days of work and googling is this little tutorial for setting up a mentioned box doing exactly this stuff. We are using CentOS 6 (i386) for that task. 
13
14
# Please excuse my bad english for I am not used anymore to post long instruction manuals. Feel free to edit whatever you want. 
15
16
First of all, I tend to use vi so if you cannot operate vi I'd recommend to use any editor you like. If my instruction tells you to edit a file, you can find the sequence "..." which means, there is something above or below that line of text, that needs to be edited. Do not include those dots... 
17
18 1 Sven Nosse
h2. Assumptions
19
20 2 Sven Nosse
* You have a CentOS 6.3 installation (minimum install) working and SSH access to your box
21 6 Hung Nguyen Vu
* You can access the Internet
22
* You are logged in as root
23 1 Sven Nosse
24 6 Hung Nguyen Vu
h2. Redmine Installation Instruction
25 2 Sven Nosse
26
My personal flavour is to use as less self compiled packages as necessary to get the package up and runnning. So I try to use as many repository packages as possible.
27
28 6 Hung Nguyen Vu
h3. Turn off SE-Linux
29 3 Sven Nosse
30 6 Hung Nguyen Vu
I spent a lot of time to find out, that selinux can be a real party pooper. So I strongly recommend to disable that first before installing anything else. You can find a tutorial inside the howto section describing how to enable SELinux for your installation.
31 2 Sven Nosse
<pre>
32
vi /etc/selinux/config
33
</pre>
34
35 1 Sven Nosse
find the line with SELINUX and set it to
36 2 Sven Nosse
<pre>
37
...
38
SELINUX=disabled
39
...
40
</pre>
41
Do a reboot *NOW*
42
43 6 Hung Nguyen Vu
h3. Install basic services (Apache, mySQL, and several tools...)
44 2 Sven Nosse
45 1 Sven Nosse
Now we are good to go to install some tools that might be useful during our installation... First of all, update your system and then install some packages
46
<pre>
47 2 Sven Nosse
yum update
48
yum -y install wget system-config-network system-config-firewall vim openssh-clients
49
yum -y install httpd mysql mysql-server 
50 1 Sven Nosse
</pre>
51 2 Sven Nosse
After that continue and install all packages that might be necessary during the ruby and redmine installation.
52
<pre>
53
yum -y install ruby rubygems 
54 6 Hung Nguyen Vu
yum -y install zlib-devel curl-devel openssl-devel httpd-devel apr-devel apr-util-devel mysql-devel gcc ruby-devel \\
55
      gcc-c++ make postgresql-devel ImageMagick-devel sqlite-devel perl-LDAP mod_perl perl-Digest-SHA
56 2 Sven Nosse
</pre>
57
58
h3. Configure basic services
59
60 6 Hung Nguyen Vu
Let's configure the basic services, first of all, make mySQL and Apache to start at boot
61 2 Sven Nosse
<pre>
62
chkconfig httpd on --level 2345
63
chkconfig mysqld on --level 2345
64
</pre>
65
After configuring these, start them up
66
<pre>
67
service httpd start
68
service mysqld start
69
</pre>
70
Now configure your new mySQL Installation and follow the instructions. Please note the mysql administrator password.
71
<pre>
72
/usr/bin/mysql_secure_installation
73
</pre>
74
75
h3. Configure passenger for Apache
76
77
You need to install passenger for Apache using gem. Do the following on the command line
78
<pre>
79
gem install passenger
80
passenger-install-apache2-module
81
</pre>
82
Please notice the installation messages! The next .conf file might use another path or version! 
83
After this you need to generate a conf file with the displayed content
84
<pre>
85
vi /etc/httpd/conf.d/ruby.conf
86
</pre>
87
During my installation the following content was displayed and needs to be entered in that file:
88
<pre>
89
   LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.15/ext/apache2/mod_passenger.so
90
   PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.15
91
   PassengerRuby /usr/bin/ruby
92
</pre>
93
Restart your apache with
94
<pre>
95
service httpd restart
96
</pre>
97
98 1 Sven Nosse
h3. Get Redmine and install it
99
100
change to your home directory and download the latest version, expand it and copy it to the right place.
101
<pre>
102
cd
103
wget http://rubyforge.org/frs/download.php/76259/redmine-2.0.3.tar.gz
104
tar xvfz redmine-2.0.3.tar.gz
105
mkdir /var/www/redmine
106
cp -av redmine-2.0.3/* /var/www/redmine
107
</pre>
108 6 Hung Nguyen Vu
109
or you can do
110
111
<pre>
112
cd /var/www
113
wget http://rubyforge.org/frs/download.php/76259/redmine-2.0.3.tar.gz
114
tar xvfz redmine-2.0.3.tar.gz
115
mkdir -p /var/www/redmine
116
ln -s redmine-2.0 redmine
117
</pre>
118
119 1 Sven Nosse
Next is to install bundler and let it install the production environment (with automatic resolve)
120
Now change to this directory - *this is your new Redmine application directory!*
121 2 Sven Nosse
<pre>
122
cd /var/www/redmine
123
gem install bundler
124
bundle install --without development test
125
</pre>
126
fetch some coffee... this might take some time... 
127
128
h3. Create Redmine database
129
130 6 Hung Nguyen Vu
Next to generate a new database for redmine
131
Log on to your datbase with the following command. If prompted for a password, enter it.
132 2 Sven Nosse
<pre>
133
mysql -u root -p
134
</pre>
135
I tend to create a local only user for that database, change the password 'very_secret' to a better one :)
136
<pre>
137
create database redmine character set utf8;
138
create user 'redmine'@'localhost' identified by 'very_secret';
139
grant all privileges on redmine.* to 'redmine'@'localhost'; 
140
quit;
141
</pre>
142
143
h3. Configure Redmine
144
145
First of all, copy the example config to a productive one and edit the config for your needs
146
<pre>
147
cd /var/www/redmine/config
148
cp database.yml.example database.yml
149
vi /var/www/redmine/config/database.yml
150
</pre>
151
Now find the production section inside this file and edit it like that
152
<pre>
153
...
154
production:
155
  adapter: mysql
156
  database: redmine
157
  host: localhost
158
  username: redmine
159
  password: very_secret
160
  encoding: utf8
161
...
162
</pre>
163
Head back to your application directory and generate a secret token
164
<pre>
165
cd /var/www/redmine/
166
rake generate_secret_token
167
</pre>
168 1 Sven Nosse
Now it is about time to generate the database structure (application directory!)
169
<pre>
170 2 Sven Nosse
cd /var/www/redmine/
171
RAILS_ENV=production rake db:migrate
172
</pre>
173
fill the database with default values...
174 1 Sven Nosse
<pre>
175 2 Sven Nosse
cd /var/www/redmine/
176
RAILS_ENV=production rake redmine:load_default_data
177
</pre>
178
follow the instructions to select your language.
179
180 6 Hung Nguyen Vu
h3. Mind the firewall!
181 2 Sven Nosse
182 6 Hung Nguyen Vu
Be aware that the firewall is enabled by default (which is good!). So if you know which ports to open, do it now or disable the firewall (just for testing purposes). I'd really recommend disabling the firewall during installation and enable it (opening ports) after you are sure that everything works.
183 1 Sven Nosse
<pre>
184 2 Sven Nosse
system-config-firewall
185
</pre>
186
use the onscreen menu to disable it or adjust the values.
187
188 6 Hung Nguyen Vu
h3. Do a testdrive!
189 2 Sven Nosse
190
I mentioned that I wanted not to use webrick, but for a testdrive, it'll work. This helps finding bugs and errors that might have occured before.
191
<pre>
192
cd /var/www/redmine/
193
ruby script/rails server webrick -e production
194
</pre>
195
Open up a browser and point it to: http://yoursystemname.yourdomain.com:3000 - the default username and password is 'admin'.
196
If everything is working, you are good to go! Kill webrick by hitting Ctrl+C.
197
198 6 Hung Nguyen Vu
h3. Activate FCGI and generate plugin directory
199 2 Sven Nosse
200
To activate the fcgi module you need to copy the example file and edit the very first line. During this step it is recommended to generate the default .htaccess config as well.
201
<pre>
202
cd /var/www/redmine/public
203
mkdir plugin_assets
204
cp dispatch.fcgi.example dispatch.fcgi
205
cp htaccess.fcgi.example .htaccess
206 1 Sven Nosse
vi /var/www/redmine/public/dispatch.fcgi
207
</pre>
208 2 Sven Nosse
now edit dispatch.fcgi and change it like this...
209
<pre>
210
#!/usr/bin/ruby
211
...
212
</pre>
213
214
h3. Apache permissions!
215
216
this one is important, so don't miss that one... 
217 1 Sven Nosse
<pre>
218 2 Sven Nosse
chown -R apache:apache /var/www/redmine/
219 1 Sven Nosse
</pre>
220 2 Sven Nosse
221 6 Hung Nguyen Vu
Note: "apache" is the user that runs httpd (apache) service, as defined in /etc/password and /etc/httpd/conf/httpd.conf 
222
223 2 Sven Nosse
h3. Getting Apache to work with FastCGI
224
225
Unfortunately the default Repo from CentOS cannot deliver the fcgid module so it is important to include a replo, that can deliver this package. I use the Fedora Repo so it is time to activate this... Again - this can change so please take care which repository to use.
226
<pre>
227
rpm --import https://fedoraproject.org/static/0608B895.txt
228
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm
229
rpm -ivh epel-release-6-7.noarch.rpm
230
yum -y install mod_fcgid
231
</pre>
232
233 6 Hung Nguyen Vu
h3. Set the file path for Redmine
234 2 Sven Nosse
235
I wanted to move the files to another location, so I decided to move them to /opt/redmine
236
<pre>
237 6 Hung Nguyen Vu
mkdir -p /opt/redmine/files
238 2 Sven Nosse
chown -R apache:apache /opt/redmine
239
</pre>
240
now edit the configuration
241
<pre>
242
cd /var/www/redmine/config
243
cp configuration.yml.example configuration.yml
244
vi /var/www/redmine/config/configuration.yml
245
</pre>
246
edit the path settings inside this file...
247
<pre>
248
...
249
  attachments_storage_path: /opt/redmine/files
250
...
251
</pre>
252
253
h3. Telling Apache to serve REDMINE
254
255
The final step is to tell apache, where to find Redmine and what to do with it. Generate a new conf file for your virtual host to serve redmine...
256
<pre>
257
vi /etc/httpd/conf.d/redmine.conf
258
</pre>
259
and enter the following config (adjust to your needs ;) )
260
<pre>
261
<VirtualHost *:80>
262
        ServerName yoursystemname.yourdomain.com
263
        ServerAdmin yourmail@yourdomain.com
264
        DocumentRoot /var/www/redmine/public/
265
        ErrorLog logs/redmine_error_log
266
267
        MaxRequestLen 20971520
268
269
        <Directory "/var/www/redmine/public/">
270
271
                Options Indexes ExecCGI FollowSymLinks
272
                Order allow,deny
273
                Allow from all
274
                AllowOverride all
275
        </Directory>
276
</VirtualHost>
277
</pre>
278
Restart Apache and cross your fingers, wheter you can access http://yoursystemname.yourdomain.com - redmine should be available right now...
279
<pre>
280
service httpd restart
281
</pre>
282
283
h3. Additional Config: E-Mail System
284
285 1 Sven Nosse
in order to get emails sent to your clients, edit the configuration.yml and enter your server settings...
286
<pre>
287
vi /var/www/redmine/config/configuration.yml
288
</pre>
289
now find the settings for your server... the following settings describe an anonymous relay on an internal server. You need to remove the username and password line if you use anonymous sign on.
290
<pre>
291
...
292
default:
293
  # Outgoing emails configuration (see examples above)
294
  email_delivery:
295
    delivery_method: :smtp
296
    smtp_settings:
297
      address: mailserver.yourdomain.com
298
      port: 25
299
      domain: yourdomain.com
300
...
301
</pre>
302
303 6 Hung Nguyen Vu
Here is the configration if you use Google's SMTP server
304
305
<pre>
306
production:
307
  email_delivery:
308
    delivery_method: :smtp
309
    smtp_settings:
310
#      tls: true
311
      enable_starttls_auto: true
312
      address: "smtp.gmail.com"
313
      port: '587'
314
      domain: "smtp.gmail.com"
315
      authentication: :plain
316
      user_name: "google-account-name@domain-name.domain-extension"
317
      password: "password"
318
</pre>
319
320
321 1 Sven Nosse
h2. Getting Subversion working
322 2 Sven Nosse
323
After getting Redmine working, it is time to get Subversion working... The goal is to integrate the repositories inside Redmine and host them on the same server...
324
325
h3. Installing Packages for Subversion
326
327
Install the following packages
328 1 Sven Nosse
<pre>
329 2 Sven Nosse
yum -y install mod_dav_svn subversion subversion-ruby
330
</pre>
331
332
h3. Linking authentication for Redmine
333
334
Redmine provides a perl module to handle Apache authentication on SVN DAV repositories. First step is to link that module into the search path
335
<pre>
336
mkdir /usr/lib/perl5/vendor_perl/Apache
337
ln -s /var/www/redmine/extra/svn/Redmine.pm /usr/lib/perl5/vendor_perl/Apache/Redmine.pm
338
</pre>
339
340 6 Hung Nguyen Vu
h3. Creating repository for subversion
341 2 Sven Nosse
342
create a path and set permissions for your SVN repo...
343
<pre>
344
mkdir /opt/subversion
345
chown -R apache:apache /opt/subversion
346
</pre>
347
348 6 Hung Nguyen Vu
h3. Edit virtual host for apache to serve SVN with redmine
349 2 Sven Nosse
350
to get Apache working with subversion, you need to adjust (create) the virtual host file
351
<pre>
352
vi /etc/httpd/conf.d/subversion.conf
353
</pre>
354
now enter/edit the following
355
<pre>
356
PerlLoadModule Apache::Redmine
357
<Location /svn>
358
        DAV svn
359
        SVNParentPath "/opt/subversion"
360
        SVNListParentPath on
361
        Order deny,allow
362
        Deny from all
363
        Satisfy any
364
        LimitXMLRequestBody 0
365
        SVNPathAuthz off
366
367
        PerlAccessHandler Apache::Authn::Redmine::access_handler
368
        PerlAuthenHandler Apache::Authn::Redmine::authen_handler
369
        AuthType Basic
370
        AuthName "Redmine SVN Repository"
371
372
        Require valid-user
373
        RedmineDSN "DBI:mysql:database=redmine;host=localhost:3306"
374
        RedmineDbUser "redmine"
375
        RedmineDbPass "OuaWe0HXidr39X"
376
377
        # cache max. 50 passwords
378
        RedmineCacheCredsMax 50
379
</Location>
380
</pre>