Project

General

Profile

HowTo Install Redmine 12x + Mercurial on Ubuntu lucid server » History » Version 21

Dimitry Profus, 2011-09-18 09:51

1 1 Dimitry Profus
h1. How to install Redmine on Ubuntu lucid server
2
3
{{toc}}
4
5 10 Dimitry Profus
h2. Redmine Installation
6 1 Dimitry Profus
7
# Install the LAMP stack
8
<pre>
9
$ sudo tasksel install lamp-server
10
</pre>
11
# Install the required packages
12
<pre>
13 20 Dimitry Profus
$ sudo apt-get install build-essential subversion llibmysqlclient15-dev libdigest-sha1-perl libgemplugin-ruby libgemplugin-ruby1.8 libruby-extras libruby1.8-extras rails rake ruby rubygems rubygems1.8 ruby1.8-dev libopenssl-ruby1.8 
14 1 Dimitry Profus
</pre>
15
# Install the required Ruby gems
16
<pre>
17
$ sudo gem install rails -v=2.3.11 --no-ri --no-rdoc
18 4 Dimitry Profus
$ sudo gem install rake -v=0.8.7 --no-ri --no-rdoc
19 5 Dimitry Profus
$ sudo gem uninstall rake -v=0.9.2 
20 4 Dimitry Profus
$ sudo gem install i18n -v=0.4.2 --no-ri --no-rdoc
21
$ sudo gem install mysql --no-ri --no-rdoc
22 1 Dimitry Profus
</pre> 
23 5 Dimitry Profus
# Download Redmine into /user/share/redmine directory
24 1 Dimitry Profus
<pre>
25 5 Dimitry Profus
$ sudo svn co http://redmine.rubyforge.org/svn/branches/1.2-stable /usr/share/redmine
26 1 Dimitry Profus
</pre>
27
# Create an empty MySQL database and accompanying user named redmine for example.
28
<pre>
29 5 Dimitry Profus
$ mysql -u root -p
30
(enter the mysql root user password)
31 1 Dimitry Profus
> create database redmine character set utf8;
32
> create user 'redmine'@'localhost' identified by '[password]';
33
> grant all privileges on redmine.* to 'redmine'@'localhost' identified by '[password]';
34 14 Dimitry Profus
> exit
35 1 Dimitry Profus
</pre>
36
# Copy config/database.yml.example to config/database.yml and edit this file in order to configure your database settings for "production" environment.
37
<pre>
38 5 Dimitry Profus
$ sudo cp /usr/share/redmine/config/database.yml.example /usr/share/redmine/config/database.yml
39 1 Dimitry Profus
40 5 Dimitry Profus
$ sudo nano /usr/share/redmine/config/database.yml
41 1 Dimitry Profus
42
Modify to the following and save (ctrl+x)
43
44
production:
45
  adapter: mysql
46
  socket: /var/run/mysqld/mysqld.sock
47
  database: redmine
48
  host: localhost
49
  username: redmine
50
  password: [password]
51 5 Dimitry Profus
  encoding: utf8
52 1 Dimitry Profus
</pre>
53 5 Dimitry Profus
# Generate a session store secret.
54
<pre>
55 6 Dimitry Profus
$ cd /usr/share/redmine
56
57 5 Dimitry Profus
$ sudo rake generate_session_store
58
</pre>
59 1 Dimitry Profus
# Create the database structure, by running the following command under the application root directory:
60
<pre>
61 5 Dimitry Profus
$ cd /usr/share/redmine
62 1 Dimitry Profus
63
$ sudo rake db:migrate RAILS_ENV="production" 
64
</pre>
65
# Insert default configuration data in database, by running the following command:
66
<pre>
67
$ sudo RAILS_ENV=production rake redmine:load_default_data
68
</pre>
69
# Setting up permissions
70
<pre>
71 5 Dimitry Profus
$ cd /usr/share/redmine
72 1 Dimitry Profus
$ sudo chown -R www-data:www-data files log tmp public/plugin_assets
73
$ sudo chmod -R 755 files log tmp public/plugin_assets
74
</pre>
75 9 Dimitry Profus
# Test using the webrick web server
76
<pre>
77
$ cd /usr/share/redmine
78
79
$ ruby script/server webrick -e production
80
81
Point your web browser at http://[my server ip]:3000
82
83
You should now see the application welcome page.
84
</pre>
85
86 1 Dimitry Profus
87 5 Dimitry Profus
h2. Apache Integration
88 1 Dimitry Profus
89
# Install the required packages
90
<pre>
91 18 Dimitry Profus
$ sudo apt-get install libapache2-mod-passenger
92 1 Dimitry Profus
</pre>
93
# Add a symbolic link to the public redmine web directory
94
<pre>
95
$ sudo ln -s /usr/share/redmine/public /var/www/redmine
96
</pre>
97
# Configure Passanger to run as www-data
98
<pre>
99
$ sudo nano /etc/apache2/mods-available/passenger.conf
100
101
Add the follow line and save (ctrl+x)
102
103
PassengerDefaultUser www-data
104
</pre>
105
# Create a new Apache site file
106
<pre> 
107
$ sudo nano /etc/apache2/sites-available/redmine 
108
</pre>
109
Add the following lines and save (ctrl+x)
110
<pre>
111
<VirtualHost *:80>
112
        ServerAdmin webmaster@localhost
113
        DocumentRoot /var/www
114
        ServerName myservername
115
        
116
        RewriteEngine on
117
        RewriteRule   ^/$  /redmine  [R]
118
119
        <Directory /var/www/redmine>
120
                RailsBaseURI /redmine
121
                PassengerResolveSymlinksInDocumentRoot on
122
        </Directory>
123
124
        ErrorLog /var/log/apache2/error.log
125
126
        # Possible values include: debug, info, notice, warn, error, crit,
127
        # alert, emerg.
128
        LogLevel warn
129
130
        CustomLog /var/log/apache2/access.log combined
131
</VirtualHost>
132
</pre>
133
For SSL add the following text instead
134
<pre>
135
<VirtualHost *:443>
136
        ServerAdmin webmaster@localhost
137
        DocumentRoot /var/www
138
        ServerName myservername
139
140
        SSLEngine On
141
        SSLCertificateFile /etc/apache2/ssl/redmine.pem
142
143
        RewriteEngine on
144
        RewriteRule   ^/$  /redmine  [R]
145
146
        <Directory /var/www/redmine>
147
                RailsBaseURI /redmine
148
                PassengerResolveSymlinksInDocumentRoot on
149
        </Directory>
150
151
        ErrorLog /var/log/apache2/error.log
152
153
        # Possible values include: debug, info, notice, warn, error, crit,
154
        # alert, emerg.
155
        LogLevel warn
156
157
        CustomLog /var/log/apache2/access.log combined
158
</VirtualHost>
159
</pre>
160
# Enable the Redmine website
161
<pre>
162
$ sudo a2dissite default
163
$ sudo a2ensite redmine
164
</pre> 
165
# Enable the Passenger and Rewite modules and restart Apache
166
<pre> 
167
$ sudo a2enmod passenger
168
$ sudo a2enmod rewrite
169
$ sudo /etc/init.d/apache2 restart
170 3 Dimitry Profus
</pre> 
171
# Test the setup
172
<pre>
173
Open up your favorite web browser and goto
174
175
http://[my site or ip]/redmine
176
</pre>
177 1 Dimitry Profus
178 5 Dimitry Profus
h2. Mercurial Integration
179 1 Dimitry Profus
180
# Install the latest Mercurial release 
181
<pre>
182 7 Dimitry Profus
$ sudo apt-get install python-software-properties
183 1 Dimitry Profus
$ sudo add-apt-repository ppa:mercurial-ppa/releases
184
$ sudo apt-get update
185 18 Dimitry Profus
$ sudo apt-get install mercurial libapache-dbi-perl libapache2-mod-perl2
186 1 Dimitry Profus
</pre>
187
# Create the hg web directory
188
<pre>
189
$ sudo mkdir -p /var/www/hg/repos
190
</pre>
191
# Create the web cgi script file
192
<pre>
193
$ sudo nano /var/www/hg/hgwebdir.cgi
194
195
Add the following and save
196
197
#!/usr/bin/env python
198
#
199
from mercurial import demandimport; demandimport.enable()
200
from mercurial.hgweb.hgwebdir_mod import hgwebdir
201
import mercurial.hgweb.wsgicgi as wsgicgi
202
application = hgwebdir('hgweb.config')
203
wsgicgi.launch(application)
204
</pre>
205
# Create the cgi web config file 
206
<pre>
207
$ sudo nano /var/www/hg/hgweb.config
208
209
Add the following and save
210
211 8 Dimitry Profus
[paths]
212
/=/var/www/hg/repos/**
213 1 Dimitry Profus
214 8 Dimitry Profus
[web]
215
allow_push = *
216
push_ssl = false
217
allowbz2 = yes
218
allowgz = yes
219
allowzip = yes
220 1 Dimitry Profus
</pre>
221
# Setup permissions
222
<pre>
223
$ sudo chown -R www-data:www-data /var/www/hg
224
$ sudo chmod gu+x /var/www/hg/hgwebdir.cgi
225
</pre>
226 12 Dimitry Profus
# Create a Apache config file
227 1 Dimitry Profus
<pre>
228
$ sudo nano /etc/apache2/conf.d/hg.config
229
230
Add the following and save
231
 
232 11 Dimitry Profus
PerlLoadModule Apache::Redmine
233
ScriptAlias /hg  "/var/www/hg/hgwebdir.cgi"
234
<Location /hg  >
235
	AuthType Basic
236
	AuthName "Mercurial" 
237
	Require valid-user
238 1 Dimitry Profus
239 11 Dimitry Profus
	#Redmine auth
240
	PerlAccessHandler Apache::Authn::Redmine::access_handler
241
	PerlAuthenHandler Apache::Authn::Redmine::authen_handler
242
	RedmineDSN "DBI:mysql:database=redmine;host=localhost" 
243
	RedmineDbUser "redmine" 
244
	RedmineDbPass "password" 
245
</Location>
246 1 Dimitry Profus
</pre>
247
# Add a symbolic link to Redmine.pm
248
<pre>
249 5 Dimitry Profus
$ sudo ln -s /usr/share/redmine/extra/svn/Redmine.pm /usr/lib/perl5/Apache/Redmine.pm
250
$ sudo ln -s /usr/share/redmine/extra/svn/Redmine.pm /usr/lib/perl5/Apache2/Redmine.pm  
251 1 Dimitry Profus
</pre>
252
# Enable the required Apache modules and restart Apache
253
<pre>
254
$ sudo /etc/init.d/apache2 restart
255
</pre>
256 8 Dimitry Profus
# Create a new test repository and project in Redmine
257 1 Dimitry Profus
<pre>
258
$ sudo hg init /var/www/hg/repos/test
259 8 Dimitry Profus
$ sudo chown -R www-data:www-data /var/www/hg/repos/test
260
261
Create a new project with and identifier 'test'
262
263
In the project Settings > Repository set
264
SCM: Mercurial
265
Path to repository: /var/www/hg/repos/test
266
Press the 'Create' button
267
268
Goto to the Repository tab of the test project
269 1 Dimitry Profus
</pre>
270
# View the test repository in the web browser 
271
<pre>
272
> http://[my site name]/hg/test
273
</pre>
274
275 15 Dimitry Profus
h2. Subversion Integration
276
277
# Install the latest Mercurial release 
278
<pre>
279 18 Dimitry Profus
$ sudo apt-get install subversion libapache2-svn libapache-dbi-perl libapache2-mod-perl2
280 15 Dimitry Profus
</pre>
281
# Create the svn repository directory
282
<pre>
283
$ sudo mkdir /var/www/svn
284
</pre>
285
# Setup permissions
286
<pre>
287
$ sudo chown -R www-data:www-data /var/www/svn
288
</pre>
289
# Create a Apache config file
290
<pre>
291
$ sudo nano /etc/apache2/conf.d/svn.config
292
</pre>
293
Add the following and save
294
<pre>
295
   PerlLoadModule Apache::Redmine
296
   <Location /svn>
297
     DAV svn
298
     SVNParentPath "/var/www/svn" 
299
     Order deny,allow
300
     Deny from all
301
     Satisfy any
302
303
     PerlAccessHandler Apache::Authn::Redmine::access_handler
304
     PerlAuthenHandler Apache::Authn::Redmine::authen_handler
305
     AuthType Basic
306
     AuthName "Redmine Subversion Repository" 
307
308
     #read-only access    
309
     <Limit GET PROPFIND OPTIONS REPORT>
310
        Require valid-user
311
        Allow from 127.0.0.1
312
        # Allow from another-ip
313
         Satisfy any
314
     </Limit>
315
     # write access
316
     <LimitExcept GET PROPFIND OPTIONS REPORT>
317
       Require valid-user
318
     </LimitExcept>
319
320
     ## for mysql
321 21 Dimitry Profus
     RedmineDSN "DBI:mysql:database=redmine;host=localhost" 
322 15 Dimitry Profus
     RedmineDbUser "redmine" 
323
     RedmineDbPass "password" 
324
  </Location>
325
</pre>
326
# Enable the required Apache modules and restart Apache
327
<pre>
328
$ sudo a2enmod dav_svn
329
$ sudo /etc/init.d/apache2 restart
330
</pre>
331
# Create a new test repository
332
<pre>
333
$ sudo svn create /var/www/svn/test
334
$ sudo chown -R www-data:www-data /var/www/svn/test
335
</pre>
336
337 10 Dimitry Profus
h2. Email Integration
338 1 Dimitry Profus
339
# Install and configure Sendmail
340
<pre>
341
$ sudo apt-get install sendmail
342
$ sudo sendmailconfig
343
344
(Answer Yes to all questions which you will be asked)
345
</pre>
346
# Update the Redmine configuration file
347
<pre>
348 5 Dimitry Profus
$ sudo nano /usr/share/redmine/config/configuration.yml
349 1 Dimitry Profus
350
Add the following text and save
351
352
 production:
353
   email_delivery:
354
     delivery_method: :sendmail
355
</pre>