Project

General

Profile

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

Sven Nosse, 2012-08-24 14:07

1 5 Sven Nosse
h1. Redmine 2.0.3 on Centos 6.3 (i386) - detailed step by step
2 2 Sven Nosse
3
{{>toc}}
4
5
h2. Introduction
6
7
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 v1.4 to v2.0.3 including getting all repositories and permissions moved. Doing this I tried to avoid webrick but rather use the fastCGI Module for Apache2. 
8
Second was converting the logins from the built in database to LDAP (ActiveDirectory). 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. Please excuse my bad english for I am not used anymore to post long instruction manuals. Feel free to edit whatever you want. 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... 
9
10
h2. Assumptions
11
12 5 Sven Nosse
* You have a CentOS 6.3 installation (minimum install) working and SSH access to your box
13 2 Sven Nosse
* You can access the internet
14
* You are logged in with your root account
15
16 4 Sven Nosse
h2. Redmine Installation Instructions
17 2 Sven Nosse
18
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.
19
20
h3. turn off SE-Linux
21
22 3 Sven Nosse
I spent a lot of time to find out, that se-linux 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.
23 2 Sven Nosse
<pre>
24
vi /etc/selinux/config
25
</pre>
26
27
find the line with SELINUX and set it to
28
<pre>
29
...
30
SELINUX=disabled
31
...
32
</pre>
33
Do a reboot *NOW*
34
35
h3. Install basic services (Apache, mySQL, and several tools...
36
37
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
38
<pre>
39
yum update
40
yum -y install wget system-config-network system-config-firewall vim openssh-clients
41
yum -y install httpd mysql mysql-server 
42
</pre>
43
After that continue and install all packages that might be necessary during the ruby and redmine installation.
44
<pre>
45
yum -y install ruby rubygems 
46
yum -y install zlib-devel curl-devel openssl-devel httpd-devel apr-devel apr-util-devel mysql-devel gcc ruby-devel gcc-c++ make postgresql-devel ImageMagick-devel sqlite-devel perl-LDAP mod_perl perl-Digest-SHA
47
</pre>
48
49
h3. Configure basic services
50
51
let's configure the basic services, first of all, enable mySQL and Apache to start at bootup
52
<pre>
53
chkconfig httpd on --level 2345
54
chkconfig mysqld on --level 2345
55
</pre>
56
After configuring these, start them up
57
<pre>
58
service httpd start
59
service mysqld start
60
</pre>
61
Now configure your new mySQL Installation and follow the instructions. Please note the mysql administrator password.
62
<pre>
63
/usr/bin/mysql_secure_installation
64
</pre>
65
66
h3. Configure passenger for Apache
67
68
You need to install passenger for Apache using gem. Do the following on the command line
69
<pre>
70
gem install passenger
71
passenger-install-apache2-module
72
</pre>
73
Please notice the installation messages! The next .conf file might use another path or version! 
74
After this you need to generate a conf file with the displayed content
75
<pre>
76
vi /etc/httpd/conf.d/ruby.conf
77
</pre>
78
During my installation the following content was displayed and needs to be entered in that file:
79
<pre>
80
   LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.15/ext/apache2/mod_passenger.so
81
   PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.15
82
   PassengerRuby /usr/bin/ruby
83
</pre>
84
Restart your apache with
85
<pre>
86
service httpd restart
87
</pre>
88
89
h3. Get Redmine and install it
90
91
change to your home directory and download the latest version, expand it and copy it to the right place.
92
<pre>
93
cd
94
wget http://rubyforge.org/frs/download.php/76259/redmine-2.0.3.tar.gz
95
tar xvfz redmine-2.0.3.tar.gz
96
mkdir /var/www/redmine
97
cp -av redmine-2.0.3/* /var/www/redmine
98
</pre>
99
Next is to install bundler and let it install the production environment (with automatic resolve)
100
Now change to this directory - *this is your new Redmine application directory!*
101
<pre>
102
cd /var/www/redmine
103
gem install bundler
104
bundle install --without development test
105
</pre>
106
fetch some coffee... this might take some time... 
107
108
h3. Create Redmine database
109
110
Next to generate a new database for redmine... Log on to your datbase with the following command. If prompted for a password, enter it.
111
<pre>
112
mysql -u root -p
113
</pre>
114
I tend to create a local only user for that database, change the password 'very_secret' to a better one :)
115
<pre>
116
create database redmine character set utf8;
117
create user 'redmine'@'localhost' identified by 'very_secret';
118
grant all privileges on redmine.* to 'redmine'@'localhost'; 
119
quit;
120
</pre>
121
122
h3. Configure Redmine
123
124
First of all, copy the example config to a productive one and edit the config for your needs
125
<pre>
126
cd /var/www/redmine/config
127
cp database.yml.example database.yml
128
vi /var/www/redmine/config/database.yml
129
</pre>
130
Now find the production section inside this file and edit it like that
131
<pre>
132
...
133
production:
134
  adapter: mysql
135
  database: redmine
136
  host: localhost
137
  username: redmine
138
  password: very_secret
139
  encoding: utf8
140
...
141
</pre>
142
Head back to your application directory and generate a secret token
143
<pre>
144
cd /var/www/redmine/
145
rake generate_secret_token
146
</pre>
147
Now it is about time to generate the database structure (application directory!)
148
<pre>
149
cd /var/www/redmine/
150
RAILS_ENV=production rake db:migrate
151
</pre>
152
fill the database with default values...
153
<pre>
154
cd /var/www/redmine/
155
RAILS_ENV=production rake redmine:load_default_data
156
</pre>
157
follow the instructions to select your language.
158
159
h3. mind the firewall!
160
161
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.
162
<pre>
163
system-config-firewall
164
</pre>
165
use the onscreen menu to disable it or adjust the values.
166
167
h3. do a testdrive!
168
169
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.
170
<pre>
171
cd /var/www/redmine/
172
ruby script/rails server webrick -e production
173
</pre>
174
Open up a browser and point it to: http://yoursystemname.yourdomain.com:3000 - the default username and password is 'admin'.
175
If everything is working, you are good to go! Kill webrick by hitting Ctrl+C.
176
177
h3. activate FCGI and generate plugin directory
178
179
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.
180
<pre>
181
cd /var/www/redmine/public
182
mkdir plugin_assets
183
cp dispatch.fcgi.example dispatch.fcgi
184
cp htaccess.fcgi.example .htaccess
185
vi /var/www/redmine/public/dispatch.fcgi
186
</pre>
187
now edit dispatch.fcgi and change it like this...
188
<pre>
189
#!/usr/bin/ruby
190
...
191
</pre>
192
193
h3. Apache permissions!
194
195
this one is important, so don't miss that one... 
196
<pre>
197
chown -R apache:apache /var/www/redmine/
198
</pre>
199
200
h3. Getting Apache to work with FastCGI
201
202
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.
203
<pre>
204
rpm --import https://fedoraproject.org/static/0608B895.txt
205
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm
206
rpm -ivh epel-release-6-7.noarch.rpm
207
yum -y install mod_fcgid
208
</pre>
209
210
h3. set the file path for Redmine
211
212
I wanted to move the files to another location, so I decided to move them to /opt/redmine
213
<pre>
214
mkdir /opt/redmine
215
mkdir /opt/redmine/files
216
chown -R apache:apache /opt/redmine
217
</pre>
218
now edit the configuration
219
<pre>
220
cd /var/www/redmine/config
221
cp configuration.yml.example configuration.yml
222
vi /var/www/redmine/config/configuration.yml
223
</pre>
224
edit the path settings inside this file...
225
<pre>
226
...
227
  attachments_storage_path: /opt/redmine/files
228
...
229
</pre>
230
231
h3. Telling Apache to serve REDMINE
232
233
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...
234
<pre>
235
vi /etc/httpd/conf.d/redmine.conf
236
</pre>
237
and enter the following config (adjust to your needs ;) )
238
<pre>
239
<VirtualHost *:80>
240
        ServerName yoursystemname.yourdomain.com
241
        ServerAdmin yourmail@yourdomain.com
242
        DocumentRoot /var/www/redmine/public/
243
        ErrorLog logs/redmine_error_log
244
245
        MaxRequestLen 20971520
246
247
        <Directory "/var/www/redmine/public/">
248
249
                Options Indexes ExecCGI FollowSymLinks
250
                Order allow,deny
251
                Allow from all
252
                AllowOverride all
253
        </Directory>
254
</VirtualHost>
255
</pre>
256
Restart Apache and cross your fingers, wheter you can access http://yoursystemname.yourdomain.com - redmine should be available right now...
257
<pre>
258
service httpd restart
259
</pre>
260
261
h3. Additional Config: E-Mail System
262
263
in order to get emails sent to your clients, edit the configuration.yml and enter your server settings...
264
<pre>
265
vi /var/www/redmine/config/configuration.yml
266
</pre>
267
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.
268
<pre>
269
...
270
default:
271
  # Outgoing emails configuration (see examples above)
272
  email_delivery:
273
    delivery_method: :smtp
274
    smtp_settings:
275
      address: mailserver.yourdomain.com
276
      port: 25
277
      domain: yourdomain.com
278
...
279
</pre>
280
281
h2. Getting Subversion working
282
283
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...
284
285
h3. Installing Packages for Subversion
286
287
Install the following packages
288
<pre>
289
yum -y install mod_dav_svn subversion subversion-ruby
290
</pre>
291
292
h3. Linking authentication for Redmine
293
294
Redmine provides a perl module to handle Apache authentication on SVN DAV repositories. First step is to link that module into the search path
295
<pre>
296
mkdir /usr/lib/perl5/vendor_perl/Apache
297
ln -s /var/www/redmine/extra/svn/Redmine.pm /usr/lib/perl5/vendor_perl/Apache/Redmine.pm
298
</pre>
299
300
h3. creating repository for subversion
301
302
create a path and set permissions for your SVN repo...
303
<pre>
304
mkdir /opt/subversion
305
chown -R apache:apache /opt/subversion
306
</pre>
307
308
h3. edit virtual host for apache to serve SVN with redmine
309
310
to get Apache working with subversion, you need to adjust (create) the virtual host file
311
<pre>
312
vi /etc/httpd/conf.d/subversion.conf
313
</pre>
314
now enter/edit the following
315
<pre>
316
PerlLoadModule Apache::Redmine
317
<Location /svn>
318
        DAV svn
319
        SVNParentPath "/opt/subversion"
320
        SVNListParentPath on
321
        Order deny,allow
322
        Deny from all
323
        Satisfy any
324
        LimitXMLRequestBody 0
325
        SVNPathAuthz off
326
327
        PerlAccessHandler Apache::Authn::Redmine::access_handler
328
        PerlAuthenHandler Apache::Authn::Redmine::authen_handler
329
        AuthType Basic
330
        AuthName "Redmine SVN Repository"
331
332
        Require valid-user
333
        RedmineDSN "DBI:mysql:database=redmine;host=localhost:3306"
334
        RedmineDbUser "redmine"
335
        RedmineDbPass "OuaWe0HXidr39X"
336
337
        # cache max. 50 passwords
338
        RedmineCacheCredsMax 50
339
</Location>
340
</pre>
341
342
*BE RIGHT BACK! THIS WILL BE CONTINUED IN A FEW HOURS!*