HowTo Install Redmine in Ubuntu » History » Version 2

Sam Wilson, 2010-05-26 05:26
Threw in some other stuff about apache etc. Needs lots more work.

1 1 Umit Uzun
h1. Redmine Installation on Virtual or Normal Ubuntu
2 1 Umit Uzun
3 2 Sam Wilson
This page is a guide to installing Redmine on either a virtual or actual installation of the Ubuntu operating system.  If you follow all instructions correctly you will be installed your Redmine server successfully almost an hour.
4 1 Umit Uzun
5 2 Sam Wilson
h2. Step 1: Install Ubuntu
6 1 Umit Uzun
7 2 Sam Wilson
If you are installing on a non-virtual Ubuntu instance, please skip this section.
8 1 Umit Uzun
9 2 Sam Wilson
*Installing VirtualBox:*
10 2 Sam Wilson
11 2 Sam Wilson
1.Download last version of Sun VirtualBox (version 3.0.10 or newer) tool in your system.
12 1 Umit Uzun
2.Install to your system by following the instructions.
13 1 Umit Uzun
14 1 Umit Uzun
*Installing Ubuntu on VirtualBox:*
15 1 Umit Uzun
16 1 Umit Uzun
1.Download last version of Ubuntu(version 9.10 or newer) OS in your system.
17 1 Umit Uzun
2.After installed VirtualBox on your system you will create a new virtual operating which will be Linux type and Ubuntu subtype. If you don't know anything about VirtualBox and/or its usage please refer to the google.
18 1 Umit Uzun
19 1 Umit Uzun
3.While installing Ubuntu you should type the related configurations as follows:
20 1 Umit Uzun
(These all configurations are optional, you can give any name what you what.)
21 1 Umit Uzun
Q: What is your name? A: Redmine Server
22 1 Umit Uzun
Q: What name do you want to use to login? A: redmine
23 1 Umit Uzun
Q: Choose to password to keep your account safe? A: redmine
24 1 Umit Uzun
Q: What is the name of this computer? A: redmine-server
25 1 Umit Uzun
Choose “Log in automatically.” radio button.
26 1 Umit Uzun
27 1 Umit Uzun
4.When you finished up installation all of them open up your new VirtualBox Ubuntu OS and open up terminal(console) screen and  issuing these commands:
28 1 Umit Uzun
> sudo apt-get update
29 1 Umit Uzun
> sudo apt-get upgrade
30 1 Umit Uzun
31 1 Umit Uzun
*Configuring VirtualBox:*
32 1 Umit Uzun
33 1 Umit Uzun
1.If you want to reach your VirtualBox Ubuntu OS from different machine, you have to configure VirtualBox Ubuntu OS's network setting to Bridged Adapter. So you can reach your VirtualBox Ubuntu from internal IP address easily. Because it get's same IP block as you from DHCP easily. I mean your guest and host computer is same IP block as different network client.
34 1 Umit Uzun
35 1 Umit Uzun
2.If you had assigned a static IP to your Network Consult by giving your static ethernet MAC address, you have to assign unique MAC address your VirtualBox Ubuntu OS by Setting->Network->MAC address initialization box. By this MAC address, you can get static ip easily or you can configure your Ubuntu system to not use DHCP, instead of that you can assign static IP manually.
36 1 Umit Uzun
37 2 Sam Wilson
h2. Step 2: Install Redmine
38 1 Umit Uzun
39 2 Sam Wilson
Once you have a functioning Ubuntu operating system up and running, you can continue with installing Redmine.
40 1 Umit Uzun
41 2 Sam Wilson
h3. Install dependencies
42 2 Sam Wilson
43 2 Sam Wilson
The following packages are required to install and run Redmine.  Please install them by running @apt-get@ as root:
44 2 Sam Wilson
45 2 Sam Wilson
>sudo apt-get package-name
46 2 Sam Wilson
47 2 Sam Wilson
where @package-name@ is each of:
48 2 Sam Wilson
* apache2 
49 2 Sam Wilson
* apache2-threaded-dev 
50 2 Sam Wilson
* build-essential
51 2 Sam Wilson
* libapache-dbi-perl 
52 2 Sam Wilson
* libapache2-mod-perl2 
53 2 Sam Wilson
* libapache2-svn
54 2 Sam Wilson
* libdigest-sha1-perl 
55 2 Sam Wilson
* libgemplugin-ruby 
56 2 Sam Wilson
* libgemplugin-ruby1.8 
57 2 Sam Wilson
* libruby-extras 
58 2 Sam Wilson
* libruby1.8-extras 
59 2 Sam Wilson
* mongrel 
60 2 Sam Wilson
* mysql-server
61 2 Sam Wilson
* rails
62 2 Sam Wilson
* rake 
63 2 Sam Wilson
* ruby
64 2 Sam Wilson
* rubygems
65 2 Sam Wilson
* rubygems1.8
66 2 Sam Wilson
* ruby1.8-dev
67 2 Sam Wilson
* subversion
68 2 Sam Wilson
69 2 Sam Wilson
_(Could someone please clean up this list?)_
70 2 Sam Wilson
71 1 Umit Uzun
*Package Installation and Setup:*
72 1 Umit Uzun
73 1 Umit Uzun
1.Once you’ve installed the VirtualBox Ubuntu OS and updated it, you need to install a bunch of packages that we will prepare the server for the Redmine installation. So, as root, install the following packages by issuing: 
74 2 Sam Wilson
> sudo apt-get install 
75 2 Sam Wilson
> sudo apt-get install 
76 1 Umit Uzun
77 1 Umit Uzun
The packages we’re installing above are MySQL, phpMyAdmin, Rails, Ruby Gems, Mongrel and Ruby Dev environment.
78 1 Umit Uzun
During the installation of the packages, when MySQL is installed, it will prompt you to	create a password. Make sure you remember it. You will need it later to log in to the 	phpMyAdmin. To make simplicity you can set all passwords to “redmine”.
79 1 Umit Uzun
80 1 Umit Uzun
2.Create a new directory for Redmine. I put mine in /opt/redmine. And download last version of Redmine in it with wget command line downloader and extract it by issuing:
81 1 Umit Uzun
> sudo mkdir /opt/redmine
82 1 Umit Uzun
> sudo cd /opt/redmine
83 1 Umit Uzun
> sudo wget http://rubyforge.org/frs/download.php/66633/redmine-0.8.6.tar.gz
84 1 Umit Uzun
> tar -xvf redmine-0.8.6.tar.gz
85 1 Umit Uzun
86 1 Umit Uzun
*Database Setup:*
87 1 Umit Uzun
88 1 Umit Uzun
1.Now it’s time to create an empty database for Redmine. As you may have noticed, we installed phpMyAdmin earlier. phpMyAdmin will come in handy now. Head over to http://localhost/phpmyadmin. You should be presented with the phpMyAdmin login screen.
89 1 Umit Uzun
Type in “root” and the MySQL “password” you created when installing MySQL.
90 1 Umit Uzun
91 1 Umit Uzun
2.First, click on “Databases” Then, at the bottom of the screen, in the “Create new database” text box create a new database called “redmine” and set “Collation” to “utf8_general_ci”.
92 1 Umit Uzun
93 1 Umit Uzun
3.Now, go back to the home screen and click on:
94 1 Umit Uzun
“Privileges”
95 1 Umit Uzun
“Add a new User” 
96 1 Umit Uzun
Fill out the “Login Information” boxes. Call your user “redmine”. Make sure you remember password you create here. It will be used when you set up the database connection details in Redmine.
97 1 Umit Uzun
In the “Database for user” section, check “Create database with same name and grant all privileges” and click on the “Go” button.
98 1 Umit Uzun
99 1 Umit Uzun
4.Log out of phpMyAdmin.
100 1 Umit Uzun
101 1 Umit Uzun
*Redmine Database Connection Configuration:*
102 1 Umit Uzun
103 1 Umit Uzun
1.It’s time to configure the database connection. If you installed Redmine as I did above, then copy “config/database.yml.example” to “config/database.yml” and edit this file in order to configure your database settings for “production” environment. You’ll find the “database.yml.example” issuing:
104 1 Umit Uzun
> sudo cd /opt/redmine/redmine-0.8.6/config
105 1 Umit Uzun
106 1 Umit Uzun
2.So now, assuming you’re in the “/opt/redmine/redmine-0.8.6/config” directory, issue:
107 1 Umit Uzun
> sudo cp database.yml.example database.yml 
108 1 Umit Uzun
109 1 Umit Uzun
3.Then, open the “database.yml” file, issue:
110 1 Umit Uzun
> sudo gedit database.yml
111 1 Umit Uzun
… and edit it as in the example for a MySQL database below:
112 1 Umit Uzun
113 1 Umit Uzun
production:
114 1 Umit Uzun
adapter: mysql
115 1 Umit Uzun
socket: /var/run/mysqld/mysqld.sock
116 1 Umit Uzun
database: redmine
117 1 Umit Uzun
host: localhost
118 1 Umit Uzun
username: redmine
119 1 Umit Uzun
password: [password]
120 1 Umit Uzun
121 1 Umit Uzun
Then save “database.yml” file and exit to the command prompt.
122 1 Umit Uzun
On Ubuntu the “mysql.sock” is located in /var/run/mysqld/mysqld.sock, as noted in the “config” above. 
123 1 Umit Uzun
(The standard Redmine installation assumes the socket is located in “/opt/redmine/redmine-0.8.6/tmp/mysqld.sock”.)
124 1 Umit Uzun
125 1 Umit Uzun
4.Create the database structure, by running the following command under the application root directory(I mean “/opt/redmine/redmine-0.8.6”):
126 1 Umit Uzun
> sudo rake db:migrate RAILS_ENV="production" 
127 1 Umit Uzun
It will create the necessary tables in the redmine database you created earlier and an 	administrator account.
128 1 Umit Uzun
129 1 Umit Uzun
5.Insert default configuration data in database, by issuing:
130 1 Umit Uzun
> sudo rake redmine:load_default_data RAILS_ENV="production" 
131 1 Umit Uzun
(This step is optional but highly recommended, as you can define your own configuration	from scratch. It will load default roles, trackers, statuses, work flows and enumerations. While loading default data command prompt wants to given language selection by you.) 
132 1 Umit Uzun
133 1 Umit Uzun
*Setting up Permissions:*
134 1 Umit Uzun
135 1 Umit Uzun
1.The user who runs Redmine must have write permission on the following sub directories: “files”, “log”, “tmp” (create the last one if not present). You probably already have a “tmp” directory in /opt/redmine/redmine-0.8.6, but if you don’t, create one now by issuing:
136 1 Umit Uzun
> sudo mkdir /opt/redmine/redmine-0.8.6
137 1 Umit Uzun
138 1 Umit Uzun
2.If you haven’t created a Redmine user, do it now by issuing:
139 1 Umit Uzun
> sudo useradd redmine
140 1 Umit Uzun
141 1 Umit Uzun
3.Now, assuming you run Redmine with a redmine user, from your /opt/redmine/redmine-0.8.6 directory issue:
142 1 Umit Uzun
> sudo chown -R redmine:redmine files log tmp
143 1 Umit Uzun
> sudo chmod -R 755 files log tmp
144 1 Umit Uzun
145 1 Umit Uzun
*Testing the Installation:*
146 1 Umit Uzun
147 1 Umit Uzun
1.It should all be working now. Test the installation by running the WEBrick web server issue:
148 1 Umit Uzun
> sudo cd /opt/redmine/redmine-0.8.6
149 1 Umit Uzun
> sudo ruby script/server -e production
150 1 Umit Uzun
	
151 1 Umit Uzun
Once WEBrick has started, point your browser to http://localhost:3000/. Or, if you are using a browser on another computer than what you installed Redmine on, point your browser to http://192.168.1.10:3000/ (if that’s the IP address you gave your Redmine server). You should now see the application welcome page. 
152 1 Umit Uzun
153 1 Umit Uzun
*Log in:*
154 1 Umit Uzun
155 1 Umit Uzun
1.Use default administrator account to log in:
156 1 Umit Uzun
Login : admin
157 1 Umit Uzun
Password : admin
158 1 Umit Uzun
159 1 Umit Uzun
2.You can go to Admin & Settings to modify application settings.
160 1 Umit Uzun
161 1 Umit Uzun
*Setting Up Static IP:*
162 1 Umit Uzun
163 1 Umit Uzun
1.A more easy method for configuring a static IP address is to use your local DHCP server to assign a permanent IP to the VirtualBox OS mac address. That way you will not have to do anything inside VBS. Consult your network administrator. 
164 1 Umit Uzun
165 1 Umit Uzun
2.Or you should learn configuration parameters as given below, and can configure your system to get static IP address:
166 1 Umit Uzun
The desired IP address
167 1 Umit Uzun
Network mask and broadcast address
168 1 Umit Uzun
Gateway address
169 1 Umit Uzun
Your local DNS server address(es)
170 1 Umit Uzun
171 1 Umit Uzun
*Assigning Host Name and Domain for VirtualBox OS:*
172 1 Umit Uzun
173 1 Umit Uzun
1.A more easy method for adding your IP address - Host name pair configurations to your DNS server . Consult your network administrator.
174 1 Umit Uzun
175 2 Sam Wilson
h2. Configuring the Passenger Apache module
176 1 Umit Uzun
177 2 Sam Wilson
Passenger is a module for apache2 that allow apache to run ruby on rails applications.  Install it thus:
178 2 Sam Wilson
179 2 Sam Wilson
>$ sudo gem install passenger
180 2 Sam Wilson
181 2 Sam Wilson
Then go to the passenger apache2 module installation directory and run @passenger-install-apache2-module@
182 2 Sam Wilson
183 2 Sam Wilson
> $ cd /var/lib/gems/1.X/gems/passenger-X.X.X/
184 2 Sam Wilson
185 2 Sam Wilson
> $ sudo bin/passenger-install-apache2-module
186 2 Sam Wilson
187 2 Sam Wilson
Next, configure Apache:
188 2 Sam Wilson
189 2 Sam Wilson
In /etc/apache2/mods-available/passenger.load we will add next line
190 2 Sam Wilson
191 2 Sam Wilson
> LoadModule passenger_module /var/lib/gems/1.X/gems/passenger-X.X.X/ext/apache2/mod_passenger.so
192 2 Sam Wilson
193 2 Sam Wilson
We have to edit the conf of the passenger apache2 module in /etc/apache2/mods-available/passenger.conf
194 2 Sam Wilson
195 2 Sam Wilson
> PassengerRoot /var/lib/gems/1.X/gems/passenger-X.X.X
196 2 Sam Wilson
> PassengerRuby /usr/bin/ruby1.X
197 2 Sam Wilson
198 2 Sam Wilson
And now we active the module
199 2 Sam Wilson
200 2 Sam Wilson
> $ sudo a2enmod passenger
201 2 Sam Wilson
202 2 Sam Wilson
Apache virtualhost for redmine web app
203 2 Sam Wilson
204 2 Sam Wilson
<pre>
205 2 Sam Wilson
    <VirtualHost *:80>
206 2 Sam Wilson
        ServerName redmine.server.com
207 2 Sam Wilson
208 2 Sam Wilson
        DocumentRoot /var/www/redmine/public
209 2 Sam Wilson
210 2 Sam Wilson
        ServerAdmin user@server.com
211 2 Sam Wilson
        LogLevel warn
212 2 Sam Wilson
        ErrorLog /var/log/apache2/redmine_error
213 2 Sam Wilson
        CustomLog /var/log/apache2/redmine_access combined
214 2 Sam Wilson
215 2 Sam Wilson
        <Directory /var/www/redmine/public>
216 2 Sam Wilson
            Options Indexes FollowSymLinks MultiViews
217 2 Sam Wilson
            AllowOverride None
218 2 Sam Wilson
            Order allow,deny
219 2 Sam Wilson
            allow from all
220 2 Sam Wilson
        </Directory>
221 2 Sam Wilson
    </VirtualHost>
222 2 Sam Wilson
</pre>
223 2 Sam Wilson
224 2 Sam Wilson
subversion server config in apache
225 2 Sam Wilson
226 2 Sam Wilson
<pre>
227 2 Sam Wilson
    <VirtualHost *:80>
228 2 Sam Wilson
	ServerName svn.server.com
229 2 Sam Wilson
	ServerAdmin user@server.com
230 2 Sam Wilson
	ErrorLog /var/log/apache2/svn_error
231 2 Sam Wilson
       	CustomLog /var/log/apache2/svn_access combined
232 2 Sam Wilson
        <Location /project>
233 2 Sam Wilson
           DAV svn
234 2 Sam Wilson
           SVNPath /var/lib/svn/project
235 2 Sam Wilson
236 2 Sam Wilson
           AuthType Basic
237 2 Sam Wilson
           AuthName "Trac system for Server projects"
238 2 Sam Wilson
           AuthUserFile "/var/lib/svn/.htpasswd"
239 2 Sam Wilson
           Require valid-user 
240 2 Sam Wilson
	   <LimitExcept GET PROPFIND OPTIONS REPORT>
241 2 Sam Wilson
               Require valid-user
242 2 Sam Wilson
           </LimitExcept>
243 2 Sam Wilson
       </Location>
244 2 Sam Wilson
    </Virtualhost>
245 2 Sam Wilson
</pre>
246 2 Sam Wilson
247 2 Sam Wilson
h2. Sendmail Server Configuration:
248 2 Sam Wilson
249 1 Umit Uzun
1.Before configure the email support of Redmine, we should download sendmail application for Ubuntu, issue:
250 1 Umit Uzun
> sudo apt-get install sendmail
251 1 Umit Uzun
> sudo sendmailconfig (Answer Yes to all questions which will be asked you)
252 1 Umit Uzun
253 1 Umit Uzun
2.It’s time to configure the server connection. Copy “config/email.yml.example” to “config/email.yml” and edit this file in order to configure your database settings for “production” environment. You’ll find the “email.yml.example” issue:
254 1 Umit Uzun
> sudo cd /opt/redmine/redmine-0.8.6/config
255 1 Umit Uzun
256 1 Umit Uzun
3.So now, assuming you’re in the “/config” directory, issue:
257 1 Umit Uzun
> sudo cp email.yml.example email.yml 
258 1 Umit Uzun
259 1 Umit Uzun
4.Then, open the “email.yml” file, issue:
260 1 Umit Uzun
> sudo gedit email.yml
261 1 Umit Uzun
… and edit it as in the example for sendmail configuration below:
262 1 Umit Uzun
263 1 Umit Uzun
production:
264 1 Umit Uzun
delivery_method: :sendmail
265 1 Umit Uzun
sendmail_settings:
266 1 Umit Uzun
location: /usr/sbin/sendmail
267 1 Umit Uzun
arguments: -i -t
268 1 Umit Uzun
address: smtp.example.net
269 1 Umit Uzun
port: 25
270 1 Umit Uzun
domain: example.net
271 1 Umit Uzun
authentication: :none
272 1 Umit Uzun
user_name: redmine@example.net
273 1 Umit Uzun
password: redmine
274 1 Umit Uzun
275 1 Umit Uzun
Then save “email.yml” file and exit to the command prompt.
276 1 Umit Uzun
277 1 Umit Uzun
5.It’s time to configure the “environmet.rb” configuration. Open up the “environment.rb” and change “config.action_mailer.perform_deliveries = false” to “config.action_mailer.perform_deliveries = true” then save and close the “environment.rb”.
278 1 Umit Uzun
279 1 Umit Uzun
*Subversion Installation and Configuration:*
280 1 Umit Uzun
281 1 Umit Uzun
1.Before configure the subversion support of Redmine, we should download subversion application for Ubuntu, issue:
282 1 Umit Uzun
> sudo apt-get install subversion
283 1 Umit Uzun
284 1 Umit Uzun
2.If your Redmine can't find the “subversion” command you can help to find by issuing:
285 1 Umit Uzun
· > sudo cd /opt/redmine/redmine-0.8.6/config
286 1 Umit Uzun
· > sudo gedit environment.rb
287 1 Umit Uzun
· Add ENV['PATH'] = "#{ENV['PATH']}:/subversion/path" line in it.
288 1 Umit Uzun
· Save and close the “environment.rb”
289 1 Umit Uzun
290 1 Umit Uzun
*Start Application Boot Time:*
291 1 Umit Uzun
292 1 Umit Uzun
1.To automatically start the application on booting your server you need to modify your “crontab”, issue:
293 1 Umit Uzun
> export EDITOR=gedit
294 1 Umit Uzun
> crontab -e
295 1 Umit Uzun
296 1 Umit Uzun
2.Your “crontab” file will be presented. This is the list of programs that start at certain times or at boot. Add the following to the “crontab” (all on one line):
297 1 Umit Uzun
@reboot cd /opt/redmine/redmine-0.8.6 ; rm -f log/mongrel.pid ; mongrel_rails start -e production -p 3000 -d
298 1 Umit Uzun
299 1 Umit Uzun
*Backup:*
300 1 Umit Uzun
301 1 Umit Uzun
1.Running backups is always a good idea. Redmine backups should include:
302 1 Umit Uzun
data (stored in your redmine database) 
303 1 Umit Uzun
/usr/bin/mysqldump -u -p | gzip > /path/to/redmine/backup/db/redmine_`date +%y_%m_%d`.gz
304 1 Umit Uzun
attachments (stored in the files directory of your Redmine install)
305 1 Umit Uzun
rsync -a /path/to/redmine/files /path/to/redmine/backup/files
306 1 Umit Uzun
307 1 Umit Uzun
2.Or you can use bash shell to automate kind of this operation issue:
308 1 Umit Uzun
> sudo cd /opt/redmine/redmine-0.8.6
309 1 Umit Uzun
> sudo mkdir backup
310 1 Umit Uzun
> sudo mkdir backup/db
311 1 Umit Uzun
> sudo mkdir backup/files
312 1 Umit Uzun
> sudo gedit backup/runRedmineBackup.bash
313 1 Umit Uzun
314 1 Umit Uzun
And after opened gedit with “runRedmineBackup.bash” write all commands below:
315 1 Umit Uzun
316 1 Umit Uzun
#!/bin/bash
317 1 Umit Uzun
data=`date -I`
318 1 Umit Uzun
mysqldump --user=root --password="redmine" --all-databases | gzip > db/backup-$data.sql.gz
319 1 Umit Uzun
cd db
320 1 Umit Uzun
ftp -i -n << EOF
321 1 Umit Uzun
open ftpserver.example.net
322 1 Umit Uzun
user username password
323 1 Umit Uzun
bin
324 1 Umit Uzun
mput backup-$data.sql.gz
325 1 Umit Uzun
bye
326 1 Umit Uzun
EOF
327 1 Umit Uzun
328 1 Umit Uzun
Then save “runRedmineBackup.bash” file and exit to the command prompt. After creation of  runRedmineBackup.bash you can add this bash to run continually between specified periods. Issue:
329 1 Umit Uzun
330 1 Umit Uzun
> export EDITOR=gedit
331 1 Umit Uzun
> crontab -e
332 1 Umit Uzun
Add 0 0 * * 0 cd /opt/redmine/redmine-0.8.6/backup ; sh runRedmineBackup.bash commands to crontab to backup database weekly.
333 1 Umit Uzun
	
334 1 Umit Uzun
To work this bush without any permission problem you have to change all of them modes to maxium permission issue:
335 1 Umit Uzun
336 1 Umit Uzun
> sudo chmod -R 777 backup
337 1 Umit Uzun
> sudo chown -R redmine:redmine backup
338 1 Umit Uzun
339 1 Umit Uzun
That's all. Now we completely installed Redmine our virtual Ubuntu OS and can reach from any machine at our network easily. Congratulations..!
340 1 Umit Uzun
341 2 Sam Wilson
h2. Sources & contributors.
342 2 Sam Wilson
343 2 Sam Wilson
* Ümit Uzun 06/11/2009.
344 2 Sam Wilson
* Some of the above material comes from Macada's wiki, licenced under the GNU Free Documentation License 1.2.  See "Redmine in Ubuntu Jaunty 9.04":http://wiki.ousli.org/index.php/Redmine_in_Ubuntu_Jaunty_9.04 by David 'macada', last modified 2010-02-08, accessed 2010-05-26.
345 2 Sam Wilson
* Sam Wilson 2010-05-26, formatting changes.