Toto je starší verze dokumentu!
Obsah
Installation of Redmine on Debian 8 (Jessie)
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.
1. System settings
Add user account that will be used for redmine application.
useradd -m -s /bin/bash redmine
2. RVM
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'
3. Database
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';
4. Redmine
Download
mkdir /srv/redmine/ 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
Configure
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: root password: "Your-Secret-Password" encoding: utf8
Install
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 ${easyredmine::install_dir}; RAILS_ENV=production rvm ${easyredmine::ruby_version} do bundle install --without development test bash -lc cd ${easyredmine::install_dir}; RAILS_ENV=production rvm ${easyredmine::ruby_version} do bundle exec rake generate_secret_token bash -lc RAILS_ENV=production cd ${easyredmine::install_dir}; rvm ${easyredmine::ruby_version} do bundle exec rake db:migrate bash -lc cd ${easyredmine::install_dir}; rvm ${easyredmine::ruby_version} do bundle exec rake redmine:load_default_data RAILS_ENV=production REDMINE_LANG=en
chown -R redmine:redmine /srv/redmine/
Configure log rotation:
echo <<EOF > /etc/logrotate.d/redmine /srv/redmine/wwwroot/log/*.log { rotate 14 daily compress delaycompress copytruncate }
5. 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
6. Nginx
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
:
cat <<EOF > /etc/nginx/sites-available/redmine server { listen *:80; server_name redmine; 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; } }
and activate the site:
ln -s /etc/nginx/sites-enables/redmine /etc/nginx/sites-available/redmine