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

Hung Nguyen Vu, 2012-08-30 10:42
iptables works fine

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