HOWTO: Redmine + Nginx / Passenger + PostgreSQL

rodrigc@

Developer
The following HOWTO describes step-by-step how to set up Redmine under FreeBSD.

PREPARATION

  1. Add a redmine user with the adduser utility.
    # adduser
  2. Before building any of the Ruby ports, make sure that the locale is set properly. For example, if we are using the en_US.UTF-8 locale:

    For sh, ksh, zsh, bash:
    export LANG=en_US.UTF-8
    export LC_ALL=en_US.UTF-8

    or for csh, tcsh:
    setenv LANG en_US.UTF-8
    setenv LC_ALL en_US.UTF-8

    If you run the locale command, you should see something like:

    Code:
    [cmd]locale[/cmd]
    LANG=en_US.UTF-8
    LC_CTYPE="en_US.UTF-8"
    LC_COLLATE="en_US.UTF-8"
    LC_TIME="en_US.UTF-8"
    LC_NUMERIC="en_US.UTF-8"
    LC_MONETARY="en_US.UTF-8"
    LC_MESSAGES="en_US.UTF-8"
    LC_ALL=en_US.UTF-8

    If all these variables are not set properly, you may see weird failures when building RubyGems from ports, such as mail/rubygem-mail.
  3. Update your ports tree.
    portsnap fetch
    portsnap extract
  4. Make sure that ports-mgmt/portmaster is installed:
    cd /usr/ports/ports-mgmt/portmaster
    make
    make install
    make clean

INSTALL NGINX PORT

  1. Configure the Nginx port, build it, and install it.
    portmaster --force-config www/nginx
  2. Make sure that PASSENGER is enabled in the Nginx options. PASSENGER is used to run Ruby on Rails applications.

INSTALL REDMINE PORT

  1. Configure, build, and install the Redmine port.
    portmaster --force-config www/redmine
  2. In the config, make sure that PASSENGER is enabled in the options, and THIN is unchecked.
  3. After the config is done, the Redmine port and dependent ports will be built.
  4. When the rubygem-passenger port is built, make sure that Build with nginx support is checked.
  5. When the rubygem-rails port is built, make sure that FastCGI backend and Passenger backend are checked.
  6. Install RubyGem to interface with PostgreSQL:
    portmaster --force-config databases/rubygem-pg

CONFIGURE NGINX

  1. Run the following command to determine where the root directory of the Passenger gem is:
    passenger-config --root
  2. Edit /usr/local/etc/nginx/nginx.conf and make sure the following lines are in the config:
    Code:
    http {
       ...
       passenger_root /usr/local/lib/ruby/gems/1.9/gems/passenger-4.0.10;
       passenger_ruby /usr/local/bin/ruby19;
       passenger_user redmine;
       passenger_group redmine;
    
    
       server {
            listen       80;
            ...
    
    
            location / {
                root   /usr/local/www/redmine/public;
                passenger_enabled on;
            }
       ...
    }
  3. Make sure that everything under /usr/local/www/redmine is owned by the redmine user:
    # chmod -R redmine:redmine /usr/local/www/redmine
  4. Add to /etc/rc.conf:

    Code:
    nginx_enable="YES"

INSTALLING POSTGRES

  • Find out what version of the PostgreSQL client was installed, due to dependencies on previously installed ports.
    # pkg info -g 'postgresql*'
  • Install the PostgreSQL server of the same version as the client which is installed. If postgresql90-client is installed, then:
    # portmaster --force-config databases/postgresql90-server
  • Add to /etc/rc.conf:
    Code:
    postgresql_enable="YES"
  • Initialize the PostgreSQL database and start it:
    # service postgresql initdb
    # service postgresql start
  • Log in as the pgsql user:
    # su pgsql
  • Create a database:
    # /usr/local/bin/createdb redminedb
  • Set a password for the pgsql user.
    passwd

CONFIGURE REDMINE

  • Create a database.yml file.
    # cp /usr/local/www/redmine/config/database.yml.example /usr/local/www/redmine/config/database.yml
  • Add the following config section to database.yml:
    Code:
    # PostgreSQL configuration example
    production:
      adapter: postgresql
      database: redminedb
      host: localhost
      username: pgsql
      password: my_password
      encoding: utf8
  • Follow the setup instructions at the Redmine setup instructions at: http://www.redmine.org/wiki/redmine/RedmineInstall

Log rotation

Add the following line to /etc/newsyslog.conf

Code:
/usr/local/www/redmine/log/production.log       644 3 3000 *  J

See the following link for more information about rotating Redmine logs:
http://www.redmine.org/projects/redmine/wiki/RedmineInstall#Logging-configuration

START NGINX

  1. Start Nginx:
    # service start nginx
  2. Make sure that Passenger is running properly:
    passenger-status
    passenger-memory-stats
  3. Test the Redmine installation by accessing your installation at http://localhost.

FURTHER REFERENCES

 
Setting locale

In regards to setting the locale, a simpler, system-wide way of doing this is to add a setting in /etc/login.conf under the default: type:

Code:
    default:\
             (lines omitted) \
             :lang=en_US.UTF-8:

And then run cap_mkdb /etc/login.conf to apply that and re-login to see the changes in effect.

Patrick
 
Don't forget to install run:
#gem install pkg-config

This installs a dependency for: textproc/rubygem-nokogiri A.K.A. a headache
 
Back
Top