Jul 16, 2024 3 min read

Redmine: The Full Guide to Self-Hosting Anywhere

Redmine: The Full Guide to Self-Hosting Anywhere
Table of Contents

Redmine is a powerful, flexible, and open-source project management and issue-tracking tool that is perfect for self-hosting. It offers extensive customization, giving users full control over their data, while providing key features like Gantt charts, time tracking, and a robust plugin ecosystem. This guide will walk you through installing, configuring, securing, and managing Redmine, whether you’re deploying it via Docker or manually on a Linux server.

Installing Redmine

πŸ“¦ Docker/Docker Compose Setup

To deploy Redmine using Docker, create a docker-compose.yml file to define the application’s services, volumes, and ports. Here’s a sample setup:


version: '3.9'

services:

redmine:

image: redmine:latest

container_name: redmine

environment:

REDMINE_DB_MYSQL: redmine_db

REDMINE_DB_PASSWORD: secretpassword

REDMINE_DB_USERNAME: redmine_user

ports:

- "3000:3000"

volumes:

- redmine_data:/usr/src/redmine/files

depends_on:

- mysql

mysql:

image: mysql:5.7

container_name: redmine_db

environment:

MYSQL_ROOT_PASSWORD: rootpassword

MYSQL_DATABASE: redmine_db

MYSQL_USER: redmine_user

MYSQL_PASSWORD: secretpassword

volumes:

- mysql_data:/var/lib/mysql

volumes:

redmine_data:

mysql_data:

Deploy the application using the following commands:


docker-compose up -d

The app will be accessible at http://<your-server-ip>:3000.

πŸš€ Manual Installation

For a direct installation on a Linux server, follow these steps:

  1. Install required dependencies:

sudo apt update

sudo apt install -y ruby ruby-dev build-essential libmysqlclient-dev mysql-client git

  1. Clone the Redmine repository:

git clone https://github.com/redmine/redmine.git /opt/redmine

cd /opt/redmine

  1. Install Ruby gems:

sudo gem install bundler

bundle install --without development test

  1. Set up the database configuration in /opt/redmine/config/database.yml:

production:

adapter: mysql2

database: redmine_db

host: localhost

username: redmine_user

password: secretpassword

  1. Run database migrations and start the server:

RAILS_ENV=production bundle exec rake db:migrate

RAILS_ENV=production bundle exec rails server

Access Redmine at http://<your-server-ip>:3000.

Configuring Nginx as a Reverse Proxy

🌐 Nginx Configuration

To serve Redmine through Nginx, create the following server block in /etc/nginx/sites-available/redmine:


server {

server_name your-domain.com;

location / {

proxy_pass http://127.0.0.1:3000;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}

listen 80;

}

Enable the configuration and restart Nginx:


sudo ln -s /etc/nginx/sites-available/redmine /etc/nginx/sites-enabled/

sudo systemctl restart nginx

πŸ”’ SSL/TLS Setup

Secure your Redmine instance using Let’s Encrypt:


sudo apt install -y certbot python3-certbot-nginx

sudo certbot --nginx -d your-domain.com

Automate certificate renewal:


sudo crontab -e

0 3 * * * certbot renew --quiet

πŸ› οΈ Testing and Reloading Nginx

Verify the configuration and restart Nginx:


sudo nginx -t

sudo systemctl reload nginx

Logging and Debugging Redmine

πŸ—ƒοΈ Enabling Debug Logs

To enable debug-level logging, modify config/additional_environment.rb:


config.log_level = :debug

Restart the application to apply changes.

πŸ“„ Viewing Logs

For Docker-based installations, view logs using:


docker logs redmine

For manual installations, check the log file in /opt/redmine/log/production.log:


tail -f /opt/redmine/log/production.log

πŸ› οΈ Troubleshooting Common Issues

If Redmine fails to start, review logs for database connection errors or missing dependencies. For example, ensure the database is properly configured and running.

πŸ“€ Exporting Logs

To send logs to an external system like ELK Stack, use a tool like Filebeat:


sudo apt install filebeat

sudo filebeat setup

sudo systemctl start filebeat

Backup and Restore

πŸ—‚οΈ File-Based Backups

Create a backup of Redmine’s files directory:


tar -czvf redmine_files_backup.tar.gz /usr/src/redmine/files

πŸ”„ Database Backups

Export the database:


mysqldump -u redmine_user -p redmine_db > redmine_db_backup.sql

Restore the database:


mysql -u redmine_user -p redmine_db < redmine_db_backup.sql

πŸ“… Automated Backup Scripts

Set up a cron job for automated backups:


crontab -e

## Add the line:

0 2 * * * tar -czvf /backup/redmine_$(date +\%F).tar.gz /usr/src/redmine/files && mysqldump -u redmine_user -p'redmine_db' > /backup/redmine_db_$(date +\%F).sql

Updating and Upgrading Redmine

⬆️ Updating Docker Images

Pull the latest Redmine image and recreate containers:


docker-compose pull

docker-compose up -d

πŸ› οΈ Manual Updates

For manual installations, update the source code and dependencies:


cd /opt/redmine

git pull

bundle install --without development test

RAILS_ENV=production bundle exec rake db:migrate

πŸ” Checking for Updates

Visit the Redmine Changelog to monitor new releases.

Leveraging Redmine’s Unique Features

πŸ”§ Enabling APIs

Activate the Redmine REST API in config/configuration.yml:


rest_api_enabled: true

Example API usage with curl:


curl -H "X-Redmine-API-Key: your_api_key" -X GET http://your-domain.com/issues.json

🌟 Advanced Configurations

Enable plugins by adding them to the plugins directory and migrating:


cd /opt/redmine/plugins

git clone https://github.com/example-plugin.git

RAILS_ENV=production bundle exec rake redmine:plugins:migrate

Restart the server to apply the changes.

Wrapping Up

With Redmine installed, configured, and secured, you now have a powerful project management tool tailored to your needs. From seamless backups to advanced API utilization, this guide equips you with the foundation to maximize Redmine’s potential. Start implementing these steps today and unlock the full power of self-hosted project management!

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to Selfhosted Ninja.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.