Project

General

Profile

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

Dimitry Profus, 2011-09-18 05:03

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 7 Dimitry Profus
$ sudo apt-get install python-software-properties
172 1 Dimitry Profus
$ sudo add-apt-repository ppa:mercurial-ppa/releases
173
$ sudo apt-get update
174
$ sudo apt-get install mercurial  
175
</pre>
176
# Create the hg web directory
177
<pre>
178
$ sudo mkdir -p /var/www/hg/repos
179
</pre>
180
# Create the web cgi script file
181
<pre>
182
$ sudo nano /var/www/hg/hgwebdir.cgi
183
184
Add the following and save
185
186
#!/usr/bin/env python
187
#
188
from mercurial import demandimport; demandimport.enable()
189
from mercurial.hgweb.hgwebdir_mod import hgwebdir
190
import mercurial.hgweb.wsgicgi as wsgicgi
191
application = hgwebdir('hgweb.config')
192
wsgicgi.launch(application)
193
</pre>
194
# Create the cgi web config file 
195
<pre>
196
$ sudo nano /var/www/hg/hgweb.config
197
198
Add the following and save
199
200
	[paths]
201
	/=/var/www/hg/repos/**
202
203
	[web]
204
	allow_push = *
205
	push_ssl = false
206
	allowbz2 = yes
207
	allowgz = yes
208
	allowzip = yes
209
</pre>
210
# Setup permissions
211
<pre>
212
$ sudo chown -R www-data:www-data /var/www/hg
213
$ sudo chmod gu+x /var/www/hg/hgwebdir.cgi
214
</pre>
215
# Create the Mercurial config file
216
<pre>
217
$ sudo nano /etc/apache2/conf.d/hg.config
218
219
Add the following and save
220
 
221
    PerlLoadModule Apache::Redmine
222
    ScriptAlias /hg  "/var/www/hg/hgwebdir.cgi"
223
    <Location /hg  >
224
        AuthType Basic
225
        AuthName "Mercurial" 
226
        Require valid-user
227
228
        #Redmine auth
229
        PerlAccessHandler Apache::Authn::Redmine::access_handler
230
        PerlAuthenHandler Apache::Authn::Redmine::authen_handler
231
        RedmineDSN "DBI:mysql:database=redmine;host=localhost" 
232
        RedmineDbUser "redmine" 
233
        RedmineDbPass "password" 
234
    </Location>
235
</pre>
236
# Add a symbolic link to Redmine.pm
237
<pre>
238 5 Dimitry Profus
$ sudo ln -s /usr/share/redmine/extra/svn/Redmine.pm /usr/lib/perl5/Apache/Redmine.pm
239
$ sudo ln -s /usr/share/redmine/extra/svn/Redmine.pm /usr/lib/perl5/Apache2/Redmine.pm  
240 1 Dimitry Profus
</pre>
241
# Enable the required Apache modules and restart Apache
242
<pre>
243
$ sudo a2enmod perl
244 2 Dimitry Profus
$ sudo /etc/init.d/apache2 restart
245 1 Dimitry Profus
</pre>
246
# Create a new test repository
247
<pre>
248
$ sudo hg init /var/www/hg/repos/test
249
$ sudo chown -R www-data:www-data /var/www/hg/repos/test 
250
</pre>
251
# View the test repository in the web browser 
252
<pre>
253
> http://[my site name]/hg/test
254
</pre>
255
256
h2. Email Setup
257
258
# Install and configure Sendmail
259
<pre>
260
$ sudo apt-get install sendmail
261
$ sudo sendmailconfig
262
263
(Answer Yes to all questions which you will be asked)
264
</pre>
265
# Update the Redmine configuration file
266
<pre>
267 5 Dimitry Profus
$ sudo nano /usr/share/redmine/config/configuration.yml
268 1 Dimitry Profus
269
Add the following text and save
270
271
 production:
272
   email_delivery:
273
     delivery_method: :sendmail
274
</pre>