Rails+nginx Server Deployment

Source: Internet
Author: User
Tags app service nginx server ruby on rails
  1. The native Nginx server does not meet the requirements of rails deployment and therefore requires the use of passenger-rewritten nginx.

    Ps:

    • Rails accepts the requested model as a process that processes a request, a single process is less efficient, and typically requires multiple processes to be opened
    • Passenger is the Rails app service Management tool that can manage the number of rails processes, lifecycle, request queue, etc.
    • Nginx is a high-performance Web server, because Nginx processing links and static resources are very strong, so generally before rails put Nginx to accept client requests
    • The relationship is as
  2. Install Passernger, because Nginx does not support dynamic module loading, so use passenger to compile and install the Nginx modified by passenger

        #安装passenger       gem install passenger    #接下来安装nginx      passenger-install-nginx-module    

    3. After the installation is complete, the system will prompt, the Nginx installation directory, under CENTOS7 is installed under/opt/nginx, the configuration file is the default in/opt/nginx/conf/nginx.conf

    4. Configure Nginx (the most important part)

    sudo nano /opt/nginx/conf/nginx.conf

       {       worker_processes  1;events {      worker_connections  1024;}http {    #这里是由passenger自己设置的  passenger_root /usr/local/rvm/gems/ruby-2.2.1/gems/passenger-5.0.10;  passenger_ruby /usr/local/rvm/gems/ruby-2.2.1/wrappers/ruby;  include       mime.types;  default_type  application/octet-stream;  sendfile        on;  keepalive_timeout  65;  server {      #监听的端口      listen       80;      server_name  127.0.0.1;      #web根目录,一定是rails项目下的public      root /var/www/furui_hisms/ironmine/public/;      #一定要记得将这个选项设置为on      passenger_enabled on;  }    }     

    4. Start Nginx to access (refer to my blog under the Linux shell command, is to start to stop Nginx as an instance)
    5. Several nginx commands

       #启动   sudo nginx   #停止   sudo nginx -s stop   #重启   sudo nginx -s reload

    6. The article part of the information is referenced from the use of passenger in CENTOS7 deployment Nginx+ruby on Rails

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

The above describes the Rails+nginx server deployment, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.