# Installing RedMine Project Management Software on Linux

1. Log into the Debian device
2. Run the following commands in a terminal:
   # update repositories
   sudo apt update
   # install available software updates
   sudo apt upgrade
   # install Apache2, Ruby, MySQL/MariaDB and redmine dependencies
   sudo apt install ruby-dev apache2 libapache2-mod-passenger mariadb-server build-essential libxslt1-dev libmariadb-dev libxml2-dev zlib1g-dev imagemagick libmagickwand-dev curl
   # configure the MySQL database
   sudo su
   mysql_secure_installation
3. Press Enter to login as root
4. Type Y and press Enter to set a root password, type the password twice to confirm
5. Type Y and press Enter to remove anonymous users
6. Type Y and press Enter to disallow root login remotely
7. Type Y and press Enter to remove the test database
8. Type Y and press Enter to reload privilege tables
9. Run the following command to login into MySQL:
   mysql -u root -p
10. Authenticate with the root password set earlier
11. Run the following commands to create the Redmine database and database user
    CREATE DATABASE redmine CHARACTER SET utf8mb4;
    GRANT ALL ON redmine.* to 'redmine'@'localhost' IDENTIFIED BY 'R3dM1n3!!';
    FLUSH PRIVILEGES;
    EXIT;
    exit
12. Continue with the following commands to download and extract Redmine
    # create redmine user
    sudo useradd -r -m -d /opt/redmine -s /usr/bin/bash redmine
    # add redmine user to www-data group
    sudo usermod -aG redmine www-data
    # download latest redmine version
    sudo wget -O redmine.tar.gz https://www.redmine.org/releases/redmine-4.1.2.tar.gz
    # extract redmine.tar.gz
    sudo -u redmine tar xzf redmine.tar.gz -C /opt/redmine/ --strip-components=1
    # authenticate as the redmine user
    sudo su - redmine
    # create copies of example configuration files
    cp /opt/redmine/config/configuration.yml{.example,}
    cp /opt/redmine/public/dispatch.fcgi{.example,}
    cp /opt/redmine/config/database.yml{.example,}
    # edit database.yml
    nano /opt/redmine/config/database.yml
13. Update the following values in database.yml

    production:
    adapter: mysql2
    database: redmine
    host: localhost
    username: redmine
    password: "R3dM1n3!!"

14. Press CTRL+O, Enter, CTRL+X to write the changes to database.yml
15. Continue with the following commands
    # exit redmine login
    exit
    # cd to /opt/redmine
    cd /opt/redmine
    # install bundler
    sudo gem install bundler
    # authenticate as the redmine user
    sudo su - redmine
    # install dependencies
    bundle install --without development test --path vendor/bundle
    # generate store secret
    bundle exec rake generate_secret_token
    # create database objects
    RAILS_ENV=production bundle exec rake db:migrate
    # insert database data
    RAILS_ENV=production REDMINE_LANG=en bundle exec rake redmine:load_default_data
    # reset permissions
    chmod -R 755 /opt/redmine
    # exit redmine login
    exit
    # cd to /opt/redmine
    cd /opt/redmine
    # start the redmine server
    sudo bundle exec rails server webrick -e production
    # create redmine apache2 conf
    sudo nano /etc/apache2/sites-available/redmine.conf
16. Paste the following configuration into redmine.conf

    Listen 3000
    <VirtualHost *:3000>
    ServerName redmine.kifarunix-demo.com
    RailsEnv production
    DocumentRoot /opt/redmine/public

    <Directory "/opt/redmine/public">
    Allow from all
    Require all granted
    </Directory>

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

17. Press CTRL+O, Enter, CTRL+X to write the changes to redmine.conf
18. Continue with the following commands to enable the site and restart Apache:
    # enable the required Apache modules
    sudo a2enmod passenger
    # enable redmine site
    sudo a2ensite redmine
    # restart apache2 service for the changes to take effect
    sudo systemctl restart apache2
19. Open a web browser and navigate to http://DNSorIP:3000
20. Log in with the username admin and password admin
21. Enter the password admin and set and confirm a new password for the admin user
22. Welcome to Redmine

Source: https://www.redmine.org/projects/redmine/wiki/RedmineInstall