Rails + nginx server deployment

Source: Internet
Author: User
Tags ruby on rails
: This article describes how to deploy the Rails + nginx server. if you are interested in the PHP Tutorial, refer to it.
  1. The native nginx server does not meet the conditions for deploying rails. Therefore, you need to use the nginx modified by passenger.

    Ps:

    • Rails's request receiving model is a process that processes a request. a single process is inefficient and generally requires multiple processes to be enabled.
    • Passenger is a management tool for Rails application services. it can manage the number, lifecycle, and request queue of rails processes in a unified manner.
    • Nginx is a high-performance web server. due to the strong capability of nginx to process links and static resources, nginx is generally placed before rails to accept client requests.
    • Its relationship is as follows:
  2. Install passernger. because nginx does not support dynamic module loading, passernger must be used for compilation and installation of nginx modified by passenger.

    # Install passenger gem install passenger # install nginx passenger-install-nginx-module # ps: Remember to select 1 during installation to complete installation.

    3. after the installation is complete, the system will prompt that the nginx installation directory is installed under/opt/nginx by default under centos7, and the configuration file is/opt/nginx/conf/nginx by default. conf

    4. Configure nginx (the most important part)

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

    {Worker_processes 1; events {worker_connections 1024;} http {# passenger_root/usr/local/rvm/gems/ruby-2.2.1/gems/passenger-5.0.10 set by passenger; 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 {# listener Port listen 80; server_name 127.0.0.1; # web root directory, it must be public root/var/www/furui_hisms/ironmine/public/under the rails project; # Be sure to set this option to on passenger_enabled on ;}}

    4. start nginx to access nginx (refer to my blog linux shell command to stop nginx from being started as an instance)
    5. several nginx commands

    # Start sudo nginx # stop sudo nginx-s stop # restart sudo nginx-s reload

    6. For more information, see deploy nginx + Ruby on Rails on Centos7 using passenger.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

The above introduces the Rails + nginx server deployment, including some content, and hope to be helpful to friends who are interested in the PHP Tutorial.

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.