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

Hung Nguyen Vu, 2012-08-31 06:15

1 7 Hung Nguyen Vu
h1. Redmine 2.0.3 on Centos 6.3
2 2 Sven Nosse
3 20 Hung Nguyen Vu
{{>toc}} 
4 1 Sven Nosse
5 21 Hung Nguyen Vu
6 20 Hung Nguyen Vu
h2. The Goals
7 21 Hung Nguyen Vu
8 20 Hung Nguyen Vu
* Setup Redmine 2.0.3 running on CentOS 6.3;
9 20 Hung Nguyen Vu
* with MySQL backend, FastCGI to connect Redmine and Apache;
10 20 Hung Nguyen Vu
* integrate Redmine with Subversion;
11 20 Hung Nguyen Vu
* Single sign-on between Apache, Subversion and Redmine using LDAP
12 1 Sven Nosse
13 20 Hung Nguyen Vu
h2. Backgrounds
14 20 Hung Nguyen Vu
15 1 Sven Nosse
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. 
16 1 Sven Nosse
17 1 Sven Nosse
I've tried to avoid webrick but rather use the fastCGI Module for Apache2. 
18 1 Sven Nosse
19 20 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 for that task. 
20 6 Hung Nguyen Vu
21 20 Hung Nguyen Vu
"vi/vim" is the editor used this in this tutorial but you can you any editor you want. 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...
22 1 Sven Nosse
23 1 Sven Nosse
h2. Assumptions
24 2 Sven Nosse
25 20 Hung Nguyen Vu
* You have a CentOS 6.3 installation (minimum install) working and SSH access to your Redmine box;
26 20 Hung Nguyen Vu
* You can access the Internet;
27 20 Hung Nguyen Vu
* You are logged in as root.
28 6 Hung Nguyen Vu
29 2 Sven Nosse
h2. Redmine Installation Instruction
30 2 Sven Nosse
31 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.
32 6 Hung Nguyen Vu
33 20 Hung Nguyen Vu
h3. Turn off SELinux
34 6 Hung Nguyen Vu
35 2 Sven Nosse
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.
36 2 Sven Nosse
<pre>
37 2 Sven Nosse
vi /etc/selinux/config
38 2 Sven Nosse
</pre>
39 1 Sven Nosse
40 2 Sven Nosse
find the line with SELINUX and set it to
41 2 Sven Nosse
<pre>
42 2 Sven Nosse
...
43 2 Sven Nosse
SELINUX=disabled
44 2 Sven Nosse
...
45 2 Sven Nosse
</pre>
46 2 Sven Nosse
Do a reboot *NOW*
47 6 Hung Nguyen Vu
48 2 Sven Nosse
h3. Install basic services (Apache, mySQL, and several tools...)
49 9 Hung Nguyen Vu
50 9 Hung Nguyen Vu
Now we are good to go to install some tools that might be useful during our installation... 
51 9 Hung Nguyen Vu
52 1 Sven Nosse
First of all, update your system, make sure it is up to date,
53 1 Sven Nosse
<pre>
54 9 Hung Nguyen Vu
yum update
55 9 Hung Nguyen Vu
</pre>
56 9 Hung Nguyen Vu
57 9 Hung Nguyen Vu
and then install some prerequisite packages to the setup,
58 9 Hung Nguyen Vu
<pre>
59 9 Hung Nguyen Vu
yum -y install wget vim \\
60 9 Hung Nguyen Vu
       system-config-network system-config-firewall vim openssh-clients
61 9 Hung Nguyen Vu
</pre>
62 9 Hung Nguyen Vu
63 9 Hung Nguyen Vu
anhd some packages needed for Redmine
64 2 Sven Nosse
<pre>
65 1 Sven Nosse
yum -y install httpd mysql mysql-server 
66 2 Sven Nosse
</pre>
67 2 Sven Nosse
After that continue and install all packages that might be necessary during the ruby and redmine installation.
68 2 Sven Nosse
<pre>
69 6 Hung Nguyen Vu
yum -y install ruby rubygems 
70 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 \\
71 2 Sven Nosse
      gcc-c++ make postgresql-devel ImageMagick-devel sqlite-devel perl-LDAP mod_perl perl-Digest-SHA
72 2 Sven Nosse
</pre>
73 2 Sven Nosse
74 2 Sven Nosse
h3. Configure basic services
75 6 Hung Nguyen Vu
76 2 Sven Nosse
Let's configure the basic services, first of all, make mySQL and Apache to start at boot
77 18 Hung Nguyen Vu
<pre>
78 18 Hung Nguyen Vu
chkconfig httpd on --level 35
79 2 Sven Nosse
chkconfig mysqld on --level 35
80 2 Sven Nosse
</pre>
81 1 Sven Nosse
After configuring these, start them up
82 2 Sven Nosse
<pre>
83 2 Sven Nosse
service httpd start
84 2 Sven Nosse
service mysqld start
85 18 Hung Nguyen Vu
</pre>
86 2 Sven Nosse
Now configure your new mySQL Installation and follow the instructions. Please note/write down administrator password to MySQL you've just installed.
87 2 Sven Nosse
<pre>
88 2 Sven Nosse
/usr/bin/mysql_secure_installation
89 2 Sven Nosse
</pre>
90 2 Sven Nosse
91 2 Sven Nosse
h3. Configure passenger for Apache
92 2 Sven Nosse
93 20 Hung Nguyen Vu
You need to install Passenger for Apache using gem. Do the following on the command line
94 2 Sven Nosse
<pre>
95 2 Sven Nosse
gem install passenger
96 2 Sven Nosse
passenger-install-apache2-module
97 2 Sven Nosse
</pre>
98 2 Sven Nosse
Please notice the installation messages! The next .conf file might use another path or version! 
99 2 Sven Nosse
After this you need to generate a conf file with the displayed content
100 2 Sven Nosse
<pre>
101 2 Sven Nosse
vi /etc/httpd/conf.d/ruby.conf
102 2 Sven Nosse
</pre>
103 2 Sven Nosse
During my installation the following content was displayed and needs to be entered in that file:
104 2 Sven Nosse
<pre>
105 2 Sven Nosse
   LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.15/ext/apache2/mod_passenger.so
106 2 Sven Nosse
   PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.15
107 2 Sven Nosse
   PassengerRuby /usr/bin/ruby
108 2 Sven Nosse
</pre>
109 2 Sven Nosse
Restart your apache with
110 2 Sven Nosse
<pre>
111 2 Sven Nosse
service httpd restart
112 2 Sven Nosse
</pre>
113 1 Sven Nosse
114 1 Sven Nosse
h3. Get Redmine and install it
115 1 Sven Nosse
116 1 Sven Nosse
change to your home directory and download the latest version, expand it and copy it to the right place.
117 1 Sven Nosse
<pre>
118 1 Sven Nosse
cd
119 1 Sven Nosse
wget http://rubyforge.org/frs/download.php/76259/redmine-2.0.3.tar.gz
120 11 Hung Nguyen Vu
tar xvfz redmine-2.0.3.tar.gz
121 12 Hung Nguyen Vu
mkdir -p /var/www/redmine
122 1 Sven Nosse
cp redmine-2.0.3/* /var/www/redmine
123 6 Hung Nguyen Vu
</pre>
124 6 Hung Nguyen Vu
125 6 Hung Nguyen Vu
or you can do
126 6 Hung Nguyen Vu
127 6 Hung Nguyen Vu
<pre>
128 6 Hung Nguyen Vu
cd /var/www
129 6 Hung Nguyen Vu
wget http://rubyforge.org/frs/download.php/76259/redmine-2.0.3.tar.gz
130 6 Hung Nguyen Vu
tar xvfz redmine-2.0.3.tar.gz
131 6 Hung Nguyen Vu
ln -s redmine-2.0 redmine
132 6 Hung Nguyen Vu
</pre>
133 1 Sven Nosse
134 1 Sven Nosse
Next is to install bundler and let it install the production environment (with automatic resolve)
135 2 Sven Nosse
Now change to this directory - *this is your new Redmine application directory!*
136 2 Sven Nosse
<pre>
137 2 Sven Nosse
cd /var/www/redmine
138 2 Sven Nosse
gem install bundler
139 1 Sven Nosse
bundle install --without development test
140 10 Hung Nguyen Vu
</pre>
141 2 Sven Nosse
fetch some coffee... this might take some time...
142 2 Sven Nosse
143 2 Sven Nosse
h3. Create Redmine database
144 6 Hung Nguyen Vu
145 14 Sven Nosse
Next to generate a new database for redmine
146 2 Sven Nosse
Log on to your database with the following command. If prompted for a password, enter it.
147 2 Sven Nosse
<pre>
148 2 Sven Nosse
mysql -u root -p
149 2 Sven Nosse
</pre>
150 2 Sven Nosse
I tend to create a local only user for that database, change the password 'very_secret' to a better one :)
151 2 Sven Nosse
<pre>
152 2 Sven Nosse
create database redmine character set utf8;
153 2 Sven Nosse
create user 'redmine'@'localhost' identified by 'very_secret';
154 2 Sven Nosse
grant all privileges on redmine.* to 'redmine'@'localhost'; 
155 2 Sven Nosse
quit;
156 2 Sven Nosse
</pre>
157 19 Hung Nguyen Vu
158 19 Hung Nguyen Vu
Note: If you are going to store Redmine's database to a machine that is not the server you are going to install Redmine - whose IP address is 192.168.10.100, the settings should be: 
159 19 Hung Nguyen Vu
<pre>
160 19 Hung Nguyen Vu
create database redmine character set utf8;
161 19 Hung Nguyen Vu
create user 'redmine'@'192.168.10.100' identified by 'very_secret';
162 19 Hung Nguyen Vu
grant all privileges on redmine.* to 'redmine'@'192.168.10.100'; 
163 19 Hung Nguyen Vu
quit;
164 19 Hung Nguyen Vu
</pre>
165 19 Hung Nguyen Vu
166 2 Sven Nosse
167 2 Sven Nosse
h3. Configure Redmine
168 2 Sven Nosse
169 2 Sven Nosse
First of all, copy the example config to a productive one and edit the config for your needs
170 2 Sven Nosse
<pre>
171 2 Sven Nosse
cd /var/www/redmine/config
172 2 Sven Nosse
cp database.yml.example database.yml
173 2 Sven Nosse
vi /var/www/redmine/config/database.yml
174 2 Sven Nosse
</pre>
175 2 Sven Nosse
Now find the production section inside this file and edit it like that
176 2 Sven Nosse
<pre>
177 2 Sven Nosse
...
178 13 Hung Nguyen Vu
production:
179 13 Hung Nguyen Vu
# adapter = mysql2 is newer and proven to be more better than mysql
180 2 Sven Nosse
# adapter: mysql2
181 2 Sven Nosse
  adapter: mysql
182 2 Sven Nosse
  database: redmine
183 2 Sven Nosse
  host: localhost
184 2 Sven Nosse
  username: redmine
185 2 Sven Nosse
  password: very_secret
186 2 Sven Nosse
  encoding: utf8
187 2 Sven Nosse
...
188 2 Sven Nosse
</pre>
189 2 Sven Nosse
Head back to your application directory and generate a secret token
190 2 Sven Nosse
<pre>
191 2 Sven Nosse
cd /var/www/redmine/
192 2 Sven Nosse
rake generate_secret_token
193 1 Sven Nosse
</pre>
194 1 Sven Nosse
Now it is about time to generate the database structure (application directory!)
195 2 Sven Nosse
<pre>
196 2 Sven Nosse
cd /var/www/redmine/
197 2 Sven Nosse
RAILS_ENV=production rake db:migrate
198 2 Sven Nosse
</pre>
199 1 Sven Nosse
fill the database with default values...
200 2 Sven Nosse
<pre>
201 2 Sven Nosse
cd /var/www/redmine/
202 2 Sven Nosse
RAILS_ENV=production rake redmine:load_default_data
203 2 Sven Nosse
</pre>
204 2 Sven Nosse
follow the instructions to select your language.
205 6 Hung Nguyen Vu
206 2 Sven Nosse
h3. Mind the firewall!
207 6 Hung Nguyen Vu
208 1 Sven Nosse
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.
209 2 Sven Nosse
<pre>
210 2 Sven Nosse
system-config-firewall
211 2 Sven Nosse
</pre>
212 2 Sven Nosse
use the onscreen menu to disable it or adjust the values.
213 8 Hung Nguyen Vu
214 8 Hung Nguyen Vu
or simply disable iptables during Redmine's setup
215 8 Hung Nguyen Vu
<pre>
216 8 Hung Nguyen Vu
service iptables stop
217 8 Hung Nguyen Vu
</pre>
218 6 Hung Nguyen Vu
219 2 Sven Nosse
h3. Do a testdrive!
220 2 Sven Nosse
221 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.
222 2 Sven Nosse
<pre>
223 2 Sven Nosse
cd /var/www/redmine/
224 2 Sven Nosse
ruby script/rails server webrick -e production
225 2 Sven Nosse
</pre>
226 2 Sven Nosse
Open up a browser and point it to: http://yoursystemname.yourdomain.com:3000 - the default username and password is 'admin'.
227 2 Sven Nosse
If everything is working, you are good to go! Kill webrick by hitting Ctrl+C.
228 6 Hung Nguyen Vu
229 2 Sven Nosse
h3. Activate FCGI and generate plugin directory
230 2 Sven Nosse
231 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.
232 2 Sven Nosse
<pre>
233 2 Sven Nosse
cd /var/www/redmine/public
234 2 Sven Nosse
mkdir plugin_assets
235 2 Sven Nosse
cp dispatch.fcgi.example dispatch.fcgi
236 1 Sven Nosse
cp htaccess.fcgi.example .htaccess
237 1 Sven Nosse
vi /var/www/redmine/public/dispatch.fcgi
238 2 Sven Nosse
</pre>
239 2 Sven Nosse
now edit dispatch.fcgi and change it like this...
240 2 Sven Nosse
<pre>
241 2 Sven Nosse
#!/usr/bin/ruby
242 2 Sven Nosse
...
243 2 Sven Nosse
</pre>
244 2 Sven Nosse
245 2 Sven Nosse
h3. Apache permissions!
246 2 Sven Nosse
247 1 Sven Nosse
this one is important, so don't miss that one... 
248 2 Sven Nosse
<pre>
249 1 Sven Nosse
chown -R apache:apache /var/www/redmine/
250 2 Sven Nosse
</pre>
251 6 Hung Nguyen Vu
252 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 
253 2 Sven Nosse
254 2 Sven Nosse
h3. Getting Apache to work with FastCGI
255 2 Sven Nosse
256 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.
257 2 Sven Nosse
<pre>
258 2 Sven Nosse
rpm --import https://fedoraproject.org/static/0608B895.txt
259 2 Sven Nosse
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm
260 2 Sven Nosse
rpm -ivh epel-release-6-7.noarch.rpm
261 2 Sven Nosse
yum -y install mod_fcgid
262 2 Sven Nosse
</pre>
263 6 Hung Nguyen Vu
264 2 Sven Nosse
h3. Set the file path for Redmine
265 2 Sven Nosse
266 2 Sven Nosse
I wanted to move the files to another location, so I decided to move them to /opt/redmine
267 6 Hung Nguyen Vu
<pre>
268 2 Sven Nosse
mkdir -p /opt/redmine/files
269 2 Sven Nosse
chown -R apache:apache /opt/redmine
270 2 Sven Nosse
</pre>
271 2 Sven Nosse
now edit the configuration
272 2 Sven Nosse
<pre>
273 2 Sven Nosse
cd /var/www/redmine/config
274 2 Sven Nosse
cp configuration.yml.example configuration.yml
275 2 Sven Nosse
vi /var/www/redmine/config/configuration.yml
276 2 Sven Nosse
</pre>
277 2 Sven Nosse
edit the path settings inside this file...
278 2 Sven Nosse
<pre>
279 2 Sven Nosse
...
280 2 Sven Nosse
  attachments_storage_path: /opt/redmine/files
281 2 Sven Nosse
...
282 2 Sven Nosse
</pre>
283 2 Sven Nosse
284 2 Sven Nosse
h3. Telling Apache to serve REDMINE
285 2 Sven Nosse
286 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...
287 2 Sven Nosse
<pre>
288 2 Sven Nosse
vi /etc/httpd/conf.d/redmine.conf
289 2 Sven Nosse
</pre>
290 2 Sven Nosse
and enter the following config (adjust to your needs ;) )
291 2 Sven Nosse
<pre>
292 2 Sven Nosse
<VirtualHost *:80>
293 2 Sven Nosse
        ServerName yoursystemname.yourdomain.com
294 2 Sven Nosse
        ServerAdmin yourmail@yourdomain.com
295 2 Sven Nosse
        DocumentRoot /var/www/redmine/public/
296 2 Sven Nosse
        ErrorLog logs/redmine_error_log
297 2 Sven Nosse
298 2 Sven Nosse
        MaxRequestLen 20971520
299 2 Sven Nosse
300 2 Sven Nosse
        <Directory "/var/www/redmine/public/">
301 2 Sven Nosse
302 2 Sven Nosse
                Options Indexes ExecCGI FollowSymLinks
303 2 Sven Nosse
                Order allow,deny
304 2 Sven Nosse
                Allow from all
305 2 Sven Nosse
                AllowOverride all
306 2 Sven Nosse
        </Directory>
307 2 Sven Nosse
</VirtualHost>
308 2 Sven Nosse
</pre>
309 2 Sven Nosse
Restart Apache and cross your fingers, wheter you can access http://yoursystemname.yourdomain.com - redmine should be available right now...
310 2 Sven Nosse
<pre>
311 2 Sven Nosse
service httpd restart
312 2 Sven Nosse
</pre>
313 2 Sven Nosse
314 2 Sven Nosse
h3. Additional Config: E-Mail System
315 1 Sven Nosse
316 1 Sven Nosse
in order to get emails sent to your clients, edit the configuration.yml and enter your server settings...
317 1 Sven Nosse
<pre>
318 1 Sven Nosse
vi /var/www/redmine/config/configuration.yml
319 1 Sven Nosse
</pre>
320 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.
321 1 Sven Nosse
<pre>
322 1 Sven Nosse
...
323 1 Sven Nosse
default:
324 1 Sven Nosse
  # Outgoing emails configuration (see examples above)
325 1 Sven Nosse
  email_delivery:
326 1 Sven Nosse
    delivery_method: :smtp
327 1 Sven Nosse
    smtp_settings:
328 1 Sven Nosse
      address: mailserver.yourdomain.com
329 1 Sven Nosse
      port: 25
330 1 Sven Nosse
      domain: yourdomain.com
331 1 Sven Nosse
...
332 1 Sven Nosse
</pre>
333 6 Hung Nguyen Vu
334 6 Hung Nguyen Vu
Here is the configration if you use Google's SMTP server
335 6 Hung Nguyen Vu
336 6 Hung Nguyen Vu
<pre>
337 6 Hung Nguyen Vu
production:
338 6 Hung Nguyen Vu
  email_delivery:
339 6 Hung Nguyen Vu
    delivery_method: :smtp
340 6 Hung Nguyen Vu
    smtp_settings:
341 6 Hung Nguyen Vu
#      tls: true
342 6 Hung Nguyen Vu
      enable_starttls_auto: true
343 6 Hung Nguyen Vu
      address: "smtp.gmail.com"
344 6 Hung Nguyen Vu
      port: '587'
345 6 Hung Nguyen Vu
      domain: "smtp.gmail.com"
346 6 Hung Nguyen Vu
      authentication: :plain
347 6 Hung Nguyen Vu
      user_name: "google-account-name@domain-name.domain-extension"
348 6 Hung Nguyen Vu
      password: "password"
349 6 Hung Nguyen Vu
</pre>
350 1 Sven Nosse
351 2 Sven Nosse
h2. Getting Subversion working
352 2 Sven Nosse
353 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...
354 2 Sven Nosse
355 2 Sven Nosse
h3. Installing Packages for Subversion
356 2 Sven Nosse
357 1 Sven Nosse
Install the following packages
358 2 Sven Nosse
<pre>
359 2 Sven Nosse
yum -y install mod_dav_svn subversion subversion-ruby
360 2 Sven Nosse
</pre>
361 2 Sven Nosse
362 2 Sven Nosse
h3. Linking authentication for Redmine
363 2 Sven Nosse
364 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
365 2 Sven Nosse
<pre>
366 2 Sven Nosse
mkdir /usr/lib/perl5/vendor_perl/Apache
367 2 Sven Nosse
ln -s /var/www/redmine/extra/svn/Redmine.pm /usr/lib/perl5/vendor_perl/Apache/Redmine.pm
368 2 Sven Nosse
</pre>
369 16 Sven Nosse
370 2 Sven Nosse
h3. Creating a path for subversion repositories
371 2 Sven Nosse
372 2 Sven Nosse
create a path and set permissions for your SVN repo...
373 2 Sven Nosse
<pre>
374 2 Sven Nosse
mkdir /opt/subversion
375 2 Sven Nosse
chown -R apache:apache /opt/subversion
376 2 Sven Nosse
</pre>
377 6 Hung Nguyen Vu
378 2 Sven Nosse
h3. Edit virtual host for apache to serve SVN with redmine
379 2 Sven Nosse
380 2 Sven Nosse
to get Apache working with subversion, you need to adjust (create) the virtual host file
381 2 Sven Nosse
<pre>
382 2 Sven Nosse
vi /etc/httpd/conf.d/subversion.conf
383 2 Sven Nosse
</pre>
384 2 Sven Nosse
now enter/edit the following
385 2 Sven Nosse
<pre>
386 2 Sven Nosse
PerlLoadModule Apache::Redmine
387 2 Sven Nosse
<Location /svn>
388 2 Sven Nosse
        DAV svn
389 2 Sven Nosse
        SVNParentPath "/opt/subversion"
390 2 Sven Nosse
        SVNListParentPath on
391 2 Sven Nosse
        Order deny,allow
392 2 Sven Nosse
        Deny from all
393 2 Sven Nosse
        Satisfy any
394 2 Sven Nosse
        LimitXMLRequestBody 0
395 2 Sven Nosse
        SVNPathAuthz off
396 2 Sven Nosse
397 2 Sven Nosse
        PerlAccessHandler Apache::Authn::Redmine::access_handler
398 2 Sven Nosse
        PerlAuthenHandler Apache::Authn::Redmine::authen_handler
399 2 Sven Nosse
        AuthType Basic
400 2 Sven Nosse
        AuthName "Redmine SVN Repository"
401 2 Sven Nosse
402 2 Sven Nosse
        Require valid-user
403 2 Sven Nosse
        RedmineDSN "DBI:mysql:database=redmine;host=localhost:3306"
404 15 Sven Nosse
        RedmineDbUser "redmine"
405 2 Sven Nosse
        RedmineDbPass "very_secret"
406 2 Sven Nosse
407 1 Sven Nosse
        # cache max. 50 passwords
408 1 Sven Nosse
        RedmineCacheCredsMax 50
409 14 Sven Nosse
</Location>
410 14 Sven Nosse
</pre>
411 17 Hung Nguyen Vu
412 14 Sven Nosse
h3. Achievements
413 17 Hung Nguyen Vu
414 17 Hung Nguyen Vu
What we've done at this point:
415 17 Hung Nguyen Vu
* A running Redmine v2.0.3 installation using Apache Passenger
416 17 Hung Nguyen Vu
* Working authentication with Redmine's builtin database
417 17 Hung Nguyen Vu
* Working Subversion with Apache's WebDav
418 14 Sven Nosse
* Subversion authentication against redmine's builtin database
419 14 Sven Nosse
420 14 Sven Nosse
h2. Authentication against Active Directory
421 14 Sven Nosse
422 14 Sven Nosse
The last step requires some knowledge how to authenticate against your Active directory. First of all, open up Redmine in a web interface and enter the Administration dialogue. Select LDAP-Authentication adn create a new authentication entry.
423 14 Sven Nosse
424 14 Sven Nosse
* Name: Enter a NAME for your entry, this can be anything... 
425 14 Sven Nosse
* Host: Enter the IP address of a domain controler unless you are really sure, that DNS is working correctly
426 14 Sven Nosse
* Port: 389
427 14 Sven Nosse
* Account: This one is kind of a pitfall. Enter the DN of the user object that can authenticate against the Active Directory.
428 14 Sven Nosse
??EXAMPLE??: Assume that you have a domain that is called: mynetwork.local and an organizational unit that is named: myUsers. The DN of this organizational unit is: @OU=myUsers, DC=mynetwork, DC=local@ If you create a user, which Display name is like ??ldap authentication user?? then the Account you need to enter is: @CN=ldap authentication user, OU=myUsers, DC=mynetwork, DC=local@. I'd recommend using a tool like Sysinternals ADExplorer if you are unsure about the distinguished name of your authentication user.
429 14 Sven Nosse
* Base DN: This is the entry point, where Redmine tries to find users. In the example above you want to enter: @OU=myUsers, DC=mynetwork, DC=local@
430 14 Sven Nosse
* LDAP Filter: You can enter any filter you like here, a valid filter for finding users is: @(&(objectClass=user)(objectCategory=person))@. 
431 14 Sven Nosse
* On-the-fly Usercreation: I tend to check this.. This allows the initial creation of a new user when the user logs on redmine.
432 14 Sven Nosse
433 14 Sven Nosse
Attributes: _(I am not sure, whether the fields below are correctly tranlsated... please correct if necessary)_
434 14 Sven Nosse
* member name: sAMAccountName
435 14 Sven Nosse
* first name: givenname
436 14 Sven Nosse
* surname: sn
437 14 Sven Nosse
* E-Mail: mail
438 14 Sven Nosse
439 14 Sven Nosse
Save it, try it :)
440 14 Sven Nosse
441 14 Sven Nosse
You should be able to log on with your windows logon name and your windows passwort. If you've never logged on a new account should have been created within the redmine built in database.
442 14 Sven Nosse
443 14 Sven Nosse
h2. Last step - authenticate Subversion against active directory (by using the built in database from redmine!)
444 14 Sven Nosse
445 14 Sven Nosse
This one is tricky, you want the authentication data from Active Directory but you also want the group permissions from redmine. So you need to tell the logon mechanism to authenticate against AD and check inside the database, whether the user is SVN editor or not. Finally most of the work is done here with the redmine.pm script (remember, we've linked that already). But unfortunatelly the CentOS Perl implementation includes no module for Simple::LDAP. So we need to do some compiler work... 
446 14 Sven Nosse
447 14 Sven Nosse
First of all, fetch the packages needed for building the necessary perl module(s).
448 14 Sven Nosse
<pre>
449 14 Sven Nosse
yum -y install perl-CPAN perl-YAML
450 14 Sven Nosse
</pre>
451 14 Sven Nosse
452 14 Sven Nosse
There are a lot of dependencies when trying to build the module, so I recommend to turn on automatic dependency handling inside the CPAN shell....
453 14 Sven Nosse
Start up the shell:
454 14 Sven Nosse
<pre>
455 14 Sven Nosse
perl -MCPAN -e shell
456 14 Sven Nosse
</pre>
457 14 Sven Nosse
and then run the following two commands:
458 14 Sven Nosse
<pre>
459 14 Sven Nosse
o conf prerequisites_policy follow
460 14 Sven Nosse
o conf commit
461 14 Sven Nosse
</pre>
462 14 Sven Nosse
Now it is time, to install the module, still inside the shell. Enter
463 14 Sven Nosse
<pre>
464 14 Sven Nosse
install Authen::Simple::LDAP
465 14 Sven Nosse
</pre>
466 14 Sven Nosse
This takes some time... If queried for any dependencies or defaults, just acknowledge them with their default values - this should work.
467 14 Sven Nosse
Close the shell after everything is done by entering
468 14 Sven Nosse
<pre>
469 14 Sven Nosse
exit
470 14 Sven Nosse
</pre>
471 14 Sven Nosse
472 14 Sven Nosse
Now we need to tell Apache where to find the authentication data, this is simple by editing the subversion.conf
473 14 Sven Nosse
<pre>
474 14 Sven Nosse
vi /etc/httpd/conf.d/subversion.conf
475 14 Sven Nosse
</pre>
476 14 Sven Nosse
just add the Simple::LDAP Perl module by editing it this way:
477 14 Sven Nosse
<pre>
478 14 Sven Nosse
   ...
479 14 Sven Nosse
   PerlLoadModule Apache::Redmine
480 14 Sven Nosse
   PerlLoadModule  Authen::Simple::LDAP
481 14 Sven Nosse
   <Location /svn>
482 14 Sven Nosse
     DAV svn
483 14 Sven Nosse
     ...
484 14 Sven Nosse
</pre>
485 14 Sven Nosse
486 14 Sven Nosse
Restart Apache and LDAP Authentication should work now
487 14 Sven Nosse
<pre>
488 2 Sven Nosse
service httpd restart
489 1 Sven Nosse
</pre>