Deploy Redmine on Debian12

2024-08-25 infra Redmine

環境

  • OS: Debain 12
  • DB:
    • 10.192.1.105
    • redmine_db

安裝步驟

sudo apt install -y gnupg2
sudo gpg2 --keyserver hkp://keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable
sudo apt -y install ruby-full build-essential libpq-dev
wget https://www.redmine.org/releases/redmine-5.1.3.tar.gz
sudo tar -zxf redmine-5.1.3.tar.gz -C /opt/
cd /opt/
sudo ln -s redmine-5.1.3 redmine
cd /opt/redmine
sudo cp /opt/redmine/config/configuration.yml{.example,}
sudo cp /opt/redmine/public/dispatch.fcgi{.example,}
sudo cp /opt/redmine/config/database.yml{.example,}
  • config/database.yml
production:
  adapter: postgresql
  database: redmine_db
  host: 127.0.0.1
  username: username
  password: "password"
sudo gem install bundler
useradd --system --home /opt/redmine -c "Redmine System account" -s /bin/bash redmine
chown -R redmine: /opt/redmine*
sudo su - redmine
bundle config set --local path 'vendor/bundle'
bundle install
bundle update
gem install io-wait strscan webrick --user-install
bundle exec rake generate_secret_token
RAILS_ENV=production bundle exec rake db:migrate
RAILS_ENV=production REDMINE_LANG=zh-TW bundle exec rake redmine:load_default_data
cd ~
for i in tmp tmp/pdf public/plugin_assets; do [ -d $i ] || mkdir -p $i; done
echo 'gem "webrick"' >> Gemfile
bundle install
# 測試運作
bundle exec rails server -u webrick -e production
  • /etc/systemd/system/redmine.service
[Unit]
Description=Redmine Webserver

[Service]
Type=simple
User=deploy
WorkingDirectory=/opt/redmine
ExecStart=/bin/bash -lc 'bundle exec rails server -e production'
TimeoutSec=15
Restart=always

User=redmine
Group=redmine
UMask=0027
RestartSec=10
Restart=always

[Install]
WantedBy=multi-user.target
sudo firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv4" source address="10.192.1.108" port protocol="tcp" port="3000" accept'
  • nginx
upstream redmine {
    server 127.0.0.1:3000;
}
server {
    listen       80;

    root /opt/redmine/public;

    location ~ /redmine/(stylesheets|javascripts|images|favicon)(.*)$
    {
        proxy_pass http://app/$1$2;
    }

    location /redmine {
        proxy_pass  http://redmine;
    }

    location @redmine {
        proxy_pass http://redmine;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
    }
}

設定LDAP

sudo apt install -y libldap2-dev
systemctl stop redmine
sudo su - redmine
bundle install --without development test

plugin

add_date_formats_with_day_names

參考資料