Skip to content

Instantly share code, notes, and snippets.

@usutani
Last active August 29, 2015 13:59
Show Gist options
  • Save usutani/10695225 to your computer and use it in GitHub Desktop.
Save usutani/10695225 to your computer and use it in GitHub Desktop.
CentOS + Nginx + Unicorn + Oracle XE + Railsの設定
  • CentOS 6.4 64bit
  • Nginx + Unicorn
  • Ruby(RVM) + Rails
  • Oracle Database XE 11.2

同一マシンでOracleを動かす

  1. How To Deploy Rails Apps Using Unicorn And Nginx on CentOS 6.5
  2. CentOS 6.4 に Oracle Database XE をインストール

Oracle の設定時、ポート8080が衝突するので8081に変更する。

ruby-oci8 gem のインストール(ビルド)前に LD_LIBRARY_PATH を設定する。

cat /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh >> .bash_profile
vi ~/.bash_profile
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH

Nginxのメモ

chkconfig nginx on

Unicornのメモ

bundle exec unicorn_rails -c config/unicorn.rb -D
kill -QUIT `cat /var/www/my_app/pids/unicorn.pid`
kill -USR2

bundle exec rake assets:precompile RAILS_ENV=production
bundle exec unicorn_rails -c config/unicorn.rb -E production -D
tail -f /var/www/ora_demo/log/unicorn.log
@usutani
Copy link
Author

usutani commented Apr 15, 2014

ssl
vi /etc/nginx/conf.d/default.conf

upstream app_server {
    # Path to Unicorn SOCK file
    server unix:/tmp/unicorn.vpp.sock fail_timeout=0;
}

server {
    listen 443 ssl;

    ssl_certificate      /etc/nginx/ssl/server.crt;
    ssl_certificate_key  /etc/nginx/ssl/server.key;

    # Application root
    root /root/vpp/public;

    try_files $uri/index.html $uri @app;

    location / {
        proxy_set_header X-Forwarded-Proto $scheme;
        if (-f $request_filename) { break; }

        # 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_redirect off;
        proxy_pass http://app_server;
    }

    error_page 500 502 503 504 /500.html;
    client_max_body_size 4G;
    keepalive_timeout 10;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment