Redmine Project Management Instaleation

Redmine is a flexible, open-source project management and issue tracking platform written in Ruby on Rails. It provides comprehensive project tracking, resource planning, issue management, and team collaboration features used by organizations worldwide. This guide covers Ruby installation, MySQL database setup, Apache/Nginx configuration, plugin installation, and email notifications.

Tabla de contenidos

Requisitos previos

Ensure you have:

  • Ubuntu 20.04 LTS or later
  • Root or sudo access
  • A registered domain name
  • Minimum 2GB RAM (4GB+ recommended)
  • 15GB available disk space
  • Basic Linux administration knowledge

Update system:

sudo apt update && sudo apt upgrade -y

Requisitos del sistema

Verifique las especificaciones del sistema:

Check OS version:

cat /etc/os-release
uname -m

Verifique available resources:

free -h
df -h

Instale required build tools:

sudo apt install -y build-essential libssl-dev libreadline-dev zlib1g-dev curl wget git

Ruby Instaleation

Instale RVM (Ruby Version Manager):

curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm

Instale Ruby 3.0 or later:

rvm install 3.0.0
rvm use 3.0.0 --default

Verifique installation:

ruby --version
gem --version

Instale bundler:

gem install bundler

Rails and Dependencies

Instale MySQL client:

sudo apt install -y mysql-server libmysqlclient-dev

Instale ImageMagick for image processing:

sudo apt install -y imagemagick libmagickwand-dev

Instale Curl development files:

sudo apt install -y libcurl4-openssl-dev

Instale Git:

sudo apt install -y git

Configuración de la base de datos

Start MySQL:

sudo systemctl start mysql
sudo systemctl enable mysql

Secure MySQL:

sudo mysql_secure_installation

Cree Redmine database:

sudo mysql -u root -p << EOF
CREATE DATABASE redmine CHARACTER SET utf8mb4;
CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'SecurePassword123!';
GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';
FLUSH PRIVILEGES;
EXIT;
EOF

Test connection:

mysql -u redmine -p -h localhost redmine
EXIT;

Redmine Instaleation

Cree installation directory:

sudo mkdir -p /opt/redmine
sudo chown -R $USER:$USER /opt/redmine
cd /opt/redmine

Descargue Redmine:

wget https://www.redmine.org/releases/redmine-5.0.0.tar.gz
tar -xzf redmine-5.0.0.tar.gz
mv redmine-5.0.0/* .
rmdir redmine-5.0.0

Cree database configuration:

cp config/database.yml.example config/database.yml
nano config/database.yml

Update for production:

production:
  adapter: mysql2
  database: redmine
  host: localhost
  username: redmine
  password: "SecurePassword123!"
  encoding: utf8mb4

Instale dependencies:

cd /opt/redmine
bundle install --without development test

Generate secret token:

bundle exec rake generate_secret_token

Cree database schema:

bundle exec rake db:migrate RAILS_ENV=production

Load default data:

bundle exec rake redmine:load_default_data RAILS_ENV=production
REDMINE_LANG=en

Set ownership:

sudo chown -R www-data:www-data /opt/redmine

Web Server Configuration

Apache Configuration

Instale Apache and Passenger:

sudo apt install -y apache2 apache2-dev
gem install passenger
passenger-install-apache2-module

Enable Passenger module:

sudo nano /etc/apache2/mods-available/passenger.load

Add:

LoadModule passenger_module /usr/local/rvm/gems/ruby-3.0.0/gems/passenger-6.0.0/buildout/apache2/mod_passenger.so

Cree virtual host:

sudo nano /etc/apache2/sites-available/redmine.conf

Add:

<VirtualHost *:80>
    ServerName redmine.example.com
    ServerAlias www.redmine.example.com
    DocumentRoot /opt/redmine/public

    <Directory /opt/redmine/public>
        AllowOverride All
        Require all granted
    </Directory>

    PassengerAppRoot /opt/redmine
    PassengerRuby /usr/local/rvm/wrappers/ruby-3.0.0/ruby

    ErrorLog ${APACHE_LOG_DIR}/redmine_error.log
    CustomLog ${APACHE_LOG_DIR}/redmine_access.log combined
</VirtualHost>

Enable site and modules:

sudo a2enmod passenger
sudo a2ensite redmine.conf
sudo a2dissite 000-default.conf
sudo apache2ctl configtest
sudo systemctl reload apache2

Configuración de Nginx

Instale Nginx:

sudo apt install -y nginx

Instale Puma web server:

cd /opt/redmine
bundle add puma

Configure Puma:

nano config/puma.rb

Add:

bind "unix:///var/run/puma.sock"
daemonize true
pidfile "/var/run/puma.pid"
state_path "/var/run/puma.state"

Cree systemd service:

sudo nano /etc/systemd/system/puma.service

Add:

[Unit]
Description=Puma HTTP Server
After=network.target

[Service]
Type=simple
User=www-data
WorkingDirectory=/opt/redmine
ExecStart=/usr/local/rvm/gems/ruby-3.0.0/bin/puma -c /opt/redmine/config/puma.rb
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

Enable and start Puma:

sudo systemctl daemon-reload
sudo systemctl enable puma
sudo systemctl start puma

Cree Nginx configuration:

sudo nano /etc/nginx/sites-available/redmine

Add:

upstream puma {
    server unix:///var/run/puma.sock;
}

server {
    listen 80;
    server_name redmine.example.com www.redmine.example.com;
    root /opt/redmine/public;

    location / {
        proxy_pass http://puma;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Enable site:

sudo ln -s /etc/nginx/sites-available/redmine /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl start nginx
sudo systemctl enable nginx

SSL Configuration

Instale Certbot:

sudo apt install -y certbot python3-certbot-apache

Obtain SSL certificate:

sudo certbot certonly --apache -d redmine.example.com

Update Apache/Nginx configuration to use HTTPS. For Apache:

sudo nano /etc/apache2/sites-available/redmine.conf

Update to listen on port 443 with SSL directives.

For Nginx, update with:

listen 443 ssl http2;
ssl_certificate /etc/letsencrypt/live/redmine.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/redmine.example.com/privkey.pem;

Email Setup

Configure SMTP in Redmine:

cd /opt/redmine
nano config/configuration.yml

Add email configuration:

production:
  email_delivery:
    delivery_method: :smtp
    smtp_settings:
      address: smtp.gmail.com
      port: 587
      user_name: [email protected]
      password: your-app-password
      authentication: plain
      enable_starttls_auto: true
      openssl_verify_mode: none

Test email:

bundle exec rails console -e production
Mailer.deliver_test_email('[email protected]')

Plugin Instaleation

Descargue useful plugins:

cd /opt/redmine/plugins
git clone https://github.com/redmine/redmine_agile.git
git clone https://github.com/redmine/redmine_checklists.git

Instale plugin dependencies:

cd /opt/redmine
bundle install

Migrate plugin database:

bundle exec rake redmine:plugins:migrate RAILS_ENV=production

Reinicie Redmine:

For Apache with Passenger:

touch /opt/redmine/tmp/restart.txt

For Nginx with Puma:

sudo systemctl restart puma

Copia de seguridad y actualizaciones

Cree backup script:

sudo nano /usr/local/bin/redmine-backup.sh

Add:

#!/bin/bash

BACKUP_DIR="/backups/redmine"
REDMINE_DIR="/opt/redmine"
DATE=$(date +%Y%m%d_%H%M%S)

mkdir -p $BACKUP_DIR

# Database backup
mysqldump -u redmine -p'SecurePassword123!' redmine | gzip > "$BACKUP_DIR/redmine-db-$DATE.sql.gz"

# Files backup
tar -czf "$BACKUP_DIR/redmine-files-$DATE.tar.gz" "$REDMINE_DIR"

# Keep only 30 days
find $BACKUP_DIR -type f -mtime +30 -delete

echo "Backup completed: $DATE"

Make executable:

sudo chmod +x /usr/local/bin/redmine-backup.sh

Schedule backups:

sudo crontab -e

Add:

0 2 * * * /usr/local/bin/redmine-backup.sh >> /var/log/redmine-backup.log 2>&1

Update Redmine:

cd /opt/redmine
git fetch origin
git checkout 5.1.0
bundle install
bundle exec rake db:migrate RAILS_ENV=production
bundle exec rake redmine:plugins:migrate RAILS_ENV=production

Conclusión

Redmine is now fully installed and configured as a comprehensive project management platform. With Ruby on Rails, MySQL database, email notifications, and plugin support, you have a powerful tool for team project tracking. Regular backups and updates ensure system reliability and access to new features. Configure projects, users, and permissions to establish an effective project management workflow.