Project

General

Profile

Support #956

Install Redmine on FreeBSD 12

Added by Daniel Curtis 24 days ago. Updated 23 days ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
Installation
Target version:
Start date:
02/11/2021
Due date:
% Done:

0%

Estimated time:
1.00 h

Description

This is a guide on installing Redmine with PostgreSQL and nginx on FreeBSD 12.

Prepare the Environment

  • Make sure everything is up to date using the following command:
    pkg update -f && pkg upgrade
    
  • Install dependencies:
    pkg install portmaster
    
  • Update ports tree:
    portsnap fetch extract
    
  • Create a redmine user:
    pw add user -n redmine -m -s /sbin/nologin -c "Redmine" 
    

Install PostgreSQL 12

  • Install PostgreSQL:
    pkg install postgresql12-{server,client}
    
  • Enable PostgreSQL at boot, initialize the database and start the service:
    sysrc postgresql_enable=YES
    service postgresql initdb
    service postgresql start
    
  • Switch to the pgsql user and enter into the psql prompt:
    su postgres
    psql -d template1
    
    • Create the redmineuser user and redminedb database:
      CREATE ROLE redmineuser LOGIN ENCRYPTED PASSWORD 'SuperSecretPassword' NOINHERIT VALID UNTIL 'infinity';
      CREATE DATABASE redminedb WITH ENCODING='UTF8' OWNER=redmineuser;
      
  • Exit from the postgres user
    \q
    exit
    

Install Nginx

  • Install passenger binaries:
    pkg install rubygem-passenger-nginx
    
  • Compile nginx with passenger support:
    portmaster www/nginx
    
    • NOTE : Make sure to enable [X]PASSENGER while configuring nginx
  • Add the redmine user to the www group:
    pw usermod redmine -G www
    
  • Start and enable nginx at boot:
    sysrc nginx_enable=YES
    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;
      
          passenger_root /usr/local/lib/ruby/gems/2.7/gems/passenger;
          passenger_ruby /usr/local/bin/ruby27;
      
          # 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_sticky_sessions on;
          passenger_enabled on;
          passenger_user    redmine;
          passenger_group   redmine;
      }
      
  • Restart nginx:
    service nginx restart
    

Install Redmine

  • Install redmine:
    pkg install redmine4
    
  • Create the 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: postgresql
        database: redminedb
        host: localhost
        username: redmineuser
        password: "SuperSecretPassword" 
        encoding: utf8
      
  • Install gem dependencies:
    cd /usr/local/www/redmine
    su -m redmine -c "bundle config without 'development test mysql'" 
    su -m redmine -c "bundle config path 'vendor/bundle'" 
    su -m redmine -c "bundle install" 
    
    • NOTE: I had to run a bundle upgrade in order to get the bundle install to pass without issue.
  • Generate a secret token:
    su -m redmine -c "bundle exec rake generate_secret_token" 
    
  • Edit the Gemfile:
    vi Gemfile
    
    • And add the following below the other gem dependencies:
      gem "pg", "1.2.3" 
      
  • Create the database structure:
    su -m redmine -c "env RAILS_ENV=production bundle exec rake db:migrate" 
    
  • Change the redmine site ownership:
    chown -R redmine:www /usr/local/www/redmine
    

Resources

#1

Updated by Daniel Curtis 24 days ago

  • Description updated (diff)
#2

Updated by Daniel Curtis 24 days ago

  • Description updated (diff)
#3

Updated by Daniel Curtis 23 days ago

  • Description updated (diff)
  • Status changed from New to Resolved
#4

Updated by Daniel Curtis 23 days ago

  • Description updated (diff)

Also available in: Atom PDF