HowTo Install Redmine on Debian 9 » History » Version 5

Fabián Rodríguez, 2018-07-19 16:30
Reformatted, updated for more formal style, put current doc under "from sources", added link to Redmine guide at Debian wiki

1 2 Bruce Schaller
h1. How to Install Redmine on Debian 9 (Stretch)
2 2 Bruce Schaller
3 5 Fabián Rodríguez
h2. Installing from Debian packages
4 2 Bruce Schaller
5 5 Fabián Rodríguez
Official Redmine packages are available for Debian. As of July 2018, stable version 3.3.1 is supported in Debian 9.
6 1 Bruce Schaller
7 5 Fabián Rodríguez
If you will be using Redmine in a production environment requiring long term support and stability using official packages is recommended. You will be receiving automatic feature and security updates.
8 1 Bruce Schaller
9 5 Fabián Rodríguez
See "the Redmine documentation on the Debian Wiki":https://wiki.debian.org/Redmine for detailed instructions.
10 1 Bruce Schaller
11 5 Fabián Rodríguez
h2. Installing from sources
12 1 Bruce Schaller
13 5 Fabián Rodríguez
If you want the very latest Redmine version and are comfortable doing manual upgrades and system administration, the following steps will guide you through installing Redmine from sources. 
14 1 Bruce Schaller
15 5 Fabián Rodríguez
1. Install the pre-requisites for Redmine and all its packages.
16 1 Bruce Schaller
17 5 Fabián Rodríguez
<pre>
18 5 Fabián Rodríguez
sudo apt install gcc build-essential zlib1g zlib1g-dev zlibc ruby-zip libssl-dev libyaml-dev \
19 5 Fabián Rodríguez
libcurl4-openssl-dev ruby gem libapache2-mod-passenger apache2 apache2-dev libapr1-dev \
20 5 Fabián Rodríguez
libxslt1-dev checkinstall libxml2-dev ruby-dev vim libmagickwand-dev imagemagick sudo rails
21 5 Fabián Rodríguez
</pre>
22 1 Bruce Schaller
23 5 Fabián Rodríguez
2.  Install your database of choice. 
24 1 Bruce Schaller
25 5 Fabián Rodríguez
<pre>
26 5 Fabián Rodríguez
apt install postgresql
27 5 Fabián Rodríguez
</pre>
28 1 Bruce Schaller
29 5 Fabián Rodríguez
3. If installing Postgres, install dev.
30 1 Bruce Schaller
31 5 Fabián Rodríguez
<pre>
32 5 Fabián Rodríguez
apt install postgresql-server-dev-9.6
33 5 Fabián Rodríguez
</pre>
34 5 Fabián Rodríguez
 
35 5 Fabián Rodríguez
4. Choose a directory where to install Redmine.  In this example /opt used.  You can use another location, but you will need to update the following steps as necessary based on your choice.
36 1 Bruce Schaller
37 5 Fabián Rodríguez
Install Redmine in /opt
38 1 Bruce Schaller
39 5 Fabián Rodríguez
<pre>
40 5 Fabián Rodríguez
cd /opt
41 5 Fabián Rodríguez
mkdir redmine
42 5 Fabián Rodríguez
cd redmine
43 5 Fabián Rodríguez
</pre>
44 1 Bruce Schaller
45 5 Fabián Rodríguez
Get Redmine  - use the "download":http://www.redmine.org/projects/redmine/wiki/Download page and review the functionality that you need to determine the right version for you. 
46 1 Bruce Schaller
47 5 Fabián Rodríguez
<pre>
48 5 Fabián Rodríguez
wget http://www.redmine.org/releases/redmine-3.4.6.tar.gz
49 5 Fabián Rodríguez
</pre>
50 1 Bruce Schaller
51 5 Fabián Rodríguez
Unpack
52 5 Fabián Rodríguez
<pre>
53 5 Fabián Rodríguez
tar xzf ./redmine-3.4.6.tar.gz
54 5 Fabián Rodríguez
</pre>
55 1 Bruce Schaller
56 5 Fabián Rodríguez
5. Login as the default postgres user and create a new role and database. Use your own password.
57 1 Bruce Schaller
58 5 Fabián Rodríguez
<pre>
59 5 Fabián Rodríguez
sudo -u postgres psql postgres
60 5 Fabián Rodríguez
CREATE ROLE redmine LOGIN ENCRYPTED PASSWORD 'your_password' NOINHERIT VALID UNTIL 'infinity';
61 5 Fabián Rodríguez
CREATE DATABASE redmine WITH ENCODING='UTF8' OWNER=redmine;
62 5 Fabián Rodríguez
</pre>
63 1 Bruce Schaller
64 5 Fabián Rodríguez
then press CTRL-D to escape the shell.
65 1 Bruce Schaller
66 5 Fabián Rodríguez
edit @/etc/postgresql/9.6/main/pg_hba.conf@ and set Postgres to trust : 
67 1 Bruce Schaller
68 5 Fabián Rodríguez
<pre>
69 5 Fabián Rodríguez
"local all postgres trust "
70 5 Fabián Rodríguez
sudo service postgresql reload 
71 5 Fabián Rodríguez
</pre>
72 1 Bruce Schaller
73 5 Fabián Rodríguez
6. Create the @/opt/redmine/redmine-3.4.6/config/database.yml@ file with the following contents…
74 1 Bruce Schaller
75 5 Fabián Rodríguez
<pre>
76 5 Fabián Rodríguez
production:
77 5 Fabián Rodríguez
  adapter: postgresql
78 5 Fabián Rodríguez
  database: redmine
79 5 Fabián Rodríguez
  host: localhost
80 5 Fabián Rodríguez
  username: redmine
81 5 Fabián Rodríguez
  password: your_password
82 5 Fabián Rodríguez
</pre>
83 1 Bruce Schaller
84 5 Fabián Rodríguez
Note that the spacing is important in this file. Under the “Production” line, each other line must be indented by two spaces, not tabs.  Replace your_password with the password specified above. Remember to save.  Keep in mind Postgresql passwords can't start with @ character (or other non alpha numerics).
85 1 Bruce Schaller
86 5 Fabián Rodríguez
7. Next, set up the database schema and load the initial database.
87 1 Bruce Schaller
88 5 Fabián Rodríguez
<pre>
89 5 Fabián Rodríguez
bundle install
90 5 Fabián Rodríguez
bundle exec rake generate_secret_token
91 5 Fabián Rodríguez
RAILS_ENV=production bundle exec rake db:migrate
92 5 Fabián Rodríguez
RAILS_ENV=production bundle exec rake redmine:load_default_data
93 5 Fabián Rodríguez
</pre>
94 1 Bruce Schaller
95 1 Bruce Schaller
8.Do a quick test to verify that redmine is working using webrick.
96 1 Bruce Schaller
97 5 Fabián Rodríguez
<pre>
98 5 Fabián Rodríguez
bundle exec ruby /usr/bin/rails server -b your_ip webrick -e production
99 5 Fabián Rodríguez
</pre>
100 1 Bruce Schaller
101 5 Fabián Rodríguez
Now try to connect via browser to @http://your_ip:3000@. Webrick is not for production systems.  It is a good way to check things before getting started with Apache, though.
102 1 Bruce Schaller
103 1 Bruce Schaller
9. Next, let’s set up Apache.
104 1 Bruce Schaller
105 5 Fabián Rodríguez
<pre>
106 5 Fabián Rodríguez
cd /opt/
107 5 Fabián Rodríguez
sudo chown -R www-data:www-data /opt/redmine
108 5 Fabián Rodríguez
cd /opt/redmine/redmine-3.4.6
109 5 Fabián Rodríguez
sudo chmod -R 755 files log tmp public/plugin_assets
110 5 Fabián Rodríguez
sudo chown www-data:www-data Gemfile.lock
111 5 Fabián Rodríguez
</pre>
112 1 Bruce Schaller
113 5 Fabián Rodríguez
9.1 Create a symbolic link which points from the Apache working directory to the Redmine public folder
114 1 Bruce Schaller
115 5 Fabián Rodríguez
<pre>
116 5 Fabián Rodríguez
sudo ln -s /opt/redmine/redmine-3.4.6/public/ /var/www/html/redmine
117 5 Fabián Rodríguez
</pre>
118 1 Bruce Schaller
119 5 Fabián Rodríguez
9.2 Create a new vhost configuration
120 1 Bruce Schaller
121 5 Fabián Rodríguez
<pre>
122 5 Fabián Rodríguez
sudo nano /etc/apache2/sites-available/master.conf
123 5 Fabián Rodríguez
</pre>
124 1 Bruce Schaller
125 5 Fabián Rodríguez
and paste in:
126 1 Bruce Schaller
127 5 Fabián Rodríguez
<pre>
128 5 Fabián Rodríguez
<VirtualHost *:80>
129 1 Bruce Schaller
130 5 Fabián Rodríguez
ServerAdmin admin@example.com
131 5 Fabián Rodríguez
Servername hostname
132 5 Fabián Rodríguez
DocumentRoot /var/www/html/
133 1 Bruce Schaller
134 5 Fabián Rodríguez
<Location /redmine>
135 5 Fabián Rodríguez
RailsEnv production
136 5 Fabián Rodríguez
RackBaseURI /redmine
137 5 Fabián Rodríguez
Options -MultiViews
138 5 Fabián Rodríguez
</Location>
139 1 Bruce Schaller
140 5 Fabián Rodríguez
</VirtualHost>
141 1 Bruce Schaller
142 5 Fabián Rodríguez
</pre>
143 3 Bruce Schaller
144 5 Fabián Rodríguez
Then, run:
145 3 Bruce Schaller
146 5 Fabián Rodríguez
<pre>
147 5 Fabián Rodríguez
sudo a2dissite 000-default.conf
148 5 Fabián Rodríguez
sudo a2ensite master.conf
149 5 Fabián Rodríguez
</pre>
150 1 Bruce Schaller
151 5 Fabián Rodríguez
9.3 add this line to @/etc/apache2/mods-available/passenger.conf@ in the body of the document- not just the 1st line.
152 1 Bruce Schaller
153 5 Fabián Rodríguez
<pre>
154 5 Fabián Rodríguez
PassengerUser www-data
155 5 Fabián Rodríguez
</pre>
156 1 Bruce Schaller
157 5 Fabián Rodríguez
Restart the Apache web server:
158 1 Bruce Schaller
159 5 Fabián Rodríguez
<pre>
160 5 Fabián Rodríguez
sudo service apache2 restart
161 5 Fabián Rodríguez
</pre>
162 1 Bruce Schaller
163 5 Fabián Rodríguez
10. Open your browser and navigate to: @http://your-ip-address/redmine@.
164 1 Bruce Schaller
165 1 Bruce Schaller
And hopefully, you're up and running.
166 1 Bruce Schaller
167 1 Bruce Schaller
Sources:
168 1 Bruce Schaller
* [[HowTo Install Redmine on Debian 8 with Apache2-Passenger|Redmine with Apache and MySQL on Debian 8 jessie]]