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

Dimitry Profus, 2011-09-18 09:47

1 1 Dimitry Profus
h1. How to install Redmine on Ubuntu lucid server
2 1 Dimitry Profus
3 1 Dimitry Profus
{{toc}}
4 1 Dimitry Profus
5 10 Dimitry Profus
h2. Redmine Installation
6 1 Dimitry Profus
7 1 Dimitry Profus
# Install the LAMP stack
8 1 Dimitry Profus
<pre>
9 1 Dimitry Profus
$ sudo tasksel install lamp-server
10 1 Dimitry Profus
</pre>
11 1 Dimitry Profus
# Install the required packages
12 1 Dimitry Profus
<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 1 Dimitry Profus
# Install the required Ruby gems
16 1 Dimitry Profus
<pre>
17 1 Dimitry Profus
$ 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 4 Dimitry Profus
$ 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 1 Dimitry Profus
# Create an empty MySQL database and accompanying user named redmine for example.
28 1 Dimitry Profus
<pre>
29 5 Dimitry Profus
$ mysql -u root -p
30 5 Dimitry Profus
(enter the mysql root user password)
31 1 Dimitry Profus
> create database redmine character set utf8;
32 1 Dimitry Profus
> create user 'redmine'@'localhost' identified by '[password]';
33 1 Dimitry Profus
> grant all privileges on redmine.* to 'redmine'@'localhost' identified by '[password]';
34 14 Dimitry Profus
> exit
35 1 Dimitry Profus
</pre>
36 1 Dimitry Profus
# Copy config/database.yml.example to config/database.yml and edit this file in order to configure your database settings for "production" environment.
37 1 Dimitry Profus
<pre>
38 5 Dimitry Profus
$ sudo cp /usr/share/redmine/config/database.yml.example /usr/share/redmine/config/database.yml
39 1 Dimitry Profus
40 5 Dimitry Profus
$ sudo nano /usr/share/redmine/config/database.yml
41 1 Dimitry Profus
42 1 Dimitry Profus
Modify to the following and save (ctrl+x)
43 1 Dimitry Profus
44 1 Dimitry Profus
production:
45 1 Dimitry Profus
  adapter: mysql
46 1 Dimitry Profus
  socket: /var/run/mysqld/mysqld.sock
47 1 Dimitry Profus
  database: redmine
48 1 Dimitry Profus
  host: localhost
49 1 Dimitry Profus
  username: redmine
50 1 Dimitry Profus
  password: [password]
51 5 Dimitry Profus
  encoding: utf8
52 1 Dimitry Profus
</pre>
53 5 Dimitry Profus
# Generate a session store secret.
54 5 Dimitry Profus
<pre>
55 6 Dimitry Profus
$ cd /usr/share/redmine
56 6 Dimitry Profus
57 5 Dimitry Profus
$ sudo rake generate_session_store
58 5 Dimitry Profus
</pre>
59 1 Dimitry Profus
# Create the database structure, by running the following command under the application root directory:
60 1 Dimitry Profus
<pre>
61 5 Dimitry Profus
$ cd /usr/share/redmine
62 1 Dimitry Profus
63 1 Dimitry Profus
$ sudo rake db:migrate RAILS_ENV="production" 
64 1 Dimitry Profus
</pre>
65 1 Dimitry Profus
# Insert default configuration data in database, by running the following command:
66 1 Dimitry Profus
<pre>
67 1 Dimitry Profus
$ sudo RAILS_ENV=production rake redmine:load_default_data
68 1 Dimitry Profus
</pre>
69 1 Dimitry Profus
# Setting up permissions
70 1 Dimitry Profus
<pre>
71 5 Dimitry Profus
$ cd /usr/share/redmine
72 1 Dimitry Profus
$ sudo chown -R www-data:www-data files log tmp public/plugin_assets
73 1 Dimitry Profus
$ sudo chmod -R 755 files log tmp public/plugin_assets
74 1 Dimitry Profus
</pre>
75 9 Dimitry Profus
# Test using the webrick web server
76 9 Dimitry Profus
<pre>
77 9 Dimitry Profus
$ cd /usr/share/redmine
78 9 Dimitry Profus
79 9 Dimitry Profus
$ ruby script/server webrick -e production
80 9 Dimitry Profus
81 9 Dimitry Profus
Point your web browser at http://[my server ip]:3000
82 9 Dimitry Profus
83 9 Dimitry Profus
You should now see the application welcome page.
84 9 Dimitry Profus
</pre>
85 9 Dimitry Profus
86 1 Dimitry Profus
87 5 Dimitry Profus
h2. Apache Integration
88 1 Dimitry Profus
89 1 Dimitry Profus
# Install the required packages
90 1 Dimitry Profus
<pre>
91 18 Dimitry Profus
$ sudo apt-get install libapache2-mod-passenger
92 1 Dimitry Profus
</pre>
93 1 Dimitry Profus
# Add a symbolic link to the public redmine web directory
94 1 Dimitry Profus
<pre>
95 1 Dimitry Profus
$ sudo ln -s /usr/share/redmine/public /var/www/redmine
96 1 Dimitry Profus
</pre>
97 1 Dimitry Profus
# Configure Passanger to run as www-data
98 1 Dimitry Profus
<pre>
99 1 Dimitry Profus
$ sudo nano /etc/apache2/mods-available/passenger.conf
100 1 Dimitry Profus
101 1 Dimitry Profus
Add the follow line and save (ctrl+x)
102 1 Dimitry Profus
103 1 Dimitry Profus
PassengerDefaultUser www-data
104 1 Dimitry Profus
</pre>
105 1 Dimitry Profus
# Create a new Apache site file
106 1 Dimitry Profus
<pre> 
107 1 Dimitry Profus
$ sudo nano /etc/apache2/sites-available/redmine 
108 1 Dimitry Profus
</pre>
109 1 Dimitry Profus
Add the following lines and save (ctrl+x)
110 1 Dimitry Profus
<pre>
111 1 Dimitry Profus
<VirtualHost *:80>
112 1 Dimitry Profus
        ServerAdmin webmaster@localhost
113 1 Dimitry Profus
        DocumentRoot /var/www
114 1 Dimitry Profus
        ServerName myservername
115 1 Dimitry Profus
        
116 1 Dimitry Profus
        RewriteEngine on
117 1 Dimitry Profus
        RewriteRule   ^/$  /redmine  [R]
118 1 Dimitry Profus
119 1 Dimitry Profus
        <Directory /var/www/redmine>
120 1 Dimitry Profus
                RailsBaseURI /redmine
121 1 Dimitry Profus
                PassengerResolveSymlinksInDocumentRoot on
122 1 Dimitry Profus
        </Directory>
123 1 Dimitry Profus
124 1 Dimitry Profus
        ErrorLog /var/log/apache2/error.log
125 1 Dimitry Profus
126 1 Dimitry Profus
        # Possible values include: debug, info, notice, warn, error, crit,
127 1 Dimitry Profus
        # alert, emerg.
128 1 Dimitry Profus
        LogLevel warn
129 1 Dimitry Profus
130 1 Dimitry Profus
        CustomLog /var/log/apache2/access.log combined
131 1 Dimitry Profus
</VirtualHost>
132 1 Dimitry Profus
</pre>
133 1 Dimitry Profus
For SSL add the following text instead
134 1 Dimitry Profus
<pre>
135 1 Dimitry Profus
<VirtualHost *:443>
136 1 Dimitry Profus
        ServerAdmin webmaster@localhost
137 1 Dimitry Profus
        DocumentRoot /var/www
138 1 Dimitry Profus
        ServerName myservername
139 1 Dimitry Profus
140 1 Dimitry Profus
        SSLEngine On
141 1 Dimitry Profus
        SSLCertificateFile /etc/apache2/ssl/redmine.pem
142 1 Dimitry Profus
143 1 Dimitry Profus
        RewriteEngine on
144 1 Dimitry Profus
        RewriteRule   ^/$  /redmine  [R]
145 1 Dimitry Profus
146 1 Dimitry Profus
        <Directory /var/www/redmine>
147 1 Dimitry Profus
                RailsBaseURI /redmine
148 1 Dimitry Profus
                PassengerResolveSymlinksInDocumentRoot on
149 1 Dimitry Profus
        </Directory>
150 1 Dimitry Profus
151 1 Dimitry Profus
        ErrorLog /var/log/apache2/error.log
152 1 Dimitry Profus
153 1 Dimitry Profus
        # Possible values include: debug, info, notice, warn, error, crit,
154 1 Dimitry Profus
        # alert, emerg.
155 1 Dimitry Profus
        LogLevel warn
156 1 Dimitry Profus
157 1 Dimitry Profus
        CustomLog /var/log/apache2/access.log combined
158 1 Dimitry Profus
</VirtualHost>
159 1 Dimitry Profus
</pre>
160 1 Dimitry Profus
# Enable the Redmine website
161 1 Dimitry Profus
<pre>
162 1 Dimitry Profus
$ sudo a2dissite default
163 1 Dimitry Profus
$ sudo a2ensite redmine
164 1 Dimitry Profus
</pre> 
165 1 Dimitry Profus
# Enable the Passenger and Rewite modules and restart Apache
166 1 Dimitry Profus
<pre> 
167 1 Dimitry Profus
$ sudo a2enmod passenger
168 1 Dimitry Profus
$ sudo a2enmod rewrite
169 1 Dimitry Profus
$ sudo /etc/init.d/apache2 restart
170 3 Dimitry Profus
</pre> 
171 3 Dimitry Profus
# Test the setup
172 3 Dimitry Profus
<pre>
173 3 Dimitry Profus
Open up your favorite web browser and goto
174 3 Dimitry Profus
175 3 Dimitry Profus
http://[my site or ip]/redmine
176 3 Dimitry Profus
</pre>
177 1 Dimitry Profus
178 5 Dimitry Profus
h2. Mercurial Integration
179 1 Dimitry Profus
180 1 Dimitry Profus
# Install the latest Mercurial release 
181 1 Dimitry Profus
<pre>
182 7 Dimitry Profus
$ sudo apt-get install python-software-properties
183 1 Dimitry Profus
$ sudo add-apt-repository ppa:mercurial-ppa/releases
184 1 Dimitry Profus
$ sudo apt-get update
185 18 Dimitry Profus
$ sudo apt-get install mercurial libapache-dbi-perl libapache2-mod-perl2
186 1 Dimitry Profus
</pre>
187 1 Dimitry Profus
# Create the hg web directory
188 1 Dimitry Profus
<pre>
189 1 Dimitry Profus
$ sudo mkdir -p /var/www/hg/repos
190 1 Dimitry Profus
</pre>
191 1 Dimitry Profus
# Create the web cgi script file
192 1 Dimitry Profus
<pre>
193 1 Dimitry Profus
$ sudo nano /var/www/hg/hgwebdir.cgi
194 1 Dimitry Profus
195 1 Dimitry Profus
Add the following and save
196 1 Dimitry Profus
197 1 Dimitry Profus
#!/usr/bin/env python
198 1 Dimitry Profus
#
199 1 Dimitry Profus
from mercurial import demandimport; demandimport.enable()
200 1 Dimitry Profus
from mercurial.hgweb.hgwebdir_mod import hgwebdir
201 1 Dimitry Profus
import mercurial.hgweb.wsgicgi as wsgicgi
202 1 Dimitry Profus
application = hgwebdir('hgweb.config')
203 1 Dimitry Profus
wsgicgi.launch(application)
204 1 Dimitry Profus
</pre>
205 1 Dimitry Profus
# Create the cgi web config file 
206 1 Dimitry Profus
<pre>
207 1 Dimitry Profus
$ sudo nano /var/www/hg/hgweb.config
208 1 Dimitry Profus
209 1 Dimitry Profus
Add the following and save
210 1 Dimitry Profus
211 8 Dimitry Profus
[paths]
212 8 Dimitry Profus
/=/var/www/hg/repos/**
213 1 Dimitry Profus
214 8 Dimitry Profus
[web]
215 8 Dimitry Profus
allow_push = *
216 8 Dimitry Profus
push_ssl = false
217 8 Dimitry Profus
allowbz2 = yes
218 8 Dimitry Profus
allowgz = yes
219 8 Dimitry Profus
allowzip = yes
220 1 Dimitry Profus
</pre>
221 1 Dimitry Profus
# Setup permissions
222 1 Dimitry Profus
<pre>
223 1 Dimitry Profus
$ sudo chown -R www-data:www-data /var/www/hg
224 1 Dimitry Profus
$ sudo chmod gu+x /var/www/hg/hgwebdir.cgi
225 1 Dimitry Profus
</pre>
226 12 Dimitry Profus
# Create a Apache config file
227 1 Dimitry Profus
<pre>
228 1 Dimitry Profus
$ sudo nano /etc/apache2/conf.d/hg.config
229 1 Dimitry Profus
230 1 Dimitry Profus
Add the following and save
231 1 Dimitry Profus
 
232 11 Dimitry Profus
PerlLoadModule Apache::Redmine
233 11 Dimitry Profus
ScriptAlias /hg  "/var/www/hg/hgwebdir.cgi"
234 11 Dimitry Profus
<Location /hg  >
235 11 Dimitry Profus
	AuthType Basic
236 11 Dimitry Profus
	AuthName "Mercurial" 
237 11 Dimitry Profus
	Require valid-user
238 1 Dimitry Profus
239 11 Dimitry Profus
	#Redmine auth
240 11 Dimitry Profus
	PerlAccessHandler Apache::Authn::Redmine::access_handler
241 11 Dimitry Profus
	PerlAuthenHandler Apache::Authn::Redmine::authen_handler
242 11 Dimitry Profus
	RedmineDSN "DBI:mysql:database=redmine;host=localhost" 
243 11 Dimitry Profus
	RedmineDbUser "redmine" 
244 11 Dimitry Profus
	RedmineDbPass "password" 
245 11 Dimitry Profus
</Location>
246 1 Dimitry Profus
</pre>
247 1 Dimitry Profus
# Add a symbolic link to Redmine.pm
248 1 Dimitry Profus
<pre>
249 5 Dimitry Profus
$ sudo ln -s /usr/share/redmine/extra/svn/Redmine.pm /usr/lib/perl5/Apache/Redmine.pm
250 5 Dimitry Profus
$ sudo ln -s /usr/share/redmine/extra/svn/Redmine.pm /usr/lib/perl5/Apache2/Redmine.pm  
251 1 Dimitry Profus
</pre>
252 1 Dimitry Profus
# Enable the required Apache modules and restart Apache
253 1 Dimitry Profus
<pre>
254 1 Dimitry Profus
$ sudo /etc/init.d/apache2 restart
255 1 Dimitry Profus
</pre>
256 8 Dimitry Profus
# Create a new test repository and project in Redmine
257 1 Dimitry Profus
<pre>
258 1 Dimitry Profus
$ sudo hg init /var/www/hg/repos/test
259 8 Dimitry Profus
$ sudo chown -R www-data:www-data /var/www/hg/repos/test
260 8 Dimitry Profus
261 8 Dimitry Profus
Create a new project with and identifier 'test'
262 8 Dimitry Profus
263 8 Dimitry Profus
In the project Settings > Repository set
264 8 Dimitry Profus
SCM: Mercurial
265 8 Dimitry Profus
Path to repository: /var/www/hg/repos/test
266 8 Dimitry Profus
Press the 'Create' button
267 8 Dimitry Profus
268 8 Dimitry Profus
Goto to the Repository tab of the test project
269 1 Dimitry Profus
</pre>
270 1 Dimitry Profus
# View the test repository in the web browser 
271 1 Dimitry Profus
<pre>
272 1 Dimitry Profus
> http://[my site name]/hg/test
273 1 Dimitry Profus
</pre>
274 1 Dimitry Profus
275 15 Dimitry Profus
h2. Subversion Integration
276 15 Dimitry Profus
277 15 Dimitry Profus
# Install the latest Mercurial release 
278 15 Dimitry Profus
<pre>
279 18 Dimitry Profus
$ sudo apt-get install subversion libapache2-svn libapache-dbi-perl libapache2-mod-perl2
280 15 Dimitry Profus
</pre>
281 15 Dimitry Profus
# Create the svn repository directory
282 15 Dimitry Profus
<pre>
283 15 Dimitry Profus
$ sudo mkdir /var/www/svn
284 15 Dimitry Profus
</pre>
285 15 Dimitry Profus
# Setup permissions
286 15 Dimitry Profus
<pre>
287 15 Dimitry Profus
$ sudo chown -R www-data:www-data /var/www/svn
288 15 Dimitry Profus
</pre>
289 15 Dimitry Profus
# Create a Apache config file
290 15 Dimitry Profus
<pre>
291 15 Dimitry Profus
$ sudo nano /etc/apache2/conf.d/svn.config
292 15 Dimitry Profus
</pre>
293 15 Dimitry Profus
Add the following and save
294 15 Dimitry Profus
<pre>
295 15 Dimitry Profus
   PerlLoadModule Apache::Redmine
296 15 Dimitry Profus
   <Location /svn>
297 15 Dimitry Profus
     DAV svn
298 15 Dimitry Profus
     SVNParentPath "/var/www/svn" 
299 15 Dimitry Profus
     Order deny,allow
300 15 Dimitry Profus
     Deny from all
301 15 Dimitry Profus
     Satisfy any
302 15 Dimitry Profus
303 15 Dimitry Profus
     PerlAccessHandler Apache::Authn::Redmine::access_handler
304 15 Dimitry Profus
     PerlAuthenHandler Apache::Authn::Redmine::authen_handler
305 15 Dimitry Profus
     AuthType Basic
306 15 Dimitry Profus
     AuthName "Redmine Subversion Repository" 
307 15 Dimitry Profus
308 15 Dimitry Profus
     #read-only access    
309 15 Dimitry Profus
     <Limit GET PROPFIND OPTIONS REPORT>
310 15 Dimitry Profus
        Require valid-user
311 15 Dimitry Profus
        Allow from 127.0.0.1
312 15 Dimitry Profus
        # Allow from another-ip
313 15 Dimitry Profus
         Satisfy any
314 15 Dimitry Profus
     </Limit>
315 15 Dimitry Profus
     # write access
316 15 Dimitry Profus
     <LimitExcept GET PROPFIND OPTIONS REPORT>
317 15 Dimitry Profus
       Require valid-user
318 15 Dimitry Profus
     </LimitExcept>
319 15 Dimitry Profus
320 15 Dimitry Profus
     ## for mysql
321 15 Dimitry Profus
     RedmineDSN "DBI:mysql:database=redmine_default;host=localhost" 
322 15 Dimitry Profus
     RedmineDbUser "redmine" 
323 15 Dimitry Profus
     RedmineDbPass "password" 
324 15 Dimitry Profus
  </Location>
325 15 Dimitry Profus
</pre>
326 15 Dimitry Profus
# Enable the required Apache modules and restart Apache
327 15 Dimitry Profus
<pre>
328 15 Dimitry Profus
$ sudo a2enmod dav_svn
329 15 Dimitry Profus
$ sudo /etc/init.d/apache2 restart
330 15 Dimitry Profus
</pre>
331 15 Dimitry Profus
# Create a new test repository
332 15 Dimitry Profus
<pre>
333 15 Dimitry Profus
$ sudo svn create /var/www/svn/test
334 15 Dimitry Profus
$ sudo chown -R www-data:www-data /var/www/svn/test
335 15 Dimitry Profus
</pre>
336 15 Dimitry Profus
337 10 Dimitry Profus
h2. Email Integration
338 1 Dimitry Profus
339 1 Dimitry Profus
# Install and configure Sendmail
340 1 Dimitry Profus
<pre>
341 1 Dimitry Profus
$ sudo apt-get install sendmail
342 1 Dimitry Profus
$ sudo sendmailconfig
343 1 Dimitry Profus
344 1 Dimitry Profus
(Answer Yes to all questions which you will be asked)
345 1 Dimitry Profus
</pre>
346 1 Dimitry Profus
# Update the Redmine configuration file
347 1 Dimitry Profus
<pre>
348 5 Dimitry Profus
$ sudo nano /usr/share/redmine/config/configuration.yml
349 1 Dimitry Profus
350 1 Dimitry Profus
Add the following text and save
351 1 Dimitry Profus
352 1 Dimitry Profus
 production:
353 1 Dimitry Profus
   email_delivery:
354 1 Dimitry Profus
     delivery_method: :sendmail
355 1 Dimitry Profus
</pre>