Project

General

Profile

HowTo Install Redmine in Ubuntu » History » Version 13

allen yeh, 2010-09-02 18:59
Change @/etc/redmine/database.yml@ to @/etc/redmine/default/database.yml:@

1 6 Roger Lipscombe
h1. Ubuntu 10.4 LTS using mod_cgi
2 3 Sam Wilson
3 7 Mischa The Evil
{{>toc}}
4
5 3 Sam Wilson
As of 10.4, Redmine is available through Ubuntu's package manager, and installation is simple:
6
7
> $ sudo apt-get install redmine redmine-mysql
8
9
The second package, _redmine-mysql_, can be replaced by either _redmine-pgsql_ or _redmine-sqlite_ if you want to use either of those databases.
10
11
Redmine will now be installed in @/usr/share/redmine@ and @/etc/redmine@
12
13
h2. Configuration
14
15
Symlink @/usr/share/redmine/public@ to your desired web-accessible location.  E.g.:
16
17 8 Holger Just
> $ ln -s /usr/share/redmine/public /var/www/redmine
18 3 Sam Wilson
19
The other files that you need to modify/create are as follows:
20
21 13 allen yeh
@/etc/redmine/default/database.yml@:
22 3 Sam Wilson
23
<pre>
24
production:
25
  adapter: mysql
26
  database: redmine
27
  host: localhost
28
  username: redmine
29
  password: pa55w0rd
30
  encoding: utf8
31
</pre>
32
33 12 Rolf Wojtech
@/usr/share/redmine/public/dispatch.cgi@:
34 3 Sam Wilson
35
<pre>
36
#!/usr/bin/ruby
37
38
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
39
40
require "dispatcher"
41
42
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
43
Dispatcher.dispatch
44
</pre>
45
46 4 Sam Wilson
@/usr/share/redmine/public/.htaccess@:
47 3 Sam Wilson
48
<pre>
49
RewriteEngine On
50
RewriteBase /redmine
51
RewriteRule ^$ index.html [QSA]
52
RewriteRule ^([^.]+)$ $1.html [QSA]
53
RewriteCond %{REQUEST_FILENAME} !-f
54
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
55
</pre>
56
57
And that's it!  If these instructions didn't work for you, please expand them to include whatever is needed.
58 1 Umit Uzun
59 6 Roger Lipscombe
h1. Ubuntu 10.4 using Passenger
60
61
If you can't get it working with mod_cgi, you might want to try mod_passenger (it's also quicker):
62 5 Roger Lipscombe
63
> $ sudo apt-get install redmine redmine-mysql
64
65
The second package, _redmine-mysql_, can be replaced by either _redmine-pgsql_ or _redmine-sqlite_ if you want to use either of those databases.
66
67
Ubuntu should prompt you for all the interesting details.
68
69
Redmine will now be installed in @/usr/share/redmine@ and @/etc/redmine@
70
71
h2. Configuration
72
73
Symlink @/usr/share/redmine/public@ to your desired web-accessible location.  E.g.:
74
75 9 Holger Just
> $ ln -s /usr/share/redmine/public /var/www/redmine
76 5 Roger Lipscombe
77
By default, passenger runs as 'nobody', so you'll need to fix that. In @/etc/apache2/mods-available/passenger.conf@, add a @PassengerDefaultUser www-data@ directive.
78
79
You'll also need to configure the @/var/www/redmine@ location in @/etc/apache2/sites-available/default@:
80
81
<pre><Directory /var/www/redmine>
82
    RailsBaseURI /redmine
83
</Directory>
84
</pre>
85
86
> $ sudo a2enmod passenger
87
88
Restart apache2 and you should be good to go.
89
90 3 Sam Wilson
h1. Redmine Installation on Virtual or Normal Ubuntu < 10.4
91 1 Umit Uzun
92 2 Sam Wilson
This page is a guide to installing Redmine on either a virtual or actual installation of the Ubuntu operating system.  If you follow all instructions correctly you will be installed your Redmine server successfully almost an hour.
93 1 Umit Uzun
94 2 Sam Wilson
h2. Step 1: Install Ubuntu
95 1 Umit Uzun
96 2 Sam Wilson
If you are installing on a non-virtual Ubuntu instance, please skip this section.
97 1 Umit Uzun
98 2 Sam Wilson
*Installing VirtualBox:*
99
100
1.Download last version of Sun VirtualBox (version 3.0.10 or newer) tool in your system.
101 1 Umit Uzun
2.Install to your system by following the instructions.
102
103
*Installing Ubuntu on VirtualBox:*
104
105
1.Download last version of Ubuntu(version 9.10 or newer) OS in your system.
106
2.After installed VirtualBox on your system you will create a new virtual operating which will be Linux type and Ubuntu subtype. If you don't know anything about VirtualBox and/or its usage please refer to the google.
107
108
3.While installing Ubuntu you should type the related configurations as follows:
109
(These all configurations are optional, you can give any name what you what.)
110
Q: What is your name? A: Redmine Server
111
Q: What name do you want to use to login? A: redmine
112
Q: Choose to password to keep your account safe? A: redmine
113
Q: What is the name of this computer? A: redmine-server
114
Choose “Log in automatically.” radio button.
115
116
4.When you finished up installation all of them open up your new VirtualBox Ubuntu OS and open up terminal(console) screen and  issuing these commands:
117
> sudo apt-get update
118
> sudo apt-get upgrade
119
120
*Configuring VirtualBox:*
121
122
1.If you want to reach your VirtualBox Ubuntu OS from different machine, you have to configure VirtualBox Ubuntu OS's network setting to Bridged Adapter. So you can reach your VirtualBox Ubuntu from internal IP address easily. Because it get's same IP block as you from DHCP easily. I mean your guest and host computer is same IP block as different network client.
123
124
2.If you had assigned a static IP to your Network Consult by giving your static ethernet MAC address, you have to assign unique MAC address your VirtualBox Ubuntu OS by Setting->Network->MAC address initialization box. By this MAC address, you can get static ip easily or you can configure your Ubuntu system to not use DHCP, instead of that you can assign static IP manually.
125
126 2 Sam Wilson
h2. Step 2: Install Redmine
127 1 Umit Uzun
128 2 Sam Wilson
Once you have a functioning Ubuntu operating system up and running, you can continue with installing Redmine.
129 1 Umit Uzun
130 2 Sam Wilson
h3. Install dependencies
131
132
The following packages are required to install and run Redmine.  Please install them by running @apt-get@ as root:
133
134
>sudo apt-get package-name
135
136
where @package-name@ is each of:
137
* apache2 
138
* apache2-threaded-dev 
139
* build-essential
140
* libapache-dbi-perl 
141
* libapache2-mod-perl2 
142
* libapache2-svn
143
* libdigest-sha1-perl 
144
* libgemplugin-ruby 
145
* libgemplugin-ruby1.8 
146
* libruby-extras 
147
* libruby1.8-extras 
148
* mongrel 
149
* mysql-server
150
* rails
151
* rake 
152
* ruby
153
* rubygems
154
* rubygems1.8
155
* ruby1.8-dev
156
* subversion
157
158
_(Could someone please clean up this list?)_
159
160 1 Umit Uzun
*Package Installation and Setup:*
161
162
1.Once you’ve installed the VirtualBox Ubuntu OS and updated it, you need to install a bunch of packages that we will prepare the server for the Redmine installation. So, as root, install the following packages by issuing: 
163 2 Sam Wilson
> sudo apt-get install 
164
> sudo apt-get install 
165 1 Umit Uzun
166
The packages we’re installing above are MySQL, phpMyAdmin, Rails, Ruby Gems, Mongrel and Ruby Dev environment.
167
During the installation of the packages, when MySQL is installed, it will prompt you to	create a password. Make sure you remember it. You will need it later to log in to the 	phpMyAdmin. To make simplicity you can set all passwords to “redmine”.
168
169
2.Create a new directory for Redmine. I put mine in /opt/redmine. And download last version of Redmine in it with wget command line downloader and extract it by issuing:
170
> sudo mkdir /opt/redmine
171
> sudo cd /opt/redmine
172
> sudo wget http://rubyforge.org/frs/download.php/66633/redmine-0.8.6.tar.gz
173
> tar -xvf redmine-0.8.6.tar.gz
174
175
*Database Setup:*
176
177
1.Now it’s time to create an empty database for Redmine. As you may have noticed, we installed phpMyAdmin earlier. phpMyAdmin will come in handy now. Head over to http://localhost/phpmyadmin. You should be presented with the phpMyAdmin login screen.
178
Type in “root” and the MySQL “password” you created when installing MySQL.
179
180
2.First, click on “Databases” Then, at the bottom of the screen, in the “Create new database” text box create a new database called “redmine” and set “Collation” to “utf8_general_ci”.
181
182
3.Now, go back to the home screen and click on:
183
“Privileges”
184
“Add a new User” 
185
Fill out the “Login Information” boxes. Call your user “redmine”. Make sure you remember password you create here. It will be used when you set up the database connection details in Redmine.
186
In the “Database for user” section, check “Create database with same name and grant all privileges” and click on the “Go” button.
187
188
4.Log out of phpMyAdmin.
189
190
*Redmine Database Connection Configuration:*
191
192
1.It’s time to configure the database connection. If you installed Redmine as I did above, then copy “config/database.yml.example” to “config/database.yml” and edit this file in order to configure your database settings for “production” environment. You’ll find the “database.yml.example” issuing:
193
> sudo cd /opt/redmine/redmine-0.8.6/config
194
195
2.So now, assuming you’re in the “/opt/redmine/redmine-0.8.6/config” directory, issue:
196
> sudo cp database.yml.example database.yml 
197
198
3.Then, open the “database.yml” file, issue:
199
> sudo gedit database.yml
200
… and edit it as in the example for a MySQL database below:
201
202
production:
203
adapter: mysql
204
socket: /var/run/mysqld/mysqld.sock
205
database: redmine
206
host: localhost
207
username: redmine
208
password: [password]
209
210
Then save “database.yml” file and exit to the command prompt.
211
On Ubuntu the “mysql.sock” is located in /var/run/mysqld/mysqld.sock, as noted in the “config” above. 
212
(The standard Redmine installation assumes the socket is located in “/opt/redmine/redmine-0.8.6/tmp/mysqld.sock”.)
213
214
4.Create the database structure, by running the following command under the application root directory(I mean “/opt/redmine/redmine-0.8.6”):
215
> sudo rake db:migrate RAILS_ENV="production" 
216
It will create the necessary tables in the redmine database you created earlier and an 	administrator account.
217
218
5.Insert default configuration data in database, by issuing:
219
> sudo rake redmine:load_default_data RAILS_ENV="production" 
220
(This step is optional but highly recommended, as you can define your own configuration	from scratch. It will load default roles, trackers, statuses, work flows and enumerations. While loading default data command prompt wants to given language selection by you.) 
221
222
*Setting up Permissions:*
223
224
1.The user who runs Redmine must have write permission on the following sub directories: “files”, “log”, “tmp” (create the last one if not present). You probably already have a “tmp” directory in /opt/redmine/redmine-0.8.6, but if you don’t, create one now by issuing:
225
> sudo mkdir /opt/redmine/redmine-0.8.6
226
227
2.If you haven’t created a Redmine user, do it now by issuing:
228
> sudo useradd redmine
229
230
3.Now, assuming you run Redmine with a redmine user, from your /opt/redmine/redmine-0.8.6 directory issue:
231
> sudo chown -R redmine:redmine files log tmp
232
> sudo chmod -R 755 files log tmp
233
234
*Testing the Installation:*
235
236
1.It should all be working now. Test the installation by running the WEBrick web server issue:
237
> sudo cd /opt/redmine/redmine-0.8.6
238
> sudo ruby script/server -e production
239
	
240
Once WEBrick has started, point your browser to http://localhost:3000/. Or, if you are using a browser on another computer than what you installed Redmine on, point your browser to http://192.168.1.10:3000/ (if that’s the IP address you gave your Redmine server). You should now see the application welcome page. 
241
242
*Log in:*
243
244
1.Use default administrator account to log in:
245
Login : admin
246
Password : admin
247
248
2.You can go to Admin & Settings to modify application settings.
249
250
*Setting Up Static IP:*
251
252
1.A more easy method for configuring a static IP address is to use your local DHCP server to assign a permanent IP to the VirtualBox OS mac address. That way you will not have to do anything inside VBS. Consult your network administrator. 
253
254
2.Or you should learn configuration parameters as given below, and can configure your system to get static IP address:
255
The desired IP address
256
Network mask and broadcast address
257
Gateway address
258
Your local DNS server address(es)
259
260
*Assigning Host Name and Domain for VirtualBox OS:*
261
262
1.A more easy method for adding your IP address - Host name pair configurations to your DNS server . Consult your network administrator.
263
264 2 Sam Wilson
h2. Configuring the Passenger Apache module
265 1 Umit Uzun
266 2 Sam Wilson
Passenger is a module for apache2 that allow apache to run ruby on rails applications.  Install it thus:
267
268
>$ sudo gem install passenger
269
270
Then go to the passenger apache2 module installation directory and run @passenger-install-apache2-module@
271
272
> $ cd /var/lib/gems/1.X/gems/passenger-X.X.X/
273
274
> $ sudo bin/passenger-install-apache2-module
275
276
Next, configure Apache:
277
278
In /etc/apache2/mods-available/passenger.load we will add next line
279
280
> LoadModule passenger_module /var/lib/gems/1.X/gems/passenger-X.X.X/ext/apache2/mod_passenger.so
281
282
We have to edit the conf of the passenger apache2 module in /etc/apache2/mods-available/passenger.conf
283
284
> PassengerRoot /var/lib/gems/1.X/gems/passenger-X.X.X
285
> PassengerRuby /usr/bin/ruby1.X
286
287
And now we active the module
288
289
> $ sudo a2enmod passenger
290
291
Apache virtualhost for redmine web app
292
293
<pre>
294
    <VirtualHost *:80>
295
        ServerName redmine.server.com
296
297
        DocumentRoot /var/www/redmine/public
298
299
        ServerAdmin user@server.com
300
        LogLevel warn
301
        ErrorLog /var/log/apache2/redmine_error
302
        CustomLog /var/log/apache2/redmine_access combined
303
304
        <Directory /var/www/redmine/public>
305
            Options Indexes FollowSymLinks MultiViews
306
            AllowOverride None
307
            Order allow,deny
308
            allow from all
309
        </Directory>
310
    </VirtualHost>
311
</pre>
312
313
subversion server config in apache
314
315
<pre>
316
    <VirtualHost *:80>
317
	ServerName svn.server.com
318
	ServerAdmin user@server.com
319
	ErrorLog /var/log/apache2/svn_error
320
       	CustomLog /var/log/apache2/svn_access combined
321
        <Location /project>
322
           DAV svn
323
           SVNPath /var/lib/svn/project
324
325
           AuthType Basic
326
           AuthName "Trac system for Server projects"
327
           AuthUserFile "/var/lib/svn/.htpasswd"
328
           Require valid-user 
329
	   <LimitExcept GET PROPFIND OPTIONS REPORT>
330
               Require valid-user
331
           </LimitExcept>
332
       </Location>
333
    </Virtualhost>
334
</pre>
335
336
h2. Sendmail Server Configuration:
337
338 1 Umit Uzun
1.Before configure the email support of Redmine, we should download sendmail application for Ubuntu, issue:
339
> sudo apt-get install sendmail
340
> sudo sendmailconfig (Answer Yes to all questions which will be asked you)
341
342
2.It’s time to configure the server connection. Copy “config/email.yml.example” to “config/email.yml” and edit this file in order to configure your database settings for “production” environment. You’ll find the “email.yml.example” issue:
343
> sudo cd /opt/redmine/redmine-0.8.6/config
344
345
3.So now, assuming you’re in the “/config” directory, issue:
346
> sudo cp email.yml.example email.yml 
347
348
4.Then, open the “email.yml” file, issue:
349
> sudo gedit email.yml
350
… and edit it as in the example for sendmail configuration below:
351
352
production:
353
delivery_method: :sendmail
354
sendmail_settings:
355
location: /usr/sbin/sendmail
356
arguments: -i -t
357
address: smtp.example.net
358
port: 25
359
domain: example.net
360
authentication: :none
361
user_name: redmine@example.net
362
password: redmine
363
364
Then save “email.yml” file and exit to the command prompt.
365
366
5.It’s time to configure the “environmet.rb” configuration. Open up the “environment.rb” and change “config.action_mailer.perform_deliveries = false” to “config.action_mailer.perform_deliveries = true” then save and close the “environment.rb”.
367
368
*Subversion Installation and Configuration:*
369
370
1.Before configure the subversion support of Redmine, we should download subversion application for Ubuntu, issue:
371
> sudo apt-get install subversion
372
373
2.If your Redmine can't find the “subversion” command you can help to find by issuing:
374
· > sudo cd /opt/redmine/redmine-0.8.6/config
375
· > sudo gedit environment.rb
376
· Add ENV['PATH'] = "#{ENV['PATH']}:/subversion/path" line in it.
377
· Save and close the “environment.rb”
378
379
*Start Application Boot Time:*
380
381
1.To automatically start the application on booting your server you need to modify your “crontab”, issue:
382
> export EDITOR=gedit
383
> crontab -e
384
385
2.Your “crontab” file will be presented. This is the list of programs that start at certain times or at boot. Add the following to the “crontab” (all on one line):
386
@reboot cd /opt/redmine/redmine-0.8.6 ; rm -f log/mongrel.pid ; mongrel_rails start -e production -p 3000 -d
387
388
*Backup:*
389
390
1.Running backups is always a good idea. Redmine backups should include:
391
data (stored in your redmine database) 
392
/usr/bin/mysqldump -u -p | gzip > /path/to/redmine/backup/db/redmine_`date +%y_%m_%d`.gz
393
attachments (stored in the files directory of your Redmine install)
394
rsync -a /path/to/redmine/files /path/to/redmine/backup/files
395
396
2.Or you can use bash shell to automate kind of this operation issue:
397
> sudo cd /opt/redmine/redmine-0.8.6
398
> sudo mkdir backup
399
> sudo mkdir backup/db
400
> sudo mkdir backup/files
401
> sudo gedit backup/runRedmineBackup.bash
402
403
And after opened gedit with “runRedmineBackup.bash” write all commands below:
404
405
#!/bin/bash
406
data=`date -I`
407
mysqldump --user=root --password="redmine" --all-databases | gzip > db/backup-$data.sql.gz
408
cd db
409
ftp -i -n << EOF
410
open ftpserver.example.net
411
user username password
412
bin
413
mput backup-$data.sql.gz
414
bye
415
EOF
416
417
Then save “runRedmineBackup.bash” file and exit to the command prompt. After creation of  runRedmineBackup.bash you can add this bash to run continually between specified periods. Issue:
418
419
> export EDITOR=gedit
420
> crontab -e
421
Add 0 0 * * 0 cd /opt/redmine/redmine-0.8.6/backup ; sh runRedmineBackup.bash commands to crontab to backup database weekly.
422
	
423
To work this bush without any permission problem you have to change all of them modes to maxium permission issue:
424
425
> sudo chmod -R 777 backup
426
> sudo chown -R redmine:redmine backup
427
428
That's all. Now we completely installed Redmine our virtual Ubuntu OS and can reach from any machine at our network easily. Congratulations..!
429
430 2 Sam Wilson
h2. Sources & contributors.
431
432
* Ümit Uzun 06/11/2009.
433
* Some of the above material comes from Macada's wiki, licenced under the GNU Free Documentation License 1.2.  See "Redmine in Ubuntu Jaunty 9.04":http://wiki.ousli.org/index.php/Redmine_in_Ubuntu_Jaunty_9.04 by David 'macada', last modified 2010-02-08, accessed 2010-05-26.
434
* Sam Wilson 2010-05-26, formatting changes.