Project

General

Profile

Support #747

Install Redmine on FreeBSD

Added by Daniel Curtis almost 9 years ago. Updated over 8 years ago.

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

100%

Estimated time:
2.00 h
Spent time:

Description

This is a guide on installing Redmine with MariaDB and Nginx on FreeBSD 10.

Prepare the Environment

  • Make sure that pkg is set to use the latest packages. Create the pkg repo config file:
    mkdir -p /usr/local/etc/pkg/repos
    vi /usr/local/etc/pkg/repos/FreeBSD.conf
    
    • And add the following:
      FreeBSD: {
        url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest",
        mirror_type: "srv",
        signature_type: "fingerprints",
        fingerprints: "/usr/share/keys/pkg",
        enabled: yes
      }
      
  • Make sure everything is up to date using the following command:
    pkg update -f && pkg upgrade
    
  • Create a redmine user:
    pw add user -n redmine -m -s /sbin/nologin -c "Redmine" 
    
  • Install a few dependencies:
    pkg install portmaster gcc llvm36 cmake scons ImageMagick rubygem-mime-types1 rubygem-sass-rails
    

Install MariaDB server

  • Start by installing the mariadb100-server and mariadb100-client packages:
    pkg install mariadb100-{server,client}
    
  • Copy a base MariaDB configuration to use:
    cp /usr/local/share/mysql/my-small.cnf /var/db/mysql/my.cnf
    
  • Edit the mariadb config to change the max packet size:
    vi /var/db/mysql/my.cnf
    
    • and modify max_allowed_packet to 32M
      max_allowed_packet = 32M
      
  • Enable and start MariaDB
    echo 'mysql_enable="YES"' >> /etc/rc.conf
    service mysql-server start
    
  • Prepare the database for use by running the secure installation:
    mysql_secure_installation
    
    • NOTE: Choose a strong root password and answer yes to all questions.

Create MariaDB Databases and Users

  • Login to MariaDB and create appropriate databases and users.
    mysql -u root -p
    
    • and run the following SQL queries to create the redminedb database and redmineuser user:
      CREATE DATABASE redminedb CHARACTER SET utf8;
      
      CREATE USER 'redmineuser'@'localhost' IDENTIFIED BY 'SuperSecretPassword';
      
      GRANT ALL PRIVILEGES ON redminedb.* TO 'redmineuser'@'localhost';
      
      FLUSH PRIVILEGES;
      
      quit
      

Install Redmine

  • Install redmine:
    portmaster www/redmine
    
    • NOTE: Make sure to enable [X]PASSENGER while configuring redmine
  • Copy config/database.yml.example to config/database.yml:
    cp /usr/local/www/redmine/config/database.yml.example /usr/local/www/redmine/config/database.yml
    
  • Edit the redmine database config:
    vi /usr/local/www/redmine/config/database.yml
    
    • And modify the production database settings:
      production:
        adapter: mysql2
        database: redminedb
        host: localhost
        username: redmineuser
        password: "SuperSecretPassword" 
        encoding: utf8
      
  • Install gem dependencies:
    cd /usr/local/www/redmine
    bundle install --without development test postgres --path vendor/bundle
    
  • Generate a secret token:
    bundle exec rake generate_secret_token
    
  • Create the database structure:
    env RAILS_ENV=production bundle exec rake db:migrate
    
  • Change the redmine site ownership:
    chown -R redmine:www /usr/local/www/redmine
    

Install Nginx

  • Install nginx with passenger support:
    portmaster www/nginx
    
    • NOTE: Make sure to enable [X]PASSENGER while configuring nginx
  • Install Passenger
    portmaster www/rubygem-passenger
    
    • NOTE: Make sure to enable [X]NGINX while configuring rubygem-passenger
    • NOTE: Enabling [X]SYMLINK makes upgrading passenger easier later on.
  • Add the redmine user to the www group:
    pw usermod redmine -G www
    
  • Start and enable nginx at boot:
    echo 'nginx_enable="YES"' >> /etc/rc.conf
    service nginx start
    
  • Create a configuration directory to make managing individual server blocks easier
    mkdir /usr/local/etc/nginx/conf.d
    
  • Edit the main nginx config file:
    vi /usr/local/etc/nginx/nginx.conf
    
    • And strip down the config file and add the include statement at the end to make it easier to handle various server blocks:
      worker_processes  1;
      error_log  /var/log/nginx-error.log;
      
      events {
          worker_connections  1024;
      }
      
      http {
          include       mime.types;
          default_type  application/octet-stream;
          sendfile        on;
          keepalive_timeout  65;
      
          # Load Phusion Passenger module globally
          passenger_root /usr/local/lib/ruby/gems/2.2/gems/passenger;
          passenger_ruby /usr/local/bin/ruby22;
          passenger_max_pool_size 15;
          passenger_pool_idle_time 300;
      
          # Load config files from the /etc/nginx/conf.d directory
          include /usr/local/etc/nginx/conf.d/*.conf;
      }
      
  • Add a redmine.example.com server block:
    vi /usr/local/etc/nginx/conf.d/redmine.example.com.conf
    
    • Add the following:
      server {
          listen       80;
          server_name  redmine.example.com;
          root         /usr/local/www/redmine/public;
          access_log   /var/log/redmine.example.com-access.log;
          error_log    /var/log/redmine.example.com-error.log;
      
          passenger_enabled on;
          passenger_user    redmine;
          passenger_group   redmine;
      }
      
  • Restart nginx:
    service nginx restart
    

Resources

#1

Updated by Daniel Curtis almost 9 years ago

  • Description updated (diff)
#2

Updated by Daniel Curtis almost 9 years ago

  • Description updated (diff)
  • Status changed from New to In Progress
  • % Done changed from 0 to 50
#3

Updated by Daniel Curtis almost 9 years ago

  • Description updated (diff)
#4

Updated by Daniel Curtis almost 9 years ago

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

Updated by Daniel Curtis almost 9 years ago

  • Description updated (diff)
#6

Updated by Daniel Curtis almost 9 years ago

  • Description updated (diff)
#7

Updated by Daniel Curtis almost 9 years ago

  • Description updated (diff)
#8

Updated by Daniel Curtis almost 9 years ago

  • Status changed from Resolved to Closed
#9

Updated by Daniel Curtis over 8 years ago

  • Description updated (diff)
#10

Updated by Daniel Curtis over 8 years ago

  • Description updated (diff)
#11

Updated by Daniel Curtis over 8 years ago

  • Description updated (diff)
#12

Updated by Daniel Curtis over 8 years ago

  • Description updated (diff)
#13

Updated by Daniel Curtis over 8 years ago

  • Description updated (diff)
#14

Updated by Daniel Curtis over 8 years ago

  • Target version changed from FreeBSD 9 to FreeBSD 10
#15

Updated by Daniel Curtis over 8 years ago

  • Description updated (diff)
#16

Updated by Daniel Curtis over 8 years ago

  • Description updated (diff)

Also available in: Atom PDF