Skip to content

Instantly share code, notes, and snippets.

@niaeashes
Created December 2, 2015 10:53
Show Gist options
  • Save niaeashes/9a7c8acfc7b0c6a8b391 to your computer and use it in GitHub Desktop.
Save niaeashes/9a7c8acfc7b0c6a8b391 to your computer and use it in GitHub Desktop.
## Install
### CentOS 7.x
#### Install basic packages
```
yum update -y
rpm -ivh http://packages.groonga.org/centos/groonga-release-1.1.0-1.noarch.rpm
yum install -y nginx openssl openssl-devel mariadb-server mariadb-devel groonga groonga-tokenizer-mecab nodejs npm mongodb mongodb-server
yum install -y gcc make
```
#### Install Ruby 2.1
```
cd /usr/local/src
echo 'df795f2f99860745a416092a4004b016ccf77e8b82dec956b120f18bdc71edce' > checksum
curl https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.3.tar.gz -o ruby-2.2.3.tar.gz
openssl sha256 ruby-2.2.3.tar.gz >> checksum
cat checksum
tar -zxvf ruby-2.2.3.tar.gz
cd ruby-2.2.3
./configure
make
make install
cd ~
gem install bundler
```
#### Startup Server
```
systemctl enable nginx
systemctl enable mariadb
systemctl enable mongod
mkdir /var/application
chown nia:nia /var/application
chmod g+s /var/application
```
Setup Nginx
```unicorn.conf
upstream unicorn {
server unix:/var/application/current/tmp/unicorn.socket;
}
server {
listen 80 default_server;
server_name example.com;
access_log /var/application/shared/log/nginx_access.log;
error_log /var/application/shared/log/nginx_error.log;
root /var/application/current/public;
client_max_body_size 100m;
error_page 404 /404.html;
error_page 500 502 503 504 /500.html;
try_files $uri/index.html $uri @unicorn;
location @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://unicorn;
}
}
```
#### Systemd Service File
```
[Unit]
Description=Unicorn Server
[Service]
WorkingDirectory=/var/application/current
Environment=RAILS_ENV=production
SyslogIdentifier=nonono-unicorn
PIDFile=/var/application/currenttmp/pids/unicorn.pid
ExecStart=/usr/local/bin/bundle exec "unicorn_rails -c config/unicorn.rb -E production"
ExecStop=/usr/bin/kill -QUIT $MAINPID
ExecReload=/bin/kill -USR2 $MAINPID
[Install]
WantedBy=multi-user.target
```
#### Deploy
on Local machine.
```
bundle exec cap production deploy
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment