Install Redmine on Fedora » History » Version 3

Gerd Pokorra, 2019-01-04 11:05

1 1 Gerd Pokorra
h1. HowTo Install Redmine 4.0.0 on Fedora 29
2 1 Gerd Pokorra
3 1 Gerd Pokorra
{{toc}}
4 1 Gerd Pokorra
5 1 Gerd Pokorra
h2.  System Requirements
6 1 Gerd Pokorra
7 1 Gerd Pokorra
It is assumed that the Server Edition is installed on the system in this guide.
8 1 Gerd Pokorra
9 1 Gerd Pokorra
h3. Updating the System
10 1 Gerd Pokorra
  
11 1 Gerd Pokorra
It is recommended to install Redmine on an update system. To ensure that all installed packages are up-to-date issue the following command:
12 1 Gerd Pokorra
13 1 Gerd Pokorra
<pre>> dnf update
14 1 Gerd Pokorra
</pre>
15 1 Gerd Pokorra
16 1 Gerd Pokorra
h3. Installing Dependencies
17 1 Gerd Pokorra
18 1 Gerd Pokorra
A number of dependencies need to be installed:
19 1 Gerd Pokorra
20 1 Gerd Pokorra
<pre>> dnf install rubygem-bundler
21 1 Gerd Pokorra
> dnf install rubygem-rails
22 1 Gerd Pokorra
23 1 Gerd Pokorra
> dnf install ruby-devel rubygem-rmagick
24 1 Gerd Pokorra
> dnf install gcc redhat-rpm-config
25 1 Gerd Pokorra
26 1 Gerd Pokorra
> dnf groupinstall "C Development Tools and Libraries"
27 1 Gerd Pokorra
> dnf groupinstall "Development Tools"
28 1 Gerd Pokorra
</pre>
29 1 Gerd Pokorra
30 1 Gerd Pokorra
Database adapter for PostgreSQL:
31 1 Gerd Pokorra
  
32 1 Gerd Pokorra
<pre>> dnf install rubygem-pg
33 1 Gerd Pokorra
</pre>
34 1 Gerd Pokorra
35 1 Gerd Pokorra
Database adapter for MySQL:
36 1 Gerd Pokorra
<pre>> dnf install rubygem-mysql2
37 1 Gerd Pokorra
</pre>
38 1 Gerd Pokorra
39 1 Gerd Pokorra
Database adapter for MS SQL:
40 1 Gerd Pokorra
41 1 Gerd Pokorra
The Fedora distribution has no ruby software package for @tiny_tds@. The following dependency is needed for the build:
42 1 Gerd Pokorra
43 1 Gerd Pokorra
<pre>> dnf install freetds-devel
44 1 Gerd Pokorra
> # Now the build should work
45 1 Gerd Pokorra
> bundle install --without development test
46 1 Gerd Pokorra
</pre>
47 1 Gerd Pokorra
48 1 Gerd Pokorra
49 1 Gerd Pokorra
50 1 Gerd Pokorra
The list of dependencies may not complete. Problems of the installation or build of a compoment can be solved by installing the necessary dependency.
51 1 Gerd Pokorra
52 1 Gerd Pokorra
h2. Step 1 - Obtaining Redmine
53 1 Gerd Pokorra
54 1 Gerd Pokorra
Get the Redmine source code by downloading the packaged release.
55 1 Gerd Pokorra
56 1 Gerd Pokorra
<pre>> dnf install wget
57 1 Gerd Pokorra
58 1 Gerd Pokorra
> mkdir /var/www
59 1 Gerd Pokorra
> cd /var/www
60 1 Gerd Pokorra
61 1 Gerd Pokorra
> wget http://www.redmine.org/releases/redmine-4.0.0.tar.gz
62 1 Gerd Pokorra
> tar xf redmine-4.0.0.tar.gz
63 1 Gerd Pokorra
</pre>
64 1 Gerd Pokorra
65 1 Gerd Pokorra
At this guide is accepted that the location of the Redmine source code is:
66 1 Gerd Pokorra
67 1 Gerd Pokorra
<pre>/var/www/redmine-4.0.0
68 1 Gerd Pokorra
</pre>
69 1 Gerd Pokorra
70 1 Gerd Pokorra
For example the nginx configuration refer to the path @/var/www/redmine-4.0.0@.
71 1 Gerd Pokorra
72 1 Gerd Pokorra
h2. Setp 2 - Setup a local database
73 1 Gerd Pokorra
74 1 Gerd Pokorra
This section discribes the setup of a database server that will be configured to allow access from the localhost.
75 1 Gerd Pokorra
76 1 Gerd Pokorra
h3. PostgreSQL
77 1 Gerd Pokorra
78 1 Gerd Pokorra
The followings commands are for installing the packages, initializing the database, enable and start the postgresql server, switch the user to interact with @postgres@, create an empty database and accompanying user.
79 1 Gerd Pokorra
80 1 Gerd Pokorra
<pre>> dnf install postgresql-server postgresql-contrib
81 1 Gerd Pokorra
> postgresql-setup --initdb --unit postgresql
82 1 Gerd Pokorra
 * Initializing database in '/var/lib/pgsql/data'
83 1 Gerd Pokorra
 * Initialized, logs are in /var/lib/pgsql/initdb_postgresql.log
84 1 Gerd Pokorra
>
85 1 Gerd Pokorra
> systemctl enable postgresql
86 1 Gerd Pokorra
> systemctl start postgresql
87 1 Gerd Pokorra
> su - postgres
88 1 Gerd Pokorra
> psql
89 1 Gerd Pokorra
psql (10.6)
90 1 Gerd Pokorra
Type "help" for help.
91 1 Gerd Pokorra
92 1 Gerd Pokorra
postgres=# CREATE ROLE redmine LOGIN ENCRYPTED PASSWORD 'my_secret' NOINHERIT VALID UNTIL 'infinity';
93 1 Gerd Pokorra
CREATE ROLE
94 1 Gerd Pokorra
postgres=# CREATE DATABASE redmine WITH ENCODING='UTF8' OWNER=redmine;
95 1 Gerd Pokorra
CREATE DATABASE
96 1 Gerd Pokorra
postgres=# \q
97 1 Gerd Pokorra
> exit
98 1 Gerd Pokorra
</pre>
99 1 Gerd Pokorra
100 1 Gerd Pokorra
Edit the file @/var/lib/pgsql/data/pg_hba.conf@ to specify that the client has to supply password processed with MD5 algorithm:
101 1 Gerd Pokorra
102 1 Gerd Pokorra
<pre>#host    all             all             127.0.0.1/32            ident
103 1 Gerd Pokorra
host    all             all             127.0.0.1/32            md5
104 1 Gerd Pokorra
# IPv6 local connections:
105 1 Gerd Pokorra
#host    all             all             ::1/128                 ident
106 1 Gerd Pokorra
host    all             all             ::1/128                 md5
107 1 Gerd Pokorra
</pre>
108 1 Gerd Pokorra
109 1 Gerd Pokorra
You can check the access with the following command:
110 1 Gerd Pokorra
111 1 Gerd Pokorra
<pre>> su - postgres
112 1 Gerd Pokorra
> psql -h localhost -U redmine redmine
113 1 Gerd Pokorra
</pre>
114 1 Gerd Pokorra
115 1 Gerd Pokorra
The appropriate Redmine database configuration file for local access is:
116 1 Gerd Pokorra
117 1 Gerd Pokorra
<pre>> cat /var/www/redmine-4.0.0/config/database.yml
118 1 Gerd Pokorra
# PostgreSQL configuration
119 1 Gerd Pokorra
production:
120 1 Gerd Pokorra
  adapter: postgresql
121 1 Gerd Pokorra
  database: redmine
122 1 Gerd Pokorra
  host: localhost
123 1 Gerd Pokorra
  username: redmine
124 1 Gerd Pokorra
  password: "my_secret"
125 1 Gerd Pokorra
  encoding: utf8
126 1 Gerd Pokorra
  schema_search_path: public
127 1 Gerd Pokorra
</pre>
128 1 Gerd Pokorra
129 1 Gerd Pokorra
If you want to use IPv4 you have to specify @localhost4@ as hostname.
130 1 Gerd Pokorra
131 1 Gerd Pokorra
h3. MySQL
132 1 Gerd Pokorra
133 1 Gerd Pokorra
Install the MySQL repositry
134 1 Gerd Pokorra
135 1 Gerd Pokorra
<pre>> dnf -y install https://dev.mysql.com/get/mysql80-community-release-fc29-1.noarch.rpm
136 1 Gerd Pokorra
</pre>
137 1 Gerd Pokorra
138 1 Gerd Pokorra
If you prefer to stick to MySQL 5.7
139 1 Gerd Pokorra
140 1 Gerd Pokorra
<pre>> dnf config-manager --set-enabled mysql57-community
141 1 Gerd Pokorra
> dnf config-manager --set-disabled mysql80-community
142 1 Gerd Pokorra
</pre>
143 1 Gerd Pokorra
144 1 Gerd Pokorra
Install the MySQL server package, start the MySQL server and autostart the daemon on boot
145 1 Gerd Pokorra
146 1 Gerd Pokorra
<pre>> dnf -y install mysql-community-server
147 1 Gerd Pokorra
> systemctl start mysqld.service
148 1 Gerd Pokorra
> systemctl enable mysqld.service
149 1 Gerd Pokorra
</pre>
150 1 Gerd Pokorra
151 1 Gerd Pokorra
Get your generated random root password you will need it at the next step.
152 1 Gerd Pokorra
153 1 Gerd Pokorra
<pre>> grep 'A temporary password is generated for root@localhost' /var/log/mysqld.log |tail -1
154 1 Gerd Pokorra
</pre>
155 1 Gerd Pokorra
156 1 Gerd Pokorra
Start the secure installation assistant to
157 1 Gerd Pokorra
158 1 Gerd Pokorra
* change root password
159 1 Gerd Pokorra
* remove anonymous users
160 1 Gerd Pokorra
* disallow root login remotely
161 1 Gerd Pokorra
* remove test database and access to it
162 1 Gerd Pokorra
* reload privilege tables
163 1 Gerd Pokorra
164 1 Gerd Pokorra
<pre>> mysql_secure_installation
165 1 Gerd Pokorra
</pre>
166 1 Gerd Pokorra
167 1 Gerd Pokorra
Creation of user and database for Redmine
168 1 Gerd Pokorra
169 1 Gerd Pokorra
<pre>> mysql -h localhost -u root -p
170 1 Gerd Pokorra
Enter password:
171 1 Gerd Pokorra
...
172 1 Gerd Pokorra
mysql> CREATE DATABASE redmine CHARACTER SET utf8mb4;
173 1 Gerd Pokorra
mysql> CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'my_secret';
174 1 Gerd Pokorra
mysql> GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';
175 1 Gerd Pokorra
mysql> \q
176 1 Gerd Pokorra
</pre>
177 1 Gerd Pokorra
178 1 Gerd Pokorra
The appropriate Redmine database configuration file for local accessing the MySQL database is:
179 1 Gerd Pokorra
180 1 Gerd Pokorra
<pre>> cat /var/www/redmine-4.0.0/config/database.yml
181 1 Gerd Pokorra
# MySQL configuration
182 1 Gerd Pokorra
production:
183 1 Gerd Pokorra
  adapter: mysql2
184 1 Gerd Pokorra
  database: redmine
185 1 Gerd Pokorra
  host: localhost
186 1 Gerd Pokorra
  username: redmine
187 1 Gerd Pokorra
  password: "my_secret"
188 1 Gerd Pokorra
</pre>
189 1 Gerd Pokorra
190 1 Gerd Pokorra
h2. Step 3 to Step 9
191 1 Gerd Pokorra
192 1 Gerd Pokorra
For Step 3 to Step 9 follow the [[RedmineInstall#Step-3-Database-connection-configuration|generic installation instructions]]. Following is the overview of the commands:
193 1 Gerd Pokorra
194 1 Gerd Pokorra
<pre>> bundle install --without development test
195 1 Gerd Pokorra
> bundle exec rake generate_secret_token
196 1 Gerd Pokorra
> RAILS_ENV=production bundle exec rake db:migrate
197 1 Gerd Pokorra
> RAILS_ENV=production bundle exec rake redmine:load_default_data
198 1 Gerd Pokorra
199 1 Gerd Pokorra
> mkdir -p tmp tmp/pdf public/plugin_assets
200 1 Gerd Pokorra
> chown -R redmine:redmine files log tmp public/plugin_assets
201 1 Gerd Pokorra
> chmod -R 755 files log tmp public/plugin_assets
202 1 Gerd Pokorra
203 1 Gerd Pokorra
> find files log tmp public/plugin_assets -type f -exec chmod -x {} +
204 1 Gerd Pokorra
205 1 Gerd Pokorra
> bundle exec rails server webrick -e production
206 1 Gerd Pokorra
</pre>
207 1 Gerd Pokorra
208 1 Gerd Pokorra
* Tip:
209 1 Gerd Pokorra
210 1 Gerd Pokorra
> Over one ssh-tunnel you can easily connect to Port 3000 of the WEBrick web server.
211 1 Gerd Pokorra
> 
212 1 Gerd Pokorra
> <pre>> ssh root@<redmine-host.domain> -L 3000:localhost:3000</pre>
213 1 Gerd Pokorra
> 
214 1 Gerd Pokorra
> Open the local webbrower to show the URL 'http://localhost:3000':
215 1 Gerd Pokorra
> 
216 1 Gerd Pokorra
> <pre>> firefox localhost:3000</pre>
217 1 Gerd Pokorra
218 1 Gerd Pokorra
h2. Firewall
219 1 Gerd Pokorra
220 1 Gerd Pokorra
Open the firewall for https:
221 1 Gerd Pokorra
222 1 Gerd Pokorra
<pre>> firewall-cmd --add-service=https
223 1 Gerd Pokorra
> firewall-cmd --permanent --add-service=https
224 1 Gerd Pokorra
</pre>
225 1 Gerd Pokorra
226 1 Gerd Pokorra
h2. Web Server
227 1 Gerd Pokorra
228 1 Gerd Pokorra
h3. Nginx/Passenger
229 1 Gerd Pokorra
230 1 Gerd Pokorra
The Fedora @nginx@ package do not include Passenger, so you have to build @nginx@ with the passenger module. The guide assume that the sources are extracted under the directory @/opt@ . The @nginx@ software will be installed at @/opt/ngnix@. At the time of writting that guide this was the current stable releases of @passenger@ and @nginx@:
231 1 Gerd Pokorra
232 1 Gerd Pokorra
* passenger-6.0.0
233 1 Gerd Pokorra
* nginx-1.14.2
234 1 Gerd Pokorra
235 1 Gerd Pokorra
h4. Downloading the sources:
236 1 Gerd Pokorra
237 1 Gerd Pokorra
<pre>Passenger
238 1 Gerd Pokorra
239 1 Gerd Pokorra
> cd /opt
240 1 Gerd Pokorra
> wget https://s3.amazonaws.com/phusion-passenger/releases/passenger-6.0.0.tar.gz
241 1 Gerd Pokorra
> tar xf passenger-6.0.0.tar.gz
242 1 Gerd Pokorra
243 1 Gerd Pokorra
Nginx
244 1 Gerd Pokorra
245 1 Gerd Pokorra
> wget http://nginx.org/download/nginx-1.14.2.tar.gz
246 1 Gerd Pokorra
> mkdir /opt/src
247 1 Gerd Pokorra
> cd /opt/src
248 1 Gerd Pokorra
> tar xf nginx-1.14.2.tar.gz
249 1 Gerd Pokorra
</pre>
250 1 Gerd Pokorra
251 1 Gerd Pokorra
h4. Installing additional packages
252 1 Gerd Pokorra
253 1 Gerd Pokorra
For the build of @passenger@ and @nginx@ the following additional packages are needed to be installed:
254 1 Gerd Pokorra
255 1 Gerd Pokorra
<pre>> dnf install install gcc-c++ libcurl-devel openssl-devel zlib-devel
256 1 Gerd Pokorra
</pre>
257 1 Gerd Pokorra
258 1 Gerd Pokorra
h4. Execute the ruby script for building and installing
259 1 Gerd Pokorra
260 1 Gerd Pokorra
The simplest way to build and install the @nginx@ web server with the @passenger@ module is to run the script @passenger-install-nginx-module@.
261 1 Gerd Pokorra
262 1 Gerd Pokorra
<pre>> /opt/passenger-6.0.0/bin
263 1 Gerd Pokorra
> ./passenger-install-nginx-module --prefix=/opt/nginx --nginx-source-dir=/opt/src/nginx-1.14.2 --languages ruby
264 1 Gerd Pokorra
</pre>
265 1 Gerd Pokorra
266 1 Gerd Pokorra
With the same @passenger@ locality the installer modify the @nginx@ configuration file @/opt/nginx/conf/nginx.conf@ and output the same text:
267 1 Gerd Pokorra
268 1 Gerd Pokorra
<pre>  http {
269 1 Gerd Pokorra
      ...
270 1 Gerd Pokorra
      passenger_root /opt/passenger-6.0.0;
271 1 Gerd Pokorra
      passenger_ruby /usr/bin/ruby;
272 1 Gerd Pokorra
      ...
273 1 Gerd Pokorra
  }
274 1 Gerd Pokorra
</pre>
275 1 Gerd Pokorra
276 1 Gerd Pokorra
h4. Add a systemd service file
277 1 Gerd Pokorra
278 1 Gerd Pokorra
To start the @nginx@ process during the boot add the file @/usr/lib/systemd/system/nginx.service@ with the following content:
279 1 Gerd Pokorra
280 1 Gerd Pokorra
<pre>[Unit]
281 1 Gerd Pokorra
Description=The nginx HTTP and reverse proxy server
282 1 Gerd Pokorra
After=network.target remote-fs.target nss-lookup.target
283 1 Gerd Pokorra
284 1 Gerd Pokorra
[Service]
285 1 Gerd Pokorra
Type=forking
286 1 Gerd Pokorra
#PIDFile=/run/nginx.pid
287 1 Gerd Pokorra
PIDFile=/opt/nginx/logs/nginx.pid
288 1 Gerd Pokorra
# Nginx will fail to start if /run/nginx.pid already exists but has the wrong
289 1 Gerd Pokorra
# SELinux context. This might happen when running `nginx -t` from the cmdline.
290 1 Gerd Pokorra
# https://bugzilla.redhat.com/show_bug.cgi?id=1268621
291 1 Gerd Pokorra
ExecStartPre=/usr/bin/rm -f /opt/nginx/logs/nginx.pid
292 1 Gerd Pokorra
#ExecStartPre=/usr/sbin/nginx -t
293 1 Gerd Pokorra
#ExecStart=/usr/sbin/nginx
294 1 Gerd Pokorra
ExecStartPre=/opt/nginx/sbin/nginx -t
295 1 Gerd Pokorra
ExecStart=/opt/nginx/sbin/nginx -c /opt/nginx/conf/nginx.conf
296 1 Gerd Pokorra
ExecReload=/bin/kill -s HUP $MAINPID
297 1 Gerd Pokorra
KillSignal=SIGQUIT
298 1 Gerd Pokorra
TimeoutStopSec=5
299 1 Gerd Pokorra
KillMode=mixed
300 1 Gerd Pokorra
PrivateTmp=true
301 1 Gerd Pokorra
302 1 Gerd Pokorra
[Install]
303 1 Gerd Pokorra
WantedBy=multi-user.target
304 1 Gerd Pokorra
</pre>
305 1 Gerd Pokorra
306 1 Gerd Pokorra
The paths are modified to start the executable @/opt/nginx/sbin/nginx@.
307 1 Gerd Pokorra
308 1 Gerd Pokorra
<pre>> systemctl start nginx
309 1 Gerd Pokorra
> systemctl enable nginx
310 1 Gerd Pokorra
</pre>
311 1 Gerd Pokorra
312 1 Gerd Pokorra
h4. Nginx Configuration
313 1 Gerd Pokorra
314 1 Gerd Pokorra
For http add the two lines and comment out the four lines:
315 1 Gerd Pokorra
316 1 Gerd Pokorra
<pre>    server {
317 1 Gerd Pokorra
        listen       80;
318 1 Gerd Pokorra
...
319 1 Gerd Pokorra
        root         /var/www/redmine-4.0.0/public;
320 1 Gerd Pokorra
        passenger_enabled on;
321 1 Gerd Pokorra
        #location / {
322 1 Gerd Pokorra
        #    root   html;
323 1 Gerd Pokorra
        #    index  index.html index.htm;
324 1 Gerd Pokorra
        #}
325 1 Gerd Pokorra
...
326 1 Gerd Pokorra
       }
327 1 Gerd Pokorra
</pre>
328 1 Gerd Pokorra
329 1 Gerd Pokorra
For https add you can use lines like this:
330 1 Gerd Pokorra
331 1 Gerd Pokorra
<pre>    # HTTPS server
332 1 Gerd Pokorra
    #
333 1 Gerd Pokorra
    server {
334 1 Gerd Pokorra
        listen       443 ssl;
335 1 Gerd Pokorra
        server_name  my_web_serv.domain;
336 1 Gerd Pokorra
337 1 Gerd Pokorra
        ssl_certificate      /etc/ssl/certs/my_web_serv.pem;
338 1 Gerd Pokorra
        ssl_certificate_key  /etc/ssl/private/privkey.pem;
339 1 Gerd Pokorra
340 1 Gerd Pokorra
        root         /var/www/redmine-4.0.0/public;
341 1 Gerd Pokorra
        passenger_enabled on;
342 1 Gerd Pokorra
    }
343 1 Gerd Pokorra
</pre>
344 1 Gerd Pokorra
345 1 Gerd Pokorra
h3. Apache
346 2 Gerd Pokorra
347 2 Gerd Pokorra
<pre>> gem install passenger
348 2 Gerd Pokorra
> dnf install apr-util-devel openssl-devel httpd-devel libcurl-devel
349 2 Gerd Pokorra
350 2 Gerd Pokorra
> /usr/local/bin/passenger-install-apache2-module</pre>