Project

General

Profile

Support #570

Install Redmine on a Debian LAMP Server

Added by Daniel Curtis over 5 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Web Server
Target version:
Start date:
02/21/2015
Due date:
% Done:

100%

Estimated time:
1.50 h
Spent time:

Description

This is a simple guide for setting up Redmine on a LAMP server on Debian 7 (wheezy).

Preparing The Server

This guide is assumed that a Bare Debian install with only SSH Server access, a user that has sudo access.

  • Obtain a root shell and upgrade the server:
    sudo -s
    apt-get update && apt-get upgrade
    
  • Set the hostname in the hosts:
    nano /etc/hosts
    
    • And add/modify the following:
      127.0.1.1     redmine.example.com www
      
  • And also edit the hostname file:
    nano /etc/hostname
    
    • And add/modify the following:
      redmine
      
  • Reboot to apply the hostname settings:
    reboot
    

Install Apache 2

  • Install apache2 and the passenger module:
    apt-get install apache2 libapache2-mod-passenger
    

Configure Apache 2

  • Edit the default apache2 Vhost config:
    nano /etc/apache2/sites-available/default
    
    • And add/modify the following VirtualHost block:
      <VirtualHost *:80>
          ServerName redmine.example.com
      
          DocumentRoot /usr/share/redmine/public           
          <Directory /usr/share/redmine/public>
              RailsBaseURI /
              Options -Indexes FollowSymLinks -MultiViews
              AllowOverride All
              Order allow,deny
              allow from all
          </Directory>
      </VirtualHost>
      
    • NOTE: Make sure AllowOverride is set to ALL, or else the .htaccess file will not work.

Install Apache 2 Passenger

  • Install the apache2 passenger module:
    apt-get install libapache2-mod-passenger
    
  • Edit the apache2 passenger config file:
    nano /etc/apache2/mods-available/passenger.conf
    
    • And add/modify the apache usInstall Redmine on a Debian LAMP Serverer as the default passenger user:
      <IfModule mod_passenger.c>
        PassengerRoot /usr
        PassengerRuby /usr/bin/ruby
        PassengerDefaultUser www-data
      </IfModule>
      

Install MySQL 5.5

  • Install MySQL server and client:
    apt-get install mysql-server mysql-client
    
    • NOTE: During the setup a prompt will appear to set the root MySQL user password. Set a strong password and do not forget it.

Configure a new MySQL database

  • Log into the MySQL console:
    mysql -h localhost -u root -p
    
    • Create the redmineuser user with the SuperSecretPassword password and the redminedb database:
      CREATE USER 'redmineuser'@'localhost' IDENTIFIED BY 'SuperSecretPassword';   
      CREATE DATABASE IF NOT EXISTS  `redminedb` CHARACTER SET utf8 COLLATE utf8_general_ci;
      GRANT ALL PRIVILEGES ON `redminedb`.* TO 'redmineuser'@'localhost';
      
      flush privileges;
      exit
      

Install Redmine

  • Install Redmine and redmine-mysql packages:
    apt-get install redmine redmine-mysql
    
    • During the installation a Configuring redmine prompt for using dbconfig-common, choose: YES
    • During the installation a Configuring redmine prompt for database type, choose: mysql
    • During the installation a Configuring redmine prompt for password of the database administrative user, enter: <root mysql password>
    • During the installation a Configuring redmine prompt for application password, enter: SuperSecretPassword
    • During the installation a Configuring redmine prompt for application password confirmation, enter: SuperSecretPassword
  • Change the ownership of the Redmine folder to the apache2 user:
    chown -R www-data:www-data /usr/share/redmine
    
  • Restart apache for the php module to take effect:
    service apache2 restart
    

    Install Redmine on a Debian LAMP Server
    h1. Securing Redmine with SSL
  • Install openssl:
    apt-get install openssl
    
  • Generate a strong SSL key and a CSR to send for signing by a CA:
    mkdir /etc/apache2/ssl && cd /etc/apache2/ssl
    openssl req -sha512 -out redmine.example.com.csr -new -newkey rsa:4096 -nodes -keyout redmine.example.com.key
    
  • Make sure to securely copy the SSL certificate to redmine.example.com.crt
  • Edit the apache2 default ssl Vhost config file:
    nano /etc/apache2/sites-available/default-ssl
    
    • And Add the following:
      <VirtualHost *:443>
          ServerName redmine.example.com
      
          DocumentRoot /usr/share/redine/public           
          <Directory /usr/share/redmine/public>
              Options FollowSymLinks
              AllowOverride All
              Require all granted
          </Directory>
      
          SSLEngine on
      
          SSLCertificateFile /etc/apache2/ssl/redmine.example.com.crt
          SSLCertificateKeyFile /etc/apache2/ssl/redmine.example.com.key
      
          <FilesMatch "\.(cgi|shtml|phtml|php)$">
              SSLOptions +StdEnvVars
          </FilesMatch>
      
          BrowserMatch "MSIE [2-6]" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
          BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
      </VirtualHost>
      

Forcing SSL on a Website

  • Enable forced SSL connection by setting the two lines from earlier in the .htaccess file. Open the file for editing:
    nano /usr/share/redmine/public/.htaccess
    
    • Look for the following two lines, and remove the # characters before them:
      RewriteCond %{HTTPS} !=on
      RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
      
  • Restart apache2:
    service apache2 restart
    

(Optional) Install Latest Redmine

Debian has a older version of Redmine, this section is a guide on installing the latest Redmine version.

  • Install required packages:
    apt-get install dbconfig-common libjs-prototype libjs-scriptaculous rake ruby-actionmailer-2.3 ruby-actionpack-2.3 ruby-activerecord-2.3 ruby-activeresource-2.3 ruby-activesupport-2.3 ruby-blankslate ruby-builder ruby-coderay ruby-fastercsv ruby-i18n ruby-memcache-client ruby-net-ldap ruby-rails-2.3 ruby-rchardet ruby-text-format ruby-tmail ruby-tzinfo rubygems-integration unzip zip
    
  • Remove the old bundler that was installed earlier:
    apt-get remove bundler
    
  • Install git, ruby1.9.1-dev, zlib1g-dev, libmysqlclient-dev, ImageMagick, and libmagickwand-dev:
    apt-get install git ruby1.9.1-dev zlib1g-dev libmysqlclient-dev libmagickwand-dev
    
  • Install bundler from gems (Debian's version is too outdated):
    gem install bundler
    

    NOTE: I needed to log out and log back in for the new bundler to take effect
  • Download latest Redmine:
    cd /usr/local
    git clone https://github.com/redmine/redmine.git
    
  • Create and edit the Redmine database config:
    cp /usr/local/redmine/config/database.yml.example /usr/local/redmine/config/database.yml
    nano /usr/local/redmine/config/database.yml
    
    • And modify the config:
      production:
        adapter: mysql2
        database: redminedb
        host: localhost
        username: redmineuser
        password: "SuperSecretPassword" 
        encoding: utf8
      
  • Install the gems required by Redmine
    cd /usr/local/redmine
    bundle install --without test development postgresql --path vendor/bundle
    
  • Generate a secret token:
    rake generate_secret_token
    
  • Create the database structure, by running the following command under the application root directory:
    RAILS_ENV=production rake db:migrate
    
  • Set file system permissions:
    mkdir -p tmp tmp/pdf public/plugin_assets
    sudo chown -R www-data:www-data /usr/local/redmine
    sudo chmod -R 755 files log tmp public/plugin_assets
    

Configure Apache 2

  • Edit the default apache2 Vhost config:
    nano /etc/apache2/sites-available/default
    
    • And add/modify the following VirtualHost block:
      <VirtualHost *:80>
          ServerName redmine.example.com
      
          DocumentRoot /usr/local/redmine/public           
          <Directory /usr/local/redmine/public>
              RailsBaseURI /
              Options -Indexes FollowSymLinks -MultiViews
              AllowOverride All
              Order allow,deny
              allow from all
          </Directory>
      </VirtualHost>
      
    • NOTE: Make sure AllowOverride is set to ALL, or else the .htaccess file will not work.

Related issues

Copied from GNU/Linux Administration - Support #568: Install a Linux, Apache2, MySQL, PHP Web Server on Debian Closed 02/21/2015

History

#1 Updated by Daniel Curtis over 5 years ago

  • Copied from Support #568: Install a Linux, Apache2, MySQL, PHP Web Server on Debian added

#2 Updated by Daniel Curtis over 5 years ago

  • Description updated (diff)
  • Status changed from New to In Progress

#3 Updated by Daniel Curtis over 5 years ago

  • Description updated (diff)

#4 Updated by Daniel Curtis over 5 years ago

  • Description updated (diff)
  • % Done changed from 50 to 90

#5 Updated by Daniel Curtis over 5 years ago

  • Description updated (diff)
  • Status changed from In Progress to Resolved
  • % Done changed from 90 to 100

#6 Updated by Daniel Curtis over 5 years ago

  • Subject changed from Installing Redmine on a LAMP Server on Debian to Installing Redmine on a Debian LAMP Server

#7 Updated by Daniel Curtis over 5 years ago

  • Subject changed from Installing Redmine on a Debian LAMP Server to Install Redmine on a Debian LAMP Server

#8 Updated by Daniel Curtis over 5 years ago

  • Description updated (diff)

#9 Updated by Daniel Curtis over 5 years ago

  • Description updated (diff)

#10 Updated by Daniel Curtis over 5 years ago

  • Description updated (diff)

#11 Updated by Daniel Curtis over 5 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF