Unicorn + nginx + centos deployment and server configuration

Source: Internet
Author: User
To deploy the dashboard on the server, we also need a server to run the ruby program. unicorn is used here. The world of Unicorn configuration is reminiscent of gunicorn used to deploy python. The following are from the Internet. Unicorn is the Rack application. to deploy the dashboard to the server, we also need a server to run the ruby program. here we use unicorn. The world of Unicorn configuration is reminiscent of gunicorn used to deploy python. The following are from the Internet. Unicorn is an HTTP server designed for Rack applications. it is a low-latency, high-bandwidth client service developed using advanced Unix features. Original article: http://www.phodal.com/blog/unicorn-nginx-ruby-centos-deploy-configure/install Unicorn
gem install unicorn
Configure unicorn
#-*-Encoding: UTF-8-*-root_path = File. expand_path '.. /', File. dirname (_ FILE _) # log log_file = root_path + '/log/unicorn. log 'err _ log = root_path + '/log/unicorn_error.log' # process ID pid_file = '/tmp/unicorn_padrino.pid 'old _ pid = pid_file + '. oldbin '# Channel socket_file ='/tmp/unicorn_padrino.sock 'worker _ processes 6working_directory root_pathtimeout 30 # listen to listen 8080, tcp_nopush: falselisten socket_file, Backlog: 1024pid logs log_filepreload_app truebefore_exec do | server | ENV ['bundle _ gemfile'] = root_path + '/gemfile' endbefore _ fork do | server, worker | if File. exists? (Old_pid) & server. pid! = Old_pid begin Process. kill ('quit', File. read (old_pid ). to_ I) rescue Errno: ENOENT, Errno: ESRCH puts "Send 'quit' signal to unicorn error! "End
Configure the proxy used in nginx.
upstream app_server {    server unix:/tmp/unicorn_padrino.sock fail_timeout=0;}server {    listen   80;    charset  utf-8;    server_name  dashboard.phodal.com;    keepalive_timeout 5;    root        /home/www/iot-dashboard;    access_log  /home/www/iot-dashboard/log/nginx_access.log;    error_log   /home/www/iot-dashboard/log/nginx_error.log;    rewrite_log on;    location ~* ^/(images|javascripts|stylesheets|img)/  {        access_log    off;        log_not_found off;        expires       max;        break;    }    location / {        proxy_set_header Host               $host;        proxy_set_header X-Forwarded-Host   $host;        proxy_set_header X-Forwarded-Server $host;        proxy_set_header X-Real-IP          $remote_addr;        proxy_set_header X-Forward-For      $proxy_add_x_forwarded_for;        proxy_buffering  on;        proxy_redirect   off;        if (!-f $request_filename) {            proxy_pass http://app_server;            break;        }     }}
Create script

This part comes from the internet

#!/bin/sh# rvm wrapper ruby-1.9.3-p194 bootupUNICORN=unicornCONFIG_FILE=/home/www/iot-dashboard/config/unicorn.rbAPP_HOME=/home/www/iot-dashboardcase "$1" in      start)          $UNICORN -c $CONFIG_FILE -E production -D            ;;      stop)          kill -QUIT `cat /tmp/unicorn_padrino.pid`            ;;      restart|force-reload)            kill -USR2 `cat /tmp/unicorn_padrino.pid`              ;;      *)           echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2              exit 3                 ;;    esac:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.