Professional Documents
Culture Documents
CitRedminetrnCentOSviNginxvUnicornZonmobLabs
Zonmob Labs
Bncthcmc?Hytmkimnhngbivithuch!
SEARCH
ng nhp
Username
Bi c Hiu
Redmine
Password
Remember Me
Login
Lost Password
Bi vit ph bin
1. Mi trng ci t
vi Nginx v Unicorn
OS: CentOS 7
http://labs.zonmob.com/redmine/caidatredminetrencentosvoinginxvaunicorn.html
1/16
5/5/2016
CitRedminetrnCentOSviNginxvUnicornZonmobLabs
Ruby: 2.1.5
Redmine: 2.6.1
Nginx: 1.6.2
Unicorn: 4.8.3
2. Ci t cc gi ph thuc ca Redmine
Bi vit mi nht
3. Ci t Ruby
Ti sao email ca ti li vo
th mc spam?
Ci t cc gi ph thuc cn thit
1 $ sudo yum -y groupinstall "Development Tools"
2 $ sudo yum -y install openssl-devel readline-devel zlib-devel curl-devel libyaml
3 $ sudo yum -y install ImageMagick ImageMagick-devel ipa-pgothic-fonts
Ch
Agile
1
2
3
4
$
$
$
$
cd /usr/local/
sudo git clone git://github.com/sstephenson/rbenv.git rbenv
mkdir -p rbenv/shims rbenv/versions
sudo groupadd /usr/local/rbenv
http://labs.zonmob.com/redmine/caidatredminetrencentosvoinginxvaunicorn.html
Git
Linux
2/16
5/5/2016
CitRedminetrnCentOSviNginxvUnicornZonmobLabs
5
6
7
8
$
$
$
$
Redmine
Testing QA
Unity
1 export RBENV_ROOT="/usr/local/rbenv"
2 export PATH="/usr/local/rbenv/bin:$PATH"
3 eval "$(rbenv init -)"
1
2
3
4
5
6
7
8
9
10
11
12
Zimbra
$ 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]
$
Ci t Bundler
1 $ sudo gem install bundler --no-rdoc --no-ri
2 $ bundle --version
3 Bundler version 1.7.12
4. Thit lp MariaDB
Thit lp cu hnh cho MariaDB lu ti/etc/my.cnf
1 [mysqld]
2 datadir=/data/mysql # Th mc d liu, bt k
http://labs.zonmob.com/redmine/caidatredminetrencentosvoinginxvaunicorn.html
3/16
5/5/2016
CitRedminetrnCentOSviNginxvUnicornZonmobLabs
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
To th mc cha d liu v ci t.
1
2
3
4
$
$
$
$
sudo
sudo
sudo
sudo
$ 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.
http://labs.zonmob.com/redmine/caidatredminetrencentosvoinginxvaunicorn.html
4/16
5/5/2016
CitRedminetrnCentOSviNginxvUnicornZonmobLabs
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
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
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.
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Cleaning up...
http://labs.zonmob.com/redmine/caidatredminetrencentosvoinginxvaunicorn.html
5/16
5/5/2016
CitRedminetrnCentOSviNginxvUnicornZonmobLabs
57
58
59
60
All done!If you've completed all of the above steps, your MariaDB
installation should now be secure.
$ mysql -u root -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
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)
5. Ci t Redmine
Ti v m ngun Redmine t trang ch vto mt lin kt sang /opt.
1
2
3
4
$
$
$
$
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 # To mt lin kt tng trng
http://labs.zonmob.com/redmine/caidatredminetrencentosvoinginxvaunicorn.html
6/16
5/5/2016
CitRedminetrnCentOSviNginxvUnicornZonmobLabs
# 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
$
$
$
$
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
6. Ci t Unicorn
Ci t Unicorn bng cch chnh saGemle (/opt/redmine) v thm vo on
di y,
http://labs.zonmob.com/redmine/caidatredminetrencentosvoinginxvaunicorn.html
7/16
5/5/2016
CitRedminetrnCentOSviNginxvUnicornZonmobLabs
/opt/redmine/Gemle
1 gem 'unicorn', '4.8.3'
Ri chy bundle.
1 $ bundle install
http://labs.zonmob.com/redmine/caidatredminetrencentosvoinginxvaunicorn.html
8/16
5/5/2016
CitRedminetrnCentOSviNginxvUnicornZonmobLabs
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
# Sock
listen'/var/run/unicorn.sock'
pid '/var/run/unicorn.pid'
# Log
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
#!/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"
http://labs.zonmob.com/redmine/caidatredminetrencentosvoinginxvaunicorn.html
9/16
5/5/2016
CitRedminetrnCentOSviNginxvUnicornZonmobLabs
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
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
http://labs.zonmob.com/redmine/caidatredminetrencentosvoinginxvaunicorn.html
10/16
5/5/2016
CitRedminetrnCentOSviNginxvUnicornZonmobLabs
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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
http://labs.zonmob.com/redmine/caidatredminetrencentosvoinginxvaunicorn.html
11/16
5/5/2016
CitRedminetrnCentOSviNginxvUnicornZonmobLabs
Cc bn gc nu /etc/nginx/conf.d/redmine.conf Lm th no c th nh vy nn
vit nh, cc trang web c sn thi gian ny trong cng mt cch nh Ubuntu, bn
c th to v cu hnh cc trang web cho php.
1 $ sudo mkdir -p /etc/nginx/sites-avaliable/ /etc/nginx/sites-enabled/
usernginx;
worker_processes1;
error_log/var/log/nginx/error.log warn;
pid/var/run/nginx.pid;
events {
worker_connections1024;
}
http {
include /etc/nginx/mime.types;
default_typeapplication/octet-stream;
access_log/var/log/nginx/access.logmain;
sendfileon;
#tcp_nopush on;
keepalive_timeout65;
http://labs.zonmob.com/redmine/caidatredminetrencentosvoinginxvaunicorn.html
12/16
5/5/2016
CitRedminetrnCentOSviNginxvUnicornZonmobLabs
27
28
29
30
31
32
#gzipon;
#include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
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;
#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;
http://labs.zonmob.com/redmine/caidatredminetrencentosvoinginxvaunicorn.html
13/16
5/5/2016
CitRedminetrnCentOSviNginxvUnicornZonmobLabs
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
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;
}
14/16
5/5/2016
CitRedminetrnCentOSviNginxvUnicornZonmobLabs
About LatestPosts
Bi c Hiu
No related posts.
Leave a Reply
Your email address will not be published. Required elds are marked *
http://labs.zonmob.com/redmine/caidatredminetrencentosvoinginxvaunicorn.html
15/16
5/5/2016
CitRedminetrnCentOSviNginxvUnicornZonmobLabs
Name *
Email *
Website
PostComment
http://labs.zonmob.com/redmine/caidatredminetrencentosvoinginxvaunicorn.html
16/16