Redmine 6 Installation
1. Create System User and Shared Directory
sudo adduser redmineuser
sudo usermod -aG sudo redmineuser
sudo groupadd sharedgroup
sudo chown root:sharedgroup /data
sudo usermod -aG sharedgroup redmineuser
sudo chmod 2775 /data
- Creates a dedicated user for Redmine and a shared /data folder.
2. Install Required Packages
sudo apt update
sudo apt install -y \
build-essential libssl-dev libreadline-dev zlib1g-dev libmysqlclient-dev \
libmagickwand-dev imagemagick libcurl4-openssl-dev libffi-dev apache2 \
libapache2-mod-passenger mysql-server unzip git curl libgdbm-dev \
libyaml-dev libyaml-doc libpq-dev libsqlite3-dev libncurses5-dev \
libncursesw5-dev redis-server dos2unix libxapian-dev
Explanation:
· Installs development tools and libraries required to compile Ruby and gems.
· Includes database clients for MySQL/PostgreSQL/SQLite.
· Installs Redis for background job processing.
· Installs ImageMagick for file/image processing in Redmine.
· Installs Apache + Passenger (optional, for reverse proxy).
· dos2unix helps with script line endings, sometimes needed for plugins.
3. Install rbenv and Ruby 3.3.9
sudo apt install -y rbenv ruby-build
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init - bash)"' >> ~/.bashrc
source ~/.bashrc
echo 'if [ -f ~/.bashrc ]; then . ~/.bashrc; fi' >> ~/.bash_profile
mkdir -p ~/.rbenv/plugins
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
rbenv install 3.3.9
rbenv global 3.3.9
exec "$SHELL"
gem install bundler
gem update --system 3.7.1
4. Download and Prepare Redmine
cd /data
wget https://www.redmine.org/releases/redmine-6.0.6.zip
unzip redmine-6.0.6.zip
mv redmine-6.0.6 redmine
cd redmine
5. Setup PostgreSQL Database
sudo -u postgres psql
Inside PostgreSQL:
CREATE ROLE redmine LOGIN CREATEDB PASSWORD 'redminepass';
CREATE DATABASE redmine WITH ENCODING='UTF8' OWNER redmine;
CREATE DATABASE redmine_dev OWNER redmine ENCODING 'UTF8';
CREATE DATABASE redmine_test OWNER redmine ENCODING 'UTF8';
\c redmine
CREATE EXTENSION pgroonga;
\c redmine_dev
CREATE EXTENSION pgroonga;
\c redmine_test
CREATE EXTENSION pgroonga;
\q
Explanation:
· Creates a database user (redmine) with the ability to create DB’s.
· Creates production, development, and test databases.
· Enables PGroonga, which is a fast full-text search extension used by Redmine.
6. Configure Database Connection
cd /data/redmine/config
cp database.yml.example database.yml
nano database.yml
Set database credentials for production, development, and test:
production:
adapter: postgresql
database: redmine
host: localhost
username: redmine
password: "redminepass"
encoding: utf8
development:
adapter: postgresql
database: redmine_dev
host: localhost
username: redmine
password: "redminepass"
encoding: utf8
test:
adapter: postgresql
database: redmine_test
host: localhost
username: redmine
password: "redminepass"
encoding: utf8
Explanation:
- database.yml tells Redmine how to connect to the database for production, development, and test environments.
7. Install Gems and Migrate Databases
bundle install
bundle exec rake generate_secret_token
RAILS_ENV=production bundle exec rake db:migrate
RAILS_ENV=development bundle exec rake db:migrate
RAILS_ENV=test bundle exec rake db:migrate
Explanation:
- bundle install installs all Ruby dependencies (gems) required by Redmine.
- generate_secret_token creates a unique key for session security.
- db:migrate applies database schema changes for Redmine.
8. Precompile Assets and Start Rails Server
RAILS_ENV=production bundle exec rake assets:precompile
RAILS_ENV=production bundle exec rails server -b 0.0.0.0 -p 3000
· Important: This rails server command will run in the foreground.
· When you want to stop the server, press Ctrl+C.
9. Setup Required Directories and Permissions
cd /data/redmine
mkdir -p tmp tmp/pdf public/plugin_assets
sudo chown -R redmineuser:sharedgroup files log tmp public/plugin_assets
sudo chmod -R 775 files log tmp public/plugin_assets
Explanation:
- Redmine requires write permissions for directories like files, log, tmp, and plugin assets.
- Setting group ownership allows collaboration if multiple users manage Redmine.
10. Create Pids
ls /data/redmine/tmp/pids (if it do not exist)
mkdir -p /data/redmine/tmp/pids
chown redmineuser:redmineuser /data/redmine/tmp/pids
Explanation:
· When Redmine (Rails) runs, it writes PID files (process IDs) into this folder.
· If the folder doesn’t exist → Redmine crashes at startup because it can’t save that file.
11. Configure Puma (App Server)
echo "gem 'puma'" >> Gemfile
bundle install
Create /data/redmine/config/puma.rb:
#nano /data/redmine/config/puma.rb
directory '/data/redmine'
rackup "/data/redmine/config.ru"
environment 'production'
# Make sure pid folder exists BEFORE Puma starts
ExecStartPre=/bin/mkdir -p /data/redmine/tmp/pids
ExecStartPre=/bin/chown redmineuser:sharedgroup /data/redmine/tmp/pids
pidfile "/data/redmine/tmp/pids/puma.pid"
state_path "/data/redmine/tmp/pids/puma.state"
stdout_redirect "/data/redmine/log/puma.stdout.log", "/data/redmine/log/puma.stderr.log", true
threads 0, 16
workers 2
bind 'tcp://0.0.0.0:3300'
Explanation:
- Puma is a fast Ruby web server for Redmine.
- Configures logging, threads, workers, and the TCP port (3300).
mkdir -p /data/redmine/tmp/pids
12. Create Systemd Service for Puma
#nano /etc/systemd/system/redmine.service
[Unit]
Description=Redmine Puma Web Server
After=network.target
[Service]
Type=simple
User=redmineuser
WorkingDirectory=/data/redmine
ExecStart=/home/redmineuser/.rbenv/shims/bundle exec puma -C /data/redmine/config/puma.rb
ExecStop=/home/redmineuser/.rbenv/shims/bundle exec pumactl -S /data/redmine/tmp/pids/puma.state stop
Restart=on-failure
Environment=RAILS_ENV=production
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable redmine
sudo systemctl start redmine
Explanation:
- Allows Redmine to run as a background service.
- Automatically starts on boot and restarts on failure.
13. Setup Sidekiq
echo "gem 'sidekiq'" >> Gemfile
bundle install
Configure config/environments/production.rb:
# nano config/environments/production.rb
Rails.application.configure do
config.active_job.queue_adapter = :sidekiq
end
Systemd service /etc/systemd/system/sidekiq.service:
# nano /etc/systemd/system/sidekiq.service
[Unit]
Description=Sidekiq background job processor
After=network.target redis.service
[Service]
Type=simple
User=redmineuser
WorkingDirectory=/data/redmine
ExecStart=/home/redmineuser/.rbenv/shims/bundle exec sidekiq -e production
Restart=on-failure
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable sidekiq
sudo systemctl start sidekiq
Explanation:
- Sidekiq processes background jobs like email notifications, repository fetches, and scheduled tasks.
- Uses Redis as a queue backend.
14. Install Redis
sudo apt install redis-server
sudo systemctl enable redis-server
sudo systemctl start redis
redis-cli ping # should return pong
15. Configure Sendmail
sudo apt install sendmail
Edit config/environments/production.rb:
config.action_mailer.delivery_method = :sendmail
config.action_mailer.sendmail_settings = {
location: '/usr/sbin/sendmail',
arguments: '-i -t'
}
sudo service redmine restart
Allows Redmine to send email notifications.
16. Plugin Installation and Migration
RAILS_ENV=development bundle exec rake redmine:plugins:migrate
RAILS_ENV=production bundle exec rake redmine:plugins:migrate
RAILS_ENV=test bundle exec rake redmine:plugins:migrate
RAILS_ENV=production bundle exec rake redmine:plugins:assets
RAILS_ENV=production bundle exec rake assets:precompile
Optional gems:
echo "gem 'observer'" >> Gemfile
echo "gem 'slim-rails'" >> Gemfile
echo "gem 'xapian-ruby'" >> Gemfile
bundle install
Clear cache and recompile assets:
RAILS_ENV=production bundle exec rake tmp:clear tmp:cache:clear
RAILS_ENV=production bundle exec rake assets:precompile
RAILS_ENV=production bundle exec rake redmine:plugins:migrate
sudo systemctl restart redmine
sudo systemctl restart sidekiq
We can create systemd services for development and test environments even if we don’t keep them running all the time. This way:
- You can start them anytime with sudo systemctl start redmine-dev or sudo systemctl start redmine-test.
- You can stop them cleanly with sudo systemctl stop redmine-dev / redmine-test.
- Systemd will manage logs for you (journalctl -u redmine-dev), so you can check output anytime without keeping a terminal open.
17. Dev Service
Create /etc/systemd/system/redmine-dev.service:
# nano etc/systemd/system/redmine-dev.service
[Unit]
Description=Redmine Development Environment
After=network.target
[Service]
Type=simple
User=redmineuser
WorkingDirectory=/data/redmine
ExecStart=/home/redmineuser/.rbenv/shims/bundle exec rails server -e development -b 0.0.0.0 -p 4000
Restart=on-failure
StandardOutput=append:/data/redmine/log/redmine-dev.stdout.log
StandardError=append:/data/redmine/log/redmine-dev.stderr.log
[Install]
WantedBy=multi-user.target
sudo mkdir -p /data/redmine/log
sudo systemctl daemon-reload
sudo systemctl enable redmine-dev # optional, can start manually
sudo systemctl start redmine-dev
· Logs will go to /data/redmine/log/redmine-dev.stdout.log and redmine-dev.stderr.log.
· Stop with: sudo systemctl stop redmine-dev.
· View logs: tail -f /data/redmine/log/redmine-dev.stdout.log.
18. Test Service
Create /etc/systemd/system/redmine-test.service:
# nano /etc/systemd/system/redmine-test.service
[Unit]
Description=Redmine Test Environment
After=network.target
[Service]
Type=simple
User=redmineuser
WorkingDirectory=/data/redmine
ExecStart=/home/redmineuser/.rbenv/shims/bundle exec rails server -e test -b 0.0.0.0 -p 5000
Restart=on-failure
StandardOutput=append:/data/redmine/log/redmine-test.stdout.log
StandardError=append:/data/redmine/log/redmine-test.stderr.log
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable redmine-test # optional, can start manually
sudo systemctl start redmine-test
· Logs at /data/redmine/log/redmine-test.stdout.log and redmine-test.stderr.log.
· Stop with: sudo systemctl stop redmine-test.
No comments:
Post a Comment