Project

General

Profile

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

Dimitry Profus, 2011-09-18 01:26

1 1 Dimitry Profus
h1. How to install Redmine on Ubuntu lucid server
2
3
{{toc}}
4
5
h2. Redmine Setup
6
7
# Install the LAMP stack
8
<pre>
9
$ sudo tasksel install lamp-server
10
</pre>
11
# Install the required packages
12
<pre>
13
$ sudo apt-get install libdigest-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
</pre>
15
# Install the required Ruby gems
16
<pre>
17
$ sudo gem install rails -v=2.3.11 --no-ri --no-rdoc
18
$ sudo gem install rack -v=1.1.0 --no-ri --no-rdoc
19
$ sudo gem install rake -v=0.8.7 --no-ri --no-rdoc
20
</pre> 
21
# Download Redmine into /user/shared/redmine directory
22
<pre>
23
$ sudo svn co http://redmine.rubyforge.org/svn/branches/1.2-stable /user/shared/redmine
24
</pre>
25
# Create an empty MySQL database and accompanying user named redmine for example.
26
<pre>
27
$ mysql localhost -u root -p
28
29
> create database redmine character set utf8;
30
> create user 'redmine'@'localhost' identified by '[password]';
31
> grant all privileges on redmine.* to 'redmine'@'localhost' identified by '[password]';
32
</pre>
33
# Copy config/database.yml.example to config/database.yml and edit this file in order to configure your database settings for "production" environment.
34
<pre>
35
$ sudo cp /usr/shared/redmine/config/database.yml.example /usr/shared/redmine/config/database.yml
36
37
$ sudo nano /usr/shared/redmine/config/database.yml
38
39
Modify to the following and save (ctrl+x)
40
41
production:
42
  adapter: mysql
43
  socket: /var/run/mysqld/mysqld.sock
44
  database: redmine
45
  host: localhost
46
  username: redmine
47
  password: [password]
48
</pre>
49
# Create the database structure, by running the following command under the application root directory:
50
<pre>
51
$ cd /usr/shared/redmine
52
53
$ sudo rake db:migrate RAILS_ENV="production" 
54
</pre>
55
# Insert default configuration data in database, by running the following command:
56
<pre>
57
$ sudo RAILS_ENV=production rake redmine:load_default_data
58
</pre>
59
# Setting up permissions
60
<pre>
61
$ cd /usr/shared/redmine
62
$ sudo mkdir tmp public/plugin_assets
63
$ sudo chown -R www-data:www-data files log tmp public/plugin_assets
64
$ sudo chmod -R 755 files log tmp public/plugin_assets
65
</pre>
66
67
h2. Apache Setup
68
69
# Install the required packages
70
<pre>
71
$ sudo apt-get install libapache2-mod-passenger libapache-dbi-perl libapache2-mod-perl2 libapache2-svn
72
</pre>
73
# Add a symbolic link to the public redmine web directory
74
<pre>
75
$ sudo ln -s /usr/share/redmine/public /var/www/redmine
76
</pre>
77
# Configure Passanger to run as www-data
78
<pre>
79
$ sudo nano /etc/apache2/mods-available/passenger.conf
80
81
Add the follow line and save (ctrl+x)
82
83
PassengerDefaultUser www-data
84
</pre>
85
# Create a new Apache site file
86
<pre> 
87
$ sudo nano /etc/apache2/sites-available/redmine 
88
</pre>
89
Add the following lines and save (ctrl+x)
90
<pre>
91
<VirtualHost *:80>
92
        ServerAdmin webmaster@localhost
93
        DocumentRoot /var/www
94
        ServerName myservername
95
        
96
        RewriteEngine on
97
        RewriteRule   ^/$  /redmine  [R]
98
99
        <Directory /var/www/redmine>
100
                RailsBaseURI /redmine
101
                PassengerResolveSymlinksInDocumentRoot on
102
        </Directory>
103
104
        ErrorLog /var/log/apache2/error.log
105
106
        # Possible values include: debug, info, notice, warn, error, crit,
107
        # alert, emerg.
108
        LogLevel warn
109
110
        CustomLog /var/log/apache2/access.log combined
111
</VirtualHost>
112
</pre>
113
For SSL add the following text instead
114
<pre>
115
<VirtualHost *:443>
116
        ServerAdmin webmaster@localhost
117
        DocumentRoot /var/www
118
        ServerName myservername
119
120
        SSLEngine On
121
        SSLCertificateFile /etc/apache2/ssl/redmine.pem
122
123
        RewriteEngine on
124
        RewriteRule   ^/$  /redmine  [R]
125
126
        <Directory /var/www/redmine>
127
                RailsBaseURI /redmine
128
                PassengerResolveSymlinksInDocumentRoot on
129
        </Directory>
130
131
        ErrorLog /var/log/apache2/error.log
132
133
        # Possible values include: debug, info, notice, warn, error, crit,
134
        # alert, emerg.
135
        LogLevel warn
136
137
        CustomLog /var/log/apache2/access.log combined
138
</VirtualHost>
139
</pre>
140
# Enable the Redmine website
141
<pre>
142
$ sudo a2dissite default
143
$ sudo a2ensite redmine
144
</pre> 
145
# Enable the Passenger and Rewite modules and restart Apache
146
<pre> 
147
$ sudo a2enmod passenger
148
$ sudo a2enmod rewrite
149
$ sudo /etc/init.d/apache2 restart
150
</pre> 
151 3 Dimitry Profus
# Test the setup
152
<pre>
153
Open up your favorite web browser and goto
154
155
http://[my site or ip]/redmine
156
</pre>
157
158 1 Dimitry Profus
159
h2. Mercurial Setup
160
161
# Install the latest Mercurial release 
162
<pre>
163
$ sudo add-apt-repository ppa:mercurial-ppa/releases
164
$ sudo apt-get update
165
$ sudo apt-get install mercurial  
166
</pre>
167
# Create the hg web directory
168
<pre>
169
$ sudo mkdir -p /var/www/hg/repos
170
</pre>
171
# Create the web cgi script file
172
<pre>
173
$ sudo nano /var/www/hg/hgwebdir.cgi
174
175
Add the following and save
176
177
#!/usr/bin/env python
178
#
179
from mercurial import demandimport; demandimport.enable()
180
from mercurial.hgweb.hgwebdir_mod import hgwebdir
181
import mercurial.hgweb.wsgicgi as wsgicgi
182
application = hgwebdir('hgweb.config')
183
wsgicgi.launch(application)
184
</pre>
185
# Create the cgi web config file 
186
<pre>
187
$ sudo nano /var/www/hg/hgweb.config
188
189
Add the following and save
190
191
	[paths]
192
	/=/var/www/hg/repos/**
193
194
	[web]
195
	allow_push = *
196
	push_ssl = false
197
	allowbz2 = yes
198
	allowgz = yes
199
	allowzip = yes
200
</pre>
201
# Setup permissions
202
<pre>
203
$ sudo chown -R www-data:www-data /var/www/hg
204
$ sudo chmod gu+x /var/www/hg/hgwebdir.cgi
205
</pre>
206
# Create the Mercurial config file
207
<pre>
208
$ sudo nano /etc/apache2/conf.d/hg.config
209
210
Add the following and save
211
 
212
    PerlLoadModule Apache::Redmine
213
    ScriptAlias /hg  "/var/www/hg/hgwebdir.cgi"
214
    <Location /hg  >
215
        AuthType Basic
216
        AuthName "Mercurial" 
217
        Require valid-user
218
219
        #Redmine auth
220
        PerlAccessHandler Apache::Authn::Redmine::access_handler
221
        PerlAuthenHandler Apache::Authn::Redmine::authen_handler
222
        RedmineDSN "DBI:mysql:database=redmine;host=localhost" 
223
        RedmineDbUser "redmine" 
224
        RedmineDbPass "password" 
225
    </Location>
226
</pre>
227
# Add a symbolic link to Redmine.pm
228
<pre>
229
$ sudo ln -s /usr/shared/redmine/extra/svn/Redmine.pm /usr/lib/perl5/Apache/Redmine.pm
230
$ sudo ln -s /usr/shared/redmine/extra/svn/Redmine.pm /usr/lib/perl5/Apache2/Redmine.pm  
231
</pre>
232
# Enable the required Apache modules and restart Apache
233
<pre>
234
$ sudo a2enmod perl
235 2 Dimitry Profus
$ sudo /etc/init.d/apache2 restart
236 1 Dimitry Profus
</pre>
237
# Create a new test repository
238
<pre>
239
$ sudo hg init /var/www/hg/repos/test
240
$ sudo chown -R www-data:www-data /var/www/hg/repos/test 
241
</pre>
242
# View the test repository in the web browser 
243
<pre>
244
> http://[my site name]/hg/test
245
</pre>
246
247
h2. Email Setup
248
249
# Install and configure Sendmail
250
<pre>
251
$ sudo apt-get install sendmail
252
$ sudo sendmailconfig
253
254
(Answer Yes to all questions which you will be asked)
255
</pre>
256
# Update the Redmine configuration file
257
<pre>
258
$ sudo nano /usr/shared/redmine/config/configuration.yml
259
260
Add the following text and save
261
262
 production:
263
   email_delivery:
264
     delivery_method: :sendmail
265
</pre>