Skip to content

Instantly share code, notes, and snippets.

@greenwellness
Last active August 29, 2015 13:59
Show Gist options
  • Save greenwellness/11001687 to your computer and use it in GitHub Desktop.
Save greenwellness/11001687 to your computer and use it in GitHub Desktop.
Redmine+ Setup

Redmine Pro Setup

Install RVM

Not a must per-se but damn handy nontheless and the point is we might want to have other applications which require a whole different Ruby version to run so I’ll thank myself later.

  1. Ensure your user shell runcommand file (~/.bashrc, ~/.zshrc) doesn’t contain any $PATH path which doesn’t include the $PATH variable itself (e.g. export PATH=/foo/bar:/baz/bara) and append the $PATH environment variable postfix (e.g. export PATH=/foo/bar:/baz/bara:$PATH).

  2. Pull the latest stable Ruby from rvm.io using \curl -sSL https://get.rvm.io | bash -s stable --ruby

  3. Source the rvm file to obtain access to the function using source /the/rvm/path/.rvm/scripts/rvm

  4. Set the default Ruby binary and create a default gemset: rvm ruby-x.y.z.-build@redmine --default --create

  5. Make sure your autoload rc (~/.zshrc, ~/.bashrc) has the ruby path way way upfront the $PATH chain or it will bitch and moan and complain till you can’t take it anymore.

Setup RVM/Ruby toolkit

Having a default, flexible, Ruby install, we also have a gem for each version we can use to pull in any needed packages.

  1. Use gem i bundler rdoc rake rails pry pry-rails passenger thin --no-ri --no-rdoc for a quick install of the most dire programs.

  2. Move into the current Ruby gemset gems folder e.g. cd ~/.rvm/gems/ruby-2.1.1-latest@redmine/gems/passenger-4.0.41

  3. Compile the module for your webserver either nginx or apache: passenger-install-apache2-module or passenger-install-ngix-module.

Nginx, Passenger, Thin

  1. While trying to execute the last command of the previous chapter, we find that the script tries to install nginx from source (download instead of package manager) and that its default location probably isn’t writable (/opt/nginx).

  2. So switch user for a small bit and sudo mkdir /opt/nginx && sudo chown redmine:redmine /opt/nginx so we may install without problems using our limited redmine user.

  3. When done with compiling, write the thin configuration file either by hand or using the commands:

    • for permissions: sudo mkdir /etc/thin && sudo chown redmine:redmine /etc/thin

    • then write the config:

thin config -C /etc/thin/redmine.yml \
  -c /srv/redmine/sites/somesite.com \
  --servers 2 -e production \
  -a 127.0.0.1 -p 3000

This so we do not bump into either the gem not being found, or permissions not being correct. We can secure them lateron again.

Now make sure that these settings are reflected in the Nginx configuration file: vim /opt/nginx/conf/nginx.conf See below file for the configs of thin and nginx.

Once all files are written (configured) we can safely replace the permissions with root or your superuser.

Starting servers

  1. Thin (as Redmine): thin -C /etc/thin/redmine.yml start

  2. Nginx (as super): sudo nginx

Stopping servers

  1. Thin (as redmine): thin stop

  2. Nginx (as super): sudo nginx -s stop

Redmine packages

Next install anything we need from the Gemfile below (a tad bloated but ok..)

Then cd into the Redmine web folder, for me: /srv/http/www/projects.greenwellness.nl/

Ensure you have bundler installed by issueing: gem i bundler and then bundle to pull and compile all dependencies.

#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
upstream redmine {
server 127.0.0.1:3000;
server 127.0.0.1:3001;
# server 127.0.0.1:8002;
}
passenger_root /srv/redmine/.rvm/gems/ruby-2.1.1-latest@redmine/gems/passenger-4.0.41;
passenger_ruby /srv/redmine/.rvm/gems/ruby-2.1.1-latest@redmine/wrappers/ruby;
passenger_user redmine;
passenger_group redmine;
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name projects.greenwellness.nl;
root /srv/redmine/sites/projects.greenwellness.nl/public;
passenger_enabled on;
#charset koi8-r;
#access_log logs/host.access.log main;
#
location / {
try_files $uri @ruby;
}
location @ruby {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_read_timeout 300;
proxy_pass http://redmine;
}
#location / {
# root html;
# index index.html index.htm;
#}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root html;
#}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
# root html;
#}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
---
chdir: "/srv/redmine/sites/projects.greenwellness.nl"
environment: production
address: 127.0.0.1
port: 3000
timeout: 30
log: "/srv/redmine/log/thin.log"
pid: tmp/pids/thin.pid
max_conns: 1024
max_persistent_conns: 100
require: []
wait: 30
threadpool_size: 20
servers: 2
daemonize: true
@greenwellness
Copy link
Author

source 'https://rubygems.org'

gem 'pry'
gem 'pry-rails'

gem 'colorist'
gem 'yard'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment