Support #570
Updated by Daniel Curtis almost 10 years ago
{{>toc}}
This is a simple guide for setting up Redmine on a LAMP server on Debian 7 (wheezy).
h1. 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:
<pre>
sudo -s
apt-get update && apt-get upgrade
</pre>
* Set the hostname in the hosts:
<pre>
nano /etc/hosts
</pre>
#* And add/modify the following:
<pre>
127.0.1.1 redmine.example.com www
</pre>
* And also edit the hostname file:
<pre>
nano /etc/hostname
</pre>
#* And add/modify the following:
<pre>
redmine
</pre>
* Reboot to apply the hostname settings:
<pre>
reboot
</pre>
h1. Install Apache 2
* Install apache2 and the passenger module:
<pre>
apt-get install apache2 libapache2-mod-passenger
</pre>
h2. Configure Apache 2
* Edit the default apache2 Vhost config:
<pre>
nano /etc/apache2/sites-available/default
</pre>
#* And add/modify the following VirtualHost block:
<pre>
<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>
</pre>
#* *NOTE*: Make sure AllowOverride is set to ALL, or else the .htaccess file will not work.
h1. Install Apache 2 Passenger
* Install the apache2 passenger module:
<pre>
apt-get install libapache2-mod-passenger
</pre>
* Edit the apache2 passenger config file:
<pre>
nano /etc/apache2/mods-available/passenger.conf
</pre>
#* And add/modify the apache usInstall Redmine on a Debian LAMP Serverer as the default passenger user:
<pre>
<IfModule mod_passenger.c>
PassengerRoot /usr
PassengerRuby /usr/bin/ruby
PassengerDefaultUser www-data
</IfModule>
</pre>
h1. Install MySQL 5.5
* Install MySQL server and client:
<pre>
apt-get install mysql-server mysql-client
</pre>
#* *NOTE*: During the setup a prompt will appear to set the *root* MySQL user password. Set a strong password and do not forget it.
h2. Configure a new MySQL database
* Log into the MySQL console:
<pre>
mysql -h localhost -u root -p
</pre>
#* Create the *redmineuser* user with the *SuperSecretPassword* password and the *redminedb* database:
<pre>
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
</pre>
h1. Install Redmine
* Install Redmine and redmine-mysql packages:
<pre>
apt-get install redmine redmine-mysql
</pre>
#* 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:
<pre>
chown -R www-data:www-data /usr/share/redmine
</pre>
* Restart apache for the php module to take effect:
<pre>
service apache2 restart
</pre>
Install Redmine on a Debian LAMP Server
h1. Securing Redmine with SSL
* Install openssl:
<pre>
apt-get install openssl
</pre>
* Generate a strong SSL key and a CSR to send for signing by a CA:
<pre>
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
</pre>
* Make sure to securely copy the SSL certificate to *redmine.example.com.crt*
* Edit the apache2 default ssl Vhost config file:
<pre>
nano /etc/apache2/sites-available/default-ssl
</pre>
#* And Add the following:
<pre>
<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>
</pre>
h2. 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:
<pre>
nano /usr/share/redmine/public/.htaccess
</pre>
#* Look for the following two lines, and remove the @#@ characters before them:
<pre>
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</pre>
* Restart apache2:
<pre>
service apache2 restart
</pre>
* Now the website will be accessible from https://redmine.example.com
#* The default username is *admin*
#* The default password is *admin*
h1. (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:
<pre>
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
</pre>
* Remove the old bundler that was installed earlier:
<pre>
apt-get remove bundler
</pre>
* Install git, ruby1.9.1-dev, zlib1g-dev, libmysqlclient-dev, ImageMagick, and libmagickwand-dev:
<pre>
apt-get install git ruby1.9.1-dev zlib1g-dev libmysqlclient-dev libmagickwand-dev
</pre>
* Install bundler from gems (Debian's version is too outdated):
<pre>
gem install bundler
</pre>
NOTE: I needed to log out and log back in for the new bundler to take effect
* Download latest Redmine:
<pre>
cd /usr/local
git clone https://github.com/redmine/redmine.git
</pre>
* Create and edit the Redmine database config:
<pre>
cp /usr/local/redmine/config/database.yml.example /usr/local/redmine/config/database.yml
nano /usr/local/redmine/config/database.yml
</pre>
#* And modify the config:
<pre>
production:
adapter: mysql2
database: redminedb
host: localhost
username: redmineuser
password: "SuperSecretPassword"
encoding: utf8
</pre>
* Install the gems required by Redmine
<pre>
cd /usr/local/redmine
bundle install --without test development postgresql --path vendor/bundle
</pre>
* Generate a secret token:
<pre>
rake generate_secret_token
</pre>
* Create the database structure, by running the following command under the application root directory:
<pre>
RAILS_ENV=production rake db:migrate
</pre>
* Set file system permissions:
<pre>
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
</pre>
h2. Configure Apache 2
* Edit the default apache2 Vhost config:
<pre>
nano /etc/apache2/sites-available/default
</pre>
#* And add/modify the following VirtualHost block:
<pre>
<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>
</pre>
#* *NOTE*: Make sure AllowOverride is set to ALL, or else the .htaccess file will not work.