Project

General

Profile

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

Dimitry Profus, 2011-09-18 01:47

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