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