Redmine2.6 + Nginx + CentOS7
์๊ฐ
๊ฐ๋ ์ธ์ธ ์ ์์ผ๋ฏ๋ก ๋ฉ๋ชจํด ๋๋ค.
์๋ชป๋๋ฉด ์ง์ ๋ถํ๋๋ฆฝ๋๋ค.
๊ธฐ๋ณธ์ ์ผ๋ก
htp : // bg. ์ด d ๋ฏธ๋ค. jp/์๋ฆฌ์นใs/2_6/์ธ sํ์น์จ_์ ๊ณผ s/
๊ฐ์ ์ ์ฐจ.
ํ๊ฒฝ
Redmine ๊ด๋ จ Package ์ค์น
Redmine ์ค์น์ ํ์ํ ํจํค์ง ์ค์น.
DB์๋ MariaDB๋ฅผ ์ด์ฉ
$ sudo yum -y groupinstall "Development Tools"
$ sudo yum -y install openssl-devel readline-devel zlib-devel curl-devel libyaml-devel
$ sudo yum -y install mariadb-server mariadb-devel
$ sudo yum -y install ImageMagick ImageMagick-devel ipa-pgothic-fonts
Ruby ์ค์น
rbenv ํ๊ฒฝ์์ Ruby2.1.5๋ฅผ ์ค์นํฉ๋๋ค.
install
$ sudo yum install gcc make openssl openssl-devel
$ cd /usr/local/
$ sudo git clone git://github.com/sstephenson/rbenv.git rbenv
$ mkdir -p rbenv/shims rbenv/versions
$ sudo groupadd /usr/local/rbenv
$ sudo chgrp -R rbenv rbenv/
$ sudo git clone git://github.com/sstephenson/ruby-build.git /usr/local/rbenv/ruby-build
$ cd /usr/local/rbenv/ruby-build
$ ./install.sh
ํ๊ฒฝ ๋ณ์ ์ค์ ํ์ผ ์์ฑ.
/etc/profile.d/rbenv.sh
export RBENV_ROOT="/usr/local/rbenv"
export PATH="/usr/local/rbenv/bin:$PATH"
eval "$(rbenv init -)"
$ source /etc/profile.d/rbenv.sh
$ sudo rbenv install -v 2.1.5
$ rbenv versions
* system (set by /usr/local/rbenv/version)
2.1.3
$ sudo rbenv global 2.1.3
$ rbenv versions
system
* 2.1.5 (set by /usr/local/rbenv/version)
$ ruby --version
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux]
$
Bundler ์ค์น
$ sudo gem install bundler --no-rdoc --no-ri
$ bundle --version
Bundler version 1.7.12
$
MariaDB ์ค์
์ฐ์ ์ MariaDB์ ์ค์ .
/etc/my.cnf
[mysqld]
datadir=/data/mysql # Dataใใฃใฌใฏใใชใไปปๆ
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
character-set-server=utf8
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
[mysql]
default-character-set=utf8
๋ฐ์ดํฐ ๋๋ ํ ๋ฆฌ ์์ฑ ๋ฐ ์๋ ์์ ์ค์ .
$ sudo mkdir -p /data/mysql # ใใผใฟใใฃใฌใฏใใชใฎไฝๆ
$ sudo chown mysql:mysql /data/mysql
$ sudo service mariadb start
$ sudo systemctl enable mariadb
๊ธฐ๋ณธ ์ค์ ์
mysql_secure_installation
์์ ๋ฃจํธ ์ํธ๋ฅผ ์ค์ ํฉ๋๋ค.$ mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
New password: ${root_passwd}
Re-enter new password: ${root_passwd}
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
$
์ด๊ธฐ ์ค์ ํ๋ redmine์ฉ์ DB
redmine
์ ๊ด๋ฆฌ์ ์ ์ ์ redmine
๋ฅผ ์์ฑ.$ mysql -uroot -p
Enter password: ${mysql_root_password}
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.40-MariaDB MariaDB Server
Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
MariaDB [(none)]>
MariaDB [(none)]> CREATE DATABASE redmine DEFAULT character set utf8;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all on redmine.* TO redmine@localhost identified by '${redmine_passwd}';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit;
$
Redmine ์ค์น
์ฐ์ ์ ์์ค์ ๋ค์ด๋ก๋์ ์ ๊ฐ.
๊ทธ ํ ์ฌ๋ณผ๋ฆญ ๋งํฌ๋ฅผ ์์ฑ.
$ cd /usr/local/src
$ sudo curl -O http://www.redmine.org/releases/redmine-2.6.1.tar.gz
$ sudo tar zxvf redmine-2.6.1.tar.gz
$ sudo ln -s ./redmine-2.6.1 /opt/redmine # /opt/redmineใซใทใณใใชใใฏใชใณใฏใไฝๆ
๋ค์ redmine database ์ค์ .
์ฐ์ example ํ์ผ์ ๋ณต์ฌ.
$ sudo cp -p /opt/redmine/config/database.yml.example /opt/redmine/config/database.yml
$
๋ค์์ ๋ฐฉ๊ธ MariaDB๋ก ์์ฑํ ์ ์ ์ DB๋ฅผ ์ง์ .
/opt/redmine/config/database.yml
# Default setup is given for MySQL with ruby1.9. If you're running Redmine
# with MySQL and ruby1.8, replace the adapter name with `mysql`.
# Examples for PostgreSQL, SQLite3 and SQL Server can be found at the end.
# Line indentation must be 2 spaces (no tabs).
production:
adapter: mysql2
database: redmine
host: localhost
username: redmine
password: "${redmine_passwd}"
encoding: utf8
์ดํ DB ํฌํจํ ์ด๊ธฐ ์ค์ .
$ cd /opt/redmine
$ bundle install --without development test --path vendor/bundle
$ bundle exec rake generate_secret_token
$ RAILS_ENV=production bundle exec rake db:migrate
Unicorn ์ค์น
๋ค์์ผ๋ก Nginx์ Redmine์ ์ฐ๊ฒฐํ๋ Unicorn์ ์ค์น.
Gem ํ์ผ (/opt/redmine) ํธ์ง ํ,
/opt/redmine/Gemfile
gem 'unicorn', '4.8.3'
์ค์นํฉ๋๋ค.
$ bundle install
๋ค์์ผ๋ก redmine์ฉ์ ํ๊ฒฝ ๋ณ์๋ฅผ ์ค์ .
/etc/profile.d/redmine.sh
RAILS_ROOT=/opt/redmine
export RAILS_ROOT
ํ๊ฒฝ ๋ณ์์ ๋ฐ์.
$ source /etc/profile.d/redmine.sh
์๋ Unicorn ์ค์ ํ์ผ.
Scoket ํ์ผ์ ๋ํด์์ ๋๋ค๋ง,/tmp/ํํ์ ๋๋ฉด Nginx๋ก not found ์๋ฌ๊ฐ ๋ฉ๋๋ค.
ใ ใ ใ ใ ใ ใ ใ ใ ใ ์ฝ m / ์ฟ ์ s ์น์จ s / 463993 / ๋๊ธด x - ์ฐ์ x - ๋๋ง ใณ - ์ c t - ์๋ก r / 464025 # 464025
/opt/redmine/config/unicorn.rb
# -*- coding: utf-8 -*-
# ใฏใผใซใผใฎๆฐ
worker_processes 2
# ใฝใฑใใ
listen '/var/run/unicorn.sock'
pid '/var/run/unicorn.pid'
# ใญใฐ
log = File.expand_path('log/unicorn.log', ENV['RAILS_ROOT'])
stderr_path File.expand_path('log/unicorn.log', ENV['RAILS_ROOT'])
stdout_path File.expand_path('log/unicorn.log', ENV['RAILS_ROOT'])
preload_app true
GC.respond_to?(:copy_on_write_friendly=) and GC.copy_on_write_friendly = true
before_fork do |server, worker|
defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect!
old_pid = "#{ server.config[:pid] }.oldbin"
unless old_pid == server.pid
begin
sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
Process.kill :QUIT, File.read(old_pid).to_i
rescue Errno::ENOENT, Errno::ESRCH
end
end
end
after_fork do |server, worker|
defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
end
์๋ ์์ ์คํฌ๋ฆฝํธ.
/opt/redmine/script/unicorn.sh
#!/bin/bash
set -e
TIMEOUT=60
APP_ROOT=${RAILS_ROOT}
PID=/var/run/unicorn.pid
RAILS_ENV=production
CMD="bundle exec unicorn -D -c $APP_ROOT/config/unicorn.rb -E $RAILS_ENV"
action="$1"
set -u
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 $action in
start)
sig 0 && echo >&2 "Already running" && exit 0
$CMD
;;
stop)
sig QUIT && rm -f ${PID} && 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 '$CMD' instead"
$CMD
;;
upgrade)
if sig USR2 && sleep 2 && sig 0 && oldsig QUIT
then
n=$TIMEOUT
while test -s $old_pid && test $n -ge 0
do
printf '.' && sleep 1 && n=$(( $n - 1 ))
done
echo
if test $n -lt 0 && test -s $old_pid
then
echo >&2 "$old_pid still exists after $TIMEOUT seconds"
exit 1
fi
exit 0
fi
echo >&2 "Couldn't upgrade, starting '$CMD' instead"
$CMD
;;
reopen-logs)
sig USR1
;;
*)
echo >&2 "Usage: $0 <start|stop|restart|upgrade|force-stop|reopen-logs>"
exit 1
;;
esac
Redmine์
http://localhost/redmine/
์ ๊ฐ์ด ์๋ธ๋๋ ํ ๋ฆฌ๋ก ์ฐธ์กฐํ๋ค๋ฉด ๋ค์๊ณผ ๊ฐ์ด config.ru๋ฅผ ํธ์งํด์ผ ํฉ๋๋ค./opt/redmine/config.ru
# This file is used by Rack-based servers to start the application.
RAILS_RELATIVE_URL_ROOT="/redmine"
require ::File.expand_path('../config/environment', __FILE__)
if RAILS_RELATIVE_URL_ROOT then
map RAILS_RELATIVE_URL_ROOT do
run Rails.application
end
else
run Rails.application
end
/redmine
๋ถ๋ถ์ ์์ ์ ํ๊ฒฝ์ผ๋ก ๋์ฒดํ์ญ์์ค.Nginx ์ค์น
ํจํค์ง ์ค์น.
$ sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm # Nginxใฎใใใฑใผใธใใฆใณใญใผใ
$ sudo yum -y install nginx
์ค์ .
๋ณธ๋๋ผ๋ฉด
/etc/nginx/conf.d/redmine.conf
์ ๊ฐ์ด ์จ์ผ ํฉ๋๋ค๋ง, ์ด๋ฒ์ Ubuntu์ ๊ฐ์ด sites-available, sites-enabled๋ฅผ ์์ฑํด ์ค์ ํฉ๋๋ค.$ sudo mkdir -p /etc/nginx/sites-avaliable/ /etc/nginx/sites-enabled/
์๋ Nginx ๊ตฌ์ฑ ํ์ผ.
/etc/nginx/nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/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 /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
#include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
๊ทธ๋ฐ ๋ค์ Redmine ์ฉ ๊ตฌ์ฑ ํ์ผ.
/redmine
๋ฅผ redmine ์ ํ ๋นํ๋ค.๋ SSL ํต์ ์ํค๊ณ ์ถ๊ธฐ ๋๋ฌธ์ SSL ๋์ํ๊ณ ์๋ค.
/etc/nginx/sites-available/redmine
upstream rails-unicorn {
server unix:/var/run/unicorn.sock fail_timeout=0;
}
server {
listen 80;
server_name localhost;
return 301 https://$host$request_uri;
}
server {
listen 443;
server_name localhost;
ssl on;
ssl_certificate /etc/nginx/ssl/redmine.crt;
ssl_certificate_key /etc/nginx/ssl/redmine.key;
ssl_session_timeout 5m;
ssl_protocols SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
ssl_prefer_server_ciphers on;
#listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
root /usr/share/nginx/html/public;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
location /redmine/ {
try_files $uri $uri.html $uri/index.html @rails-unicorn;
}
location ~ ^/assets/(.*) {
alias /opt/redmine/public/assets/$1;
}
location @rails-unicorn {
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_pass http://rails-unicorn;
}
# Only for nginx-naxsi : process denied requests
#location /RequestDenied {
# For example, return an error code
#return 418;
#}
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 /usr/share/nginx/html;
}
}
๊ตฌ์ฑ ํ์ผ ํ์ฑํ.
/etc/nginx/sites-enabled/
์ ์ฌ๋ณผ๋ฆญ ๋งํฌ๋ฅผ ๋ง๋ญ๋๋ค.$ sudo ln -s /etc/nginx/sites-available/redmine /etc/nginx/sites-enabled/
๋ค์์ Redmine์ HTML ํ์ผ์ด๋ CSS๋ฑ์ด ์ ์ฅ๋์ด ์๋ค
/opt/redmine/public
์ ์ฌ๋ณผ๋ฆญ ๋งํฌ๋ฅผ ๋ฌธ์ ๋ฃจํธ ๋ฐ๋ก ์๋์ ์์ฑ$ sudo ln -s /opt/redmine/public/ /usr/share/nginx/html/
Unicorn๊ณผ Nginx ์์.
$ cd /opt/redmine
$ sudo ./script/unicorn.sh start
$ sudo service nginx start
์ก์ธ์ค
์ดํ ๋์ค๋ฉด k.

์ด๊ธฐ ๊ด๋ฆฌ์์ username/password๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
admin/admin
๊ฒฐ๋ก
Redmine2.6์์๋ Wiki๊ฐ Markdown์ ๋์ํ ๊ฒ ๊ฐ๋ค.
์ถ๊ฐ
์๋นํ ๋๋ฝ์ด ์์๊ธฐ ๋๋ฌธ์ ์ถ๊ฐ (2015/02/02)
์ด ๊ธฐ์ฌ๋ฅผ ์ฐธ๊ณ ๋ก ํ๊ฒฝ์ ๊ตฌ์ถํ ์ฌ๋ ์ฃ์กํฉ๋๋ค m(_ _)m
Reference
์ด ๋ฌธ์ ์ ๊ดํ์ฌ(Redmine2.6 + Nginx + CentOS7), ์ฐ๋ฆฌ๋ ์ด๊ณณ์์ ๋ ๋ง์ ์๋ฃ๋ฅผ ๋ฐ๊ฒฌํ๊ณ ๋งํฌ๋ฅผ ํด๋ฆญํ์ฌ ๋ณด์๋ค https://qiita.com/akito1986/items/a0d4d8a7a59c8588e0f1ํ ์คํธ๋ฅผ ์์ ๋กญ๊ฒ ๊ณต์ ํ๊ฑฐ๋ ๋ณต์ฌํ ์ ์์ต๋๋ค.ํ์ง๋ง ์ด ๋ฌธ์์ URL์ ์ฐธ์กฐ URL๋ก ๋จ๊ฒจ ๋์ญ์์ค.
์ฐ์ํ ๊ฐ๋ฐ์ ์ฝํ
์ธ ๋ฐ๊ฒฌ์ ์ ๋
(Collection and Share based on the CC Protocol.)
์ข์ ์นํ์ด์ง ์ฆ๊ฒจ์ฐพ๊ธฐ
๊ฐ๋ฐ์ ์ฐ์ ์ฌ์ดํธ ์์ง
๊ฐ๋ฐ์๊ฐ ์์์ผ ํ ํ์ ์ฌ์ดํธ 100์ ์ถ์ฒ ์ฐ๋ฆฌ๋ ๋น์ ์ ์ํด 100๊ฐ์ ์์ฃผ ์ฌ์ฉํ๋ ๊ฐ๋ฐ์ ํ์ต ์ฌ์ดํธ๋ฅผ ์ ๋ฆฌํ์ต๋๋ค