HowTo Install Redmine on Debian 8 with Apache2-Passenger » History » Version 14

Eric dLR, 2016-11-13 13:21
Correcting a typo in the 'Install Debian Packages' header.

1 1 Dirk Abe
h1. HowTo Install Redmine on Debian 8 with Apache2-Passenger
2 1 Dirk Abe
3 3 Dirk Abe
Last updated: 4. April 2015
4 1 Dirk Abe
5 7 Dirk Abe
This HowTo describes installing redmine 3.0.1 on Debain 8 (April 15, few weeks before released as
6 1 Dirk Abe
stable) with Apache and MySQL. 
7 1 Dirk Abe
8 1 Dirk Abe
*Hint:*
9 13 Felipe Braga
Run all commands as normal user. If root privileges required i used sudo (the 'sudo' package needs to be properly instaled and configured).
10 1 Dirk Abe
11 14 Eric dLR
h2. 1. Install Debian Packages
12 1 Dirk Abe
13 1 Dirk Abe
<pre>
14 11 Mike Zabala
sudo aptitude install mysql-server mysql-client libmysqlclient-dev gcc build-essential zlib1g zlib1g-dev zlibc ruby-zip libssl-dev libyaml-dev libcurl4-openssl-dev ruby gem libapache2-mod-passenger apache2-mpm-prefork apache2-dev libapr1-dev libxslt1-dev checkinstall libxml2-dev ruby-dev vim libmagickwand-dev imagemagick
15 1 Dirk Abe
</pre>
16 1 Dirk Abe
17 1 Dirk Abe
18 1 Dirk Abe
h2. 2. Download and prepare Redmine
19 1 Dirk Abe
20 1 Dirk Abe
h3. 2.1 Download Redmine
21 1 Dirk Abe
22 1 Dirk Abe
<pre>
23 1 Dirk Abe
cd /opt/
24 1 Dirk Abe
sudo mkdir redmine
25 1 Dirk Abe
sudo chown -R $your_user redmine
26 1 Dirk Abe
cd redmine
27 1 Dirk Abe
wget $redmine.tar.gz
28 1 Dirk Abe
tar xzf $redmine.tar.gz
29 1 Dirk Abe
cd redmine-X.X.X
30 1 Dirk Abe
</pre>
31 1 Dirk Abe
32 1 Dirk Abe
33 1 Dirk Abe
h3. 2.2 Prepare MySQL 
34 1 Dirk Abe
35 1 Dirk Abe
<pre>
36 1 Dirk Abe
mysql --user=root --password=$password
37 1 Dirk Abe
</pre>
38 1 Dirk Abe
39 1 Dirk Abe
40 1 Dirk Abe
<pre>
41 1 Dirk Abe
CREATE DATABASE redmine CHARACTER SET utf8;
42 1 Dirk Abe
CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'my_password';
43 1 Dirk Abe
GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';
44 1 Dirk Abe
exit
45 1 Dirk Abe
</pre>
46 1 Dirk Abe
47 1 Dirk Abe
Redmine DB-Config:
48 1 Dirk Abe
49 1 Dirk Abe
<pre>
50 1 Dirk Abe
cp config/database.yml.example config/database.yml
51 1 Dirk Abe
</pre>
52 1 Dirk Abe
53 1 Dirk Abe
customize config/database.yml:
54 1 Dirk Abe
55 1 Dirk Abe
<pre>
56 1 Dirk Abe
production:
57 9 Greg Stevenson
  adapter: mysql2
58 1 Dirk Abe
  database: redmine
59 1 Dirk Abe
  host: localhost
60 1 Dirk Abe
  username: redmine
61 1 Dirk Abe
  password: my_password
62 1 Dirk Abe
</pre>
63 1 Dirk Abe
64 1 Dirk Abe
h3. 2.3 Bundler
65 1 Dirk Abe
66 1 Dirk Abe
install bundler: 
67 1 Dirk Abe
68 1 Dirk Abe
<pre>
69 1 Dirk Abe
sudo gem install bundler
70 11 Mike Zabala
bundle install --without development test
71 1 Dirk Abe
</pre>
72 1 Dirk Abe
73 1 Dirk Abe
generate secret token:
74 1 Dirk Abe
75 1 Dirk Abe
<pre>
76 1 Dirk Abe
bundle exec rake generate_secret_token
77 1 Dirk Abe
</pre>
78 1 Dirk Abe
79 1 Dirk Abe
prepare DB and install all tables:
80 1 Dirk Abe
81 1 Dirk Abe
<pre>
82 1 Dirk Abe
RAILS_ENV=production bundle exec rake db:migrate
83 1 Dirk Abe
RAILS_ENV=production bundle exec rake redmine:load_default_data
84 1 Dirk Abe
</pre>
85 1 Dirk Abe
86 2 Dirk Abe
h3. 2.4 Test Redmine
87 1 Dirk Abe
88 1 Dirk Abe
replace $IP with your external IP:
89 1 Dirk Abe
<pre>
90 1 Dirk Abe
bundle exec ruby bin/rails server -b $IP webrick -e production
91 1 Dirk Abe
</pre>
92 1 Dirk Abe
93 1 Dirk Abe
Open your browser and visit http://$IP:3000
94 1 Dirk Abe
95 2 Dirk Abe
h2. 3 Apache
96 1 Dirk Abe
97 1 Dirk Abe
The apache service runs with the user www-data, so www-data needs access to some dirs:
98 1 Dirk Abe
99 1 Dirk Abe
<pre>
100 1 Dirk Abe
sudo chown -R www-data files log tmp public/plugin_assets
101 1 Dirk Abe
sudo chmod -R 755 files log tmp public/plugin_assets
102 12 Raúl Priego
sudo chown www-data:www-data Gemfile.lock
103 1 Dirk Abe
</pre>
104 1 Dirk Abe
105 1 Dirk Abe
Link the redmine public dir to the apache root:
106 1 Dirk Abe
107 1 Dirk Abe
<pre>
108 10 Greg Stevenson
sudo ln -s /opt/redmine/redmine-X.X.X/public/ /var/www/html/redmine
109 1 Dirk Abe
</pre>
110 1 Dirk Abe
111 1 Dirk Abe
The following VirtualHost config requieres control over your webserver.
112 1 Dirk Abe
Every Site under /var/www/html/ needs maybe an Location-directive.
113 1 Dirk Abe
114 1 Dirk Abe
We generate a new vhost config:
115 1 Dirk Abe
<pre>
116 1 Dirk Abe
sudo vim /etc/apache2/sites-available/master.conf
117 1 Dirk Abe
</pre>
118 1 Dirk Abe
119 1 Dirk Abe
and for redmine you need:
120 1 Dirk Abe
121 1 Dirk Abe
<pre>
122 1 Dirk Abe
<VirtualHost *:80>
123 1 Dirk Abe
124 1 Dirk Abe
ServerAdmin admin@example.com
125 1 Dirk Abe
Servername hostname
126 1 Dirk Abe
DocumentRoot /var/www/html/
127 1 Dirk Abe
128 1 Dirk Abe
        <Location /redmine>
129 1 Dirk Abe
                RailsEnv production
130 1 Dirk Abe
                RackBaseURI /redmine
131 1 Dirk Abe
                Options -MultiViews
132 1 Dirk Abe
        </Location>
133 1 Dirk Abe
134 1 Dirk Abe
</VirtualHost>
135 1 Dirk Abe
</pre>
136 1 Dirk Abe
137 1 Dirk Abe
Disable debians default-vhost:
138 1 Dirk Abe
<pre>
139 1 Dirk Abe
sudo a2dissite 000-default.conf
140 1 Dirk Abe
</pre>
141 1 Dirk Abe
142 1 Dirk Abe
and enable the new master vhost:
143 1 Dirk Abe
<pre>
144 1 Dirk Abe
sudo a2ensite master.conf
145 1 Dirk Abe
</pre>
146 1 Dirk Abe
147 3 Dirk Abe
To avoid permission error the passenger mod needs to run also as www-data.
148 3 Dirk Abe
Edit /etc/apache2/mods-available/passenger.conf and add this line:
149 1 Dirk Abe
<pre>
150 3 Dirk Abe
PassengerUser www-data
151 4 Dirk Abe
</pre>
152 3 Dirk Abe
153 3 Dirk Abe
after all restart apache:
154 3 Dirk Abe
<pre>
155 3 Dirk Abe
sudo service apache2 restart
156 1 Dirk Abe
</pre>
157 1 Dirk Abe
158 1 Dirk Abe
Open your browser and visit http://$IP/redmine
159 1 Dirk Abe
Finish.