概要 †
Debianのリポジトリは古いので、Redmineをソースから導入します。
Redmine公式サイトの手順を少しだけ参考にします。
https、サブディレクトリ、MariaDB、basic認証、Unicorn環境を構築します。
ここでは、以下のサンプルURLを使用します。
https://hoge.paburica.com/redmine
先にこちらを見たほうが、全体像が掴めるかもしれません。
Nginx/Gitlab,Redmine,Jenkinsサブディレクトリ構成の設定
手順 †
- 前準備
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
| -
!
-
!
-
!
-
!
-
!
-
!
-
!
-
!
-
!
-
|
!
-
|
!
-
!
-
!
-
!
-
!
-
!
-
!
-
!
-
!
-
!
-
-
|
|
|
|
|
-
!
-
!
-
!
-
|
|
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
!
|
-
!
| apt-get update -y
apt-get upgrade -y
apt-get install imagemagick libmagickcore-dev libmagickwand-dev
sudo adduser --disabled-login --gecos 'Redmine' redmine
sudo -u redmine -H git clone https://github.com/redmine/redmine.git -b 2.5-stable redmine
cd redmine
vi .bundle/config
BUNDLE_PATH: vendor/bundle
BUNDLE_DISABLE_SHARED_GEMS: '1'
sudo -u redmine vi Gemfile.local
gem 'unicorn'
sudo -u redmine -H bundle install -j3 --without development test postgresql sqlite
mysql -u root -p
create database redmine character set utf8;
create user 'redmine'@'localhost' identified by '<パスワード>';
grant all privileges on redmine.* to 'redmine'@'localhost';g
quit
sudo -u redmine cp config/database.yml.example config/database.yml
vi config/database.yml
production:
adapter: mysql2
database: redmine
host: localhost
username: redmine
password: "<MariaDBのredmineユーザーパスワード>"
encoding: utf8
sudo -u redmine bundle exec rake generate_secret_token
sudo -u redmine bundle exec rake db:migrate RAILS_ENV=production
sudo -u redmine bundle exec rake redmine:load_default_data RAILS_ENV=production
sudo -u redmine wget -O config/unicorn.rb https://raw.github.com/defunkt/unicorn/master/examples/unicorn.conf.rb
vi config/unicorn.rb
worker_processes 1 working_directory "/home/redmine/redmine" listen "/home/redmine/redmine/tmp/sockets/redmine.socket", :backlog => 64
listen 8084, :tcp_nopush => true pid "/home/redmine/redmine/tmp/pids/unicorn.pid"
stderr_path "/home/redmine/redmine/log/unicorn.stderr.log"
stdout_path "/home/redmine/redmine/log/unicorn.stdout.log"
sudo -u redmine mkdir -p tmp/sockets tmp/pids public/plugin_assets
sudo -u redmine chown -R redmine:redmine files log tmp public/plugin_assets
sudo -u redmine chmod -R 755 files log tmp public/plugin_assets
vi /var/lib/redmine/config.ru
require ::File.expand_path('../config/environment', __FILE__)
if ENV['RAILS_RELATIVE_URL_ROOT']
map ENV['RAILS_RELATIVE_URL_ROOT'] do
run RedmineApp::Application
end
else
run RedmineApp::Application
end
vi /etc/init.d/redmine
set -u
set -e
APP_USER=redmine
APP_NAME=redmine
APP_ROOT="/home/redmine/$APP_NAME"
CONFIGS="$APP_ROOT/config/unicorn.rb"
PID="$APP_ROOT/tmp/pids/unicorn.pid"
ENV=production
UNICORN_OPTS="-D -E $ENV -c $CONFIGS --path /redmine"
old_pid="$PID.oldbin"
cd $APP_ROOT || exit 1
sig(){
test -s "$PID" && kill -$1 `cat $PID`
}
oldsig(){
test -s $old_pid && kill -$1 `cat $old_pid`
}
case $1 in
start)
sig 0 && echo >&2 "Already running" && exit 0
cd $APP_ROOT ; sudo -u $APP_USER bundle exec unicorn_rails $UNICORN_OPTS
;;
stop)
sig QUIT && exit 0
echo >&2 "Not running"
;;
force-stop)
sig TERM && exit 0
echo >&2 "Not running."
;;
restart|reload)
sig HUP && echo reloaded OK && exit 0
echo >&2 "Couldn't reload, starting instead"
sudo -u $APP_USER bundle exec unicorn_rails $UNICORN_OPTS
;;
upgrade)
sig USR2 && exit 0
echo >&2 "Couldn't upgrade, starting instead"
sudo -u $APP_USER bundle exec unicorn_rails $UNICORN_OPTS
;;
rotate)
sig USR1 && echo rotated logs OK && exit 0
echo >&2 "Couldn't rotate logs" && exit 1
;;
*)
echo >&2 "Usage: $0 <start|stop|restart|upgrade|rotate|force-stop>"
exit 1
;;
esac
update-rc.d -f redmine defaults
service redmine restart
|
- Nginxのサイト設定を行います。
Nginx/Gitlab,Redmine,Jenkinsサブディレクトリ構成の設定
補足1 †
ログローテートの設定もしてください。
redmine自体にも機能があるらしいですが、私はlogrotateで行うようにしました。
検証時の環境 †
- Debian Wheezy x64
- Redmine 2.5.2
- MariaDB 5.5.39