Project

General

Profile

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

Dimitry Profus, 2011-09-18 04:52

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