Ubuntu 14.04 기준으로, Redmine의 최신 안정 버전(2.5.2)을 설치하는 과정을 설명한다. 기본적으로, Redmine 공식 페이지의 설명과 다르지 않다. (공식문서)
준비
Redmine은 Ruby On Rails 애플리케이션으로, Ruby/Rails를 위한 기본 패키지가 설치되어 있어야 한다.
$ sudo apt-get install ruby ruby-dev gem
위 명령으로 ruby와 gem을 설치해준다. (ruby-dev는 Native Gem을 Build할 때 필요하다) 또한, 아래와 같이 Ruby와 직접적인 관련은 없지만, 우리의 환경에 필요한 Build 도구를 함께 설치해준다.
$ sudo apt-get install build-essential
$ sudo apt-get install git
$ sudo apt-get install postgresql-server-dev-9.3
다음은, Bundler를 준비하는 과정인데, 이것은 Ubuntu 패키지를 쓰는 것 보다 이미 설치된 gem을 이용하는 방식으로 하였다.
$ sudo gem install bundler
Fetching: bundler-1.7.3.gem (100%)
Successfully installed bundler-1.7.3
1 gem installed
Installing ri documentation for bundler-1.7.3...
Installing RDoc documentation for bundler-1.7.3...
$
ruby on rails와 관련된 내용은 위와 같고, 다음은 데이터베이스의 설정이다.
개인적으로 요즘은 PostgreSQL을 사용하고 있다.
superhero@server:~$ sudo -i -u postgres
postgres@server:~$ pwd
/var/lib/postgresql
postgres@server:~$ psql
psql (9.3.5)
Type "help" for help.
postgres=# CREATE ROLE redmine LOGIN PASSWORD 'my_password';
CREATE ROLE
postgres=# CREATE DATABASE redmine WITH ENCODING='UTF8' OWNER=redmine;
CREATE DATABASE
postgres=# \q
postgres@server:~$
위와 유사한 방식으로, 사용자 redmine 과 데이터베이스 redmine을 만들어주면 된다.
본격적인 설치
앱이 설치될 위치로 이동하여, 다운로드한 패키지를 풀어준다.
$ cd /var/www/apps/
$ tar xvf ~/redmine-2.5.2.tar.gz
$ ln -s redmine-2.5.2 redmine
$ cd redmine
$
로컬 변경이 일어날 때 기억하기 위하여 앱 전체에 대한 버전관리를 적용한다.
$ git init
Initialized empty Git repository in /var/www/apps/redmine-2.5.2/.git/
$ git add .
$ git commit -m "initial commit"
이제 번들 gem을 설치할 차례. 운영환경에는 불필요한 것들을 제외하기 위해, —without 옵션을 활용한다.
$ bundle install --without development test rmagick
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Installing rake 10.1.1
Installing i18n 0.6.11
Installing multi_json 1.10.1
Installing activesupport 3.2.19
Installing builder 3.0.0
Installing activemodel 3.2.19
Installing erubis 2.7.0
Installing journey 1.0.4
Installing rack 1.4.5
Installing rack-cache 1.2
Installing rack-test 0.6.2
Installing hike 1.2.3
Installing tilt 1.4.1
Installing sprockets 2.2.2
Installing actionpack 3.2.19
Installing mime-types 1.25.1
Installing polyglot 0.3.5
Installing treetop 1.4.15
Installing mail 2.5.4
Installing actionmailer 3.2.19
Installing arel 3.0.3
Installing tzinfo 0.3.41
Installing activerecord 3.2.19
Installing activeresource 3.2.19
Installing awesome_nested_set 2.1.6
Using bundler 1.7.3
Installing coderay 1.1.0
Installing rack-ssl 1.3.4
Installing json 1.8.1
Installing rdoc 3.12.2
Installing thor 0.19.1
Installing railties 3.2.19
Installing jquery-rails 2.0.3
Installing net-ldap 0.3.1
Installing pg 0.17.1
Installing ruby-openid 2.3.0
Installing rack-openid 1.4.2
Installing rails 3.2.19
Installing redcarpet 2.3.0
Your bundle is complete!
Gems in the groups development, test and rmagick were not installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
그리고, 이제 실행환경용 데이터(보안 토큰) 및 데이터베이스를 초기화해준다.
$ rake generate_secret_token
$ RAILS_ENV=production rake db:migrate
$ RAILS_ENV=production rake redmine:load_default_data
Select language: ar, az, bg, bs, ca, cs, da, de, el, en, en-GB, es, et, eu, fa, fi, fr, gl, he, hr, hu, id, it, ja, ko, lt, lv, mk, mn, nl, no, pl, pt, pt-BR, ro, ru, sk, sl, sq, sr, sr-YU, sv, th, tr, uk, vi, zh, zh-TW [en]
====================================
Default configuration data loaded.
웹서버의 설정
Redmine의 설정이 끝났으면, 앱을 구동하기 위한 환경을 준비한다. 여기서는 NginX와 Unicorn을 활용할 것이다.
Nginx의 설정
upstream unicorn_redmine {
server 127.0.0.1:9494;
}
server {
listen 80;
listen 443 default_server ssl;
...
location /redmine {
alias /var/www/apps/redmine/public;
try_files $uri/index.html $uri.html $uri @redmine;
}
location @redmine {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn_redmine;
expires off;
}
...
}
Unicorn의 설정
첨부 파일 참조
Redmine의 수정
Unicorn+Nginx 환경과 함께, redmine의 경로를 '/'가 아닌 곳으로 잡아주기 위하여 다음과 같은 변경을 하였다.
diff --git a/config/application.rb b/config/application.rb index 58d949a..7bfb879 100644 --- a/config/application.rb +++ b/config/application.rb @@ -57,5 +57,7 @@ module RedmineApp if File.exists?(File.join(File.dirname(__FILE__), 'additional_environment.r instance_eval File.read(File.join(File.dirname(__FILE__), 'additional_env end + + config.assets.prefix = '/redmine/assets' end end diff --git a/config/routes.rb b/config/routes.rb index 6be563d..177cc7a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -15,7 +15,9 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US +Redmine::Utils::relative_url_root = "/redmine" RedmineApp::Application.routes.draw do +scope Redmine::Utils::relative_url_root do root :to => 'welcome#index', :as => 'home' match 'login', :to => 'account#login', :as => 'signin', :via => [:get, :post] @@ -354,3 +356,4 @@ RedmineApp::Application.routes.draw do end end end +end
다양한 구동환경에 따른 예시가 공식 사이트에 있다.
이상의 설정으로 기본적인 동작은 완성