HowTo Install Redmine on Debian 9 » History » Version 1

Bruce Schaller, 2017-09-09 05:57

1 1 Bruce Schaller
1. Install the pre-requisites for redmine and all its packages.
2 1 Bruce Schaller
3 1 Bruce Schaller
> apt install gcc build-essential zlib1g zlib1g-dev zlibc ruby-zip libssl-dev libyaml-dev libcurl4-openssl-dev ruby gem libapache2-mod-passenger apache2 apache2-dev libapr1-dev libxslt1-dev checkinstall libxml2-dev ruby-dev vim libmagickwand-dev imagemagick sudo rails
4 1 Bruce Schaller
> 
5 1 Bruce Schaller
2.  Install your database of choice.
6 1 Bruce Schaller
7 1 Bruce Schaller
> apt install postgresql
8 1 Bruce Schaller
9 1 Bruce Schaller
3. If installing postgres, install dev.  Use the version number installed in the previous step.
10 1 Bruce Schaller
11 1 Bruce Schaller
> apt install postgresql-server-dev-* (See version in step 2 during install)
12 1 Bruce Schaller
 
13 1 Bruce Schaller
4. Choose a directory where to install redmine.  I used /opt.  You can use wherever you like, but you will need to update the following steps as necessary based on your desired install location.
14 1 Bruce Schaller
15 1 Bruce Schaller
Install redmine in /opt
16 1 Bruce Schaller
17 1 Bruce Schaller
> cd /opt
18 1 Bruce Schaller
19 1 Bruce Schaller
> mkdir redmine
20 1 Bruce Schaller
21 1 Bruce Schaller
> cd redmine
22 1 Bruce Schaller
23 1 Bruce Schaller
Get redmine  - use the download page and review the functionality that you need to determine the right version for you.  I wanted DMSF, which is not yet compatible with the latest version.  If in doubt, check it out!
24 1 Bruce Schaller
25 1 Bruce Schaller
> wget http://www.redmine.org/releases/redmine-3.3.4.tar.gz
26 1 Bruce Schaller
27 1 Bruce Schaller
Unpack
28 1 Bruce Schaller
> tar xzf ./redmine-3.3.4.tar.gz
29 1 Bruce Schaller
30 1 Bruce Schaller
5. Login as the default postgres user and create a new role and database. Use your own password )).
31 1 Bruce Schaller
> sudo -u postgres psql postgres
32 1 Bruce Schaller
33 1 Bruce Schaller
> CREATE ROLE redmine LOGIN ENCRYPTED PASSWORD 'your_password' NOINHERIT VALID UNTIL 'infinity';
34 1 Bruce Schaller
35 1 Bruce Schaller
> CREATE DATABASE redmine WITH ENCODING='UTF8' OWNER=redmine;
36 1 Bruce Schaller
37 1 Bruce Schaller
then press CTRL-D to escape the shell.
38 1 Bruce Schaller
39 1 Bruce Schaller
edit /etc/postgresql/9.6/main/pg_hba.conf and set postgres to trust : 
40 1 Bruce Schaller
41 1 Bruce Schaller
> "local all postgres trust “
42 1 Bruce Schaller
> sudo service postgresql reload 
43 1 Bruce Schaller
44 1 Bruce Schaller
6. Create the /opt/redmine/redmine-3.3.4/config/database.yml file with the following contents…
45 1 Bruce Schaller
46 1 Bruce Schaller
> production:
47 1 Bruce Schaller
> >   adapter: postgresql
48 1 Bruce Schaller
> >   database: redmine
49 1 Bruce Schaller
> >   host: localhost
50 1 Bruce Schaller
> >   username: redmine
51 1 Bruce Schaller
> >   password: your_password
52 1 Bruce Schaller
> 
53 1 Bruce Schaller
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.  Seriously, don’t use your_password…. Remeber to save!
54 1 Bruce Schaller
55 1 Bruce Schaller
7. Next, set up the database schema and load the initial database.
56 1 Bruce Schaller
57 1 Bruce Schaller
> bundle exec rake generate_secret_token
58 1 Bruce Schaller
59 1 Bruce Schaller
> RAILS_ENV=production bundle exec rake db:migrate
60 1 Bruce Schaller
61 1 Bruce Schaller
> RAILS_ENV=production bundle exec rake redmine:load_default_data
62 1 Bruce Schaller
63 1 Bruce Schaller
8.Do a quick test to verify that redmine is working using webrick.
64 1 Bruce Schaller
65 1 Bruce Schaller
> bundle exec ruby /usr/bin/rails server -b your_ip webrick -e production
66 1 Bruce Schaller
67 1 Bruce Schaller
And try to connect via browser to your ip:3000. Webrick is not for production systems.  It is a good way to check things before getting started with Apache, though.
68 1 Bruce Schaller
69 1 Bruce Schaller
9. Next, let’s set up Apache.
70 1 Bruce Schaller
71 1 Bruce Schaller
> cd /opt/
72 1 Bruce Schaller
73 1 Bruce Schaller
> sudo chown -R www-data:www-data /opt/redmine
74 1 Bruce Schaller
75 1 Bruce Schaller
> cd /opt/redmine/redmine-3.3.4
76 1 Bruce Schaller
77 1 Bruce Schaller
> sudo chmod -R 755 files log tmp public/plugin_assets
78 1 Bruce Schaller
79 1 Bruce Schaller
> sudo chown www-data:www-data Gemfile.lock
80 1 Bruce Schaller
81 1 Bruce Schaller
9.1 Create a symbolic link which points from the working directory of apache to the redmine public folder…
82 1 Bruce Schaller
83 1 Bruce Schaller
> sudo ln -s /opt/redmine/redmine-3.3.4/public/ /var/www/html/redmine
84 1 Bruce Schaller
85 1 Bruce Schaller
9.2 Need to create a new vhost configuration…
86 1 Bruce Schaller
87 1 Bruce Schaller
> sudo nano /etc/apache2/sites-available/master.conf
88 1 Bruce Schaller
89 1 Bruce Schaller
and paste in….
90 1 Bruce Schaller
91 1 Bruce Schaller
> <VirtualHost *:80>
92 1 Bruce Schaller
> 
93 1 Bruce Schaller
> ServerAdmin admin@example.com
94 1 Bruce Schaller
> Servername hostname
95 1 Bruce Schaller
> DocumentRoot /var/www/html/
96 1 Bruce Schaller
> 
97 1 Bruce Schaller
> <Location /redmine>
98 1 Bruce Schaller
> RailsEnv production
99 1 Bruce Schaller
> RackBaseURI /redmine
100 1 Bruce Schaller
> Options -MultiViews
101 1 Bruce Schaller
> </Location>
102 1 Bruce Schaller
> 
103 1 Bruce Schaller
> </VirtualHost>
104 1 Bruce Schaller
105 1 Bruce Schaller
Then, run….
106 1 Bruce Schaller
107 1 Bruce Schaller
> sudo a2dissite 000-default.conf
108 1 Bruce Schaller
109 1 Bruce Schaller
> sudo a2ensite master.conf
110 1 Bruce Schaller
111 1 Bruce Schaller
9.3 add this line to /etc/apache2/mods-available/passenger.conf…. in the body of the document- not just the 1st line.
112 1 Bruce Schaller
113 1 Bruce Schaller
> PassengerUser www-data
114 1 Bruce Schaller
115 1 Bruce Schaller
run…
116 1 Bruce Schaller
117 1 Bruce Schaller
> sudo service apache2 restart
118 1 Bruce Schaller
119 1 Bruce Schaller
10. Open your browser and navigate to: http://your-ip-address/redmine
120 1 Bruce Schaller
121 1 Bruce Schaller
And hopefully, you're up and running.