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