Using these steps you can install Redmine on Debian 8 using MySQL as database backend, nginx as web server and Unicorn as application server. Redmine will be installed at /srv/redmine/
path.
Debian 8 is the first version of Debian that is using systemd
, all other steps are the same also for older versions of Debian.
Add user account that will be used for redmine application.
useradd -m -s /bin/bash redmine
Install required packages
apt-get install curl git
curl -sSL https://rvm.io/mpapis.asc | gpg --import - curl -Lk https://get.rvm.io | bash -s stable source /etc/profile.d/rvm.sh # adds rvm to path (instead of re-logging) cd /tmp git clone https://github.com/skaes/rvm-patchsets cd /tmp/rvm-patchsets bash install.sh bash -lc '/usr/local/rvm/bin/rvm install ruby-2.1.5' bash -lc 'rvm use --default 2.1.5'
As a database will be used MySQL server.
apt-get install mysql-server
Then create dedicated user account
mysql -p
CREATE DATABASE redmine CHARACTER SET utf8; CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'Your-Secret-Password'; GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';
mkdir /srv/redmine/ mkdir /srv/redmine/run/ cd /srv/redmine/ wget http://www.redmine.org/releases/redmine-3.1.0.tar.gz tar zxvf redmine-3.1.0.tar.gz mv redmine-3.1.0 wwwroot rm redmine-3.1.0.tar.gz
cd /srv/redmine/wwwroot/config/ cp configuration.yml.example configuration.yml cp database.yml.example database.yml
now edit database.yml
file and change MySQL connection:
production: adapter: mysql2 database: redmine host: localhost username: redmine password: "Your-Secret-Password" encoding: utf8
Install dependencies:
apt-get install make gcc libxml2-dev libxslt-dev libmysql++-dev libmysqlclient-dev libmagickcore-dev libmagickwand-dev libpq-dev imagemagick ruby-dev
cd /srv/redmine/wwwroot bash -lc 'rvm 2.1.5 do gem install bundler' bash -lc 'cd /srv/redmine/wwwroot; RAILS_ENV=production rvm 2.1.5 do bundle install --without development test'
Now make sure that redmine
user can access Redmine files.
chown -R redmine:redmine /srv/redmine/
And following commands should be executed as redmine
user.
su - redmine # login as redmine user bash -lc 'cd /srv/redmine/wwwroot; RAILS_ENV=production rvm 2.1.5 do bundle exec rake generate_secret_token' bash -lc 'cd /srv/redmine/wwwroot; RAILS_ENV=production rvm 2.1.5 do bundle exec rake db:migrate' bash -lc 'cd /srv/redmine/wwwroot; RAILS_ENV=production rvm 2.1.5 do bundle exec rake redmine:load_default_data REDMINE_LANG=en' exit # logout
To enable log rotation create file /etc/logrotate.d/redmine
using this:
echo <<EOF > /etc/logrotate.d/redmine /srv/redmine/wwwroot/log/*.log { rotate 14 daily compress delaycompress copytruncate } EOF
Install unicorn server.
bash -lc 'rvm 2.1.5 do gem install unicorn'
mkdir /etc/unicorn
Add systemd init file /lib/systemd/system/unicorn.service
:
cat <<EOF > /lib/systemd/system/unicorn.service [Unit] Description=Unicorn [Service] Type=simple User=redmine WorkingDirectory=/srv/redmine/wwwroot Environment=RAILS_ENV=production PIDFile=/srv/redmine/run/unicorn.pid ExecStart=/bin/bash -lc 'rvm 2.1.5 do unicorn -D -c /etc/unicorn/redmine.rb -E production' [Install] WantedBy=multi-user.target EOF
and unicorn config file /etc/unicorn/redmine.rb
:
cat <<'EOF' > /etc/unicorn/redmine.rb worker_processes 4 stderr_path '/srv/redmine/wwwroot/log/stderr.log' stdout_path '/srv/redmine/wwwroot/log/stdout.log' listen '/srv/redmine/run/unicorn.sock' pid "/srv/redmine/run/unicorn.pid" timeout 300 preload_app true before_fork do |server, worker| Signal.trap 'TERM' do puts 'Unicorn master intercepting TERM and sending myself QUIT instead' Process.kill 'QUIT', Process.pid end defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! end after_fork do |server, worker| Signal.trap 'TERM' do puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT' end defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection end EOF
Install server:
apt-get install nginx
Add upstream configuration for Unicorn (/etc/nginx/conf.d/unicorn.conf
):
cat <<EOF > /etc/nginx/conf.d/unicorn.conf upstream unicorn { server unix:/srv/redmine/run/unicorn.sock fail_timeout=10s; } EOF
Redmine site configuration /etc/nginx/sites-available/redmine
using hostname my-redmine.company.com
cat <<'EOF' > /etc/nginx/sites-available/redmine server { listen *:80; server_name my-redmine.company.com; index index.html index.htm; access_log /var/log/nginx/redmine.access.log combined; error_log /var/log/nginx/redmine.error.log; location / { proxy_pass http://unicorn; proxy_read_timeout 90; proxy_connect_timeout 90; proxy_redirect off; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; } } EOF
and activate the site:
ln -s /etc/nginx/sites-available/redmine /etc/nginx/sites-enabled/
systemctl start unicorn.service
systemctl reload nginx.service
To access newly installed instance open web browser and access it using hostnamed configured in nginx.
During installation was created default administrator with these credentials:
Login | admin |
---|---|
Password | admin |