Project

General

Profile

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

Dimitry Profus, 2011-09-18 04:51

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