Project

General

Profile

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

Dimitry Profus, 2011-09-18 05:34

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 5 Dimitry Profus
$ sudo apt-get install build-essential llibmysqlclient15-dev ibdigest-sha1-perl libgemplugin-ruby libgemplugin-ruby1.8 libruby-extras libruby1.8-extras rails rake ruby rubygems rubygems1.8 ruby1.8-dev subversion 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
</pre>
35
# Copy config/database.yml.example to config/database.yml and edit this file in order to configure your database settings for "production" environment.
36
<pre>
37 5 Dimitry Profus
$ sudo cp /usr/share/redmine/config/database.yml.example /usr/share/redmine/config/database.yml
38 1 Dimitry Profus
39 5 Dimitry Profus
$ sudo nano /usr/share/redmine/config/database.yml
40 1 Dimitry Profus
41
Modify to the following and save (ctrl+x)
42
43
production:
44
  adapter: mysql
45
  socket: /var/run/mysqld/mysqld.sock
46
  database: redmine
47
  host: localhost
48
  username: redmine
49
  password: [password]
50 5 Dimitry Profus
  encoding: utf8
51 1 Dimitry Profus
</pre>
52 5 Dimitry Profus
# Generate a session store secret.
53
<pre>
54 6 Dimitry Profus
$ cd /usr/share/redmine
55
56 5 Dimitry Profus
$ sudo rake generate_session_store
57
</pre>
58 1 Dimitry Profus
# Create the database structure, by running the following command under the application root directory:
59
<pre>
60 5 Dimitry Profus
$ cd /usr/share/redmine
61 1 Dimitry Profus
62
$ sudo rake db:migrate RAILS_ENV="production" 
63
</pre>
64
# Insert default configuration data in database, by running the following command:
65
<pre>
66
$ sudo RAILS_ENV=production rake redmine:load_default_data
67
</pre>
68
# Setting up permissions
69
<pre>
70 5 Dimitry Profus
$ cd /usr/share/redmine
71 1 Dimitry Profus
$ sudo mkdir tmp public/plugin_assets
72
$ 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
$ sudo apt-get install libapache2-mod-passenger libapache-dbi-perl libapache2-mod-perl2 libapache2-svn
92
</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
$ sudo apt-get install mercurial  
186
</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
# Create the Mercurial config file
227
<pre>
228
$ sudo nano /etc/apache2/conf.d/hg.config
229
230
Add the following and save
231
 
232
    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
239
        #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
</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 a2enmod perl
255
$ sudo /etc/init.d/apache2 restart
256
</pre>
257 8 Dimitry Profus
# Create a new test repository and project in Redmine
258 1 Dimitry Profus
<pre>
259
$ sudo hg init /var/www/hg/repos/test
260 8 Dimitry Profus
$ sudo chown -R www-data:www-data /var/www/hg/repos/test
261
262
Create a new project with and identifier 'test'
263
264
In the project Settings > Repository set
265
SCM: Mercurial
266
Path to repository: /var/www/hg/repos/test
267
Press the 'Create' button
268
269
Goto to the Repository tab of the test project
270 1 Dimitry Profus
</pre>
271
# View the test repository in the web browser 
272
<pre>
273
> http://[my site name]/hg/test
274
</pre>
275
276 10 Dimitry Profus
h2. Email Integration
277 1 Dimitry Profus
278
# Install and configure Sendmail
279
<pre>
280
$ sudo apt-get install sendmail
281
$ sudo sendmailconfig
282
283
(Answer Yes to all questions which you will be asked)
284
</pre>
285
# Update the Redmine configuration file
286
<pre>
287 5 Dimitry Profus
$ sudo nano /usr/share/redmine/config/configuration.yml
288 1 Dimitry Profus
289
Add the following text and save
290
291
 production:
292
   email_delivery:
293
     delivery_method: :sendmail
294
</pre>