Home > Backend Development > PHP Tutorial > Rails+nginx server deployment

Rails+nginx server deployment

WBOY
Release: 2016-07-30 13:31:25
Original
1116 people have browsed it

  1. The native nginx server does not meet the conditions for rails deployment, so nginx rewritten by passenger needs to be used.

    ps:

    • The model for rails to accept requests is that one process handles one request, and the efficiency of a single process is relatively low , generally need to open multiple processes
    • passenger is a Rails application service management tool, which can uniformly manage the number of rails processes, life cycle, request queue, etc.
    • nginx is a high-performance web server, because nginx handles links and static resources The ability is very strong, so nginx is usually placed before rails to accept client requests. The relationship is as shown below. Install passenger. Since nginx does not support dynamic module loading, passenger must be used. Compile and install nginx modified by passenger
    <code>
        #安装passenger
           gem install passenger
        #接下来安装nginx
          passenger-install-nginx-module
        #ps:记得在安装过程中选择1,即完整安装
     </code>
    Copy after login
  2. 3. After the installation is completed, the system will prompt that the directory where nginx is installed, under centos7, is installed under /opt/nginx by default, and the configuration file is under /opt/nginx/conf/ by default. nginx.conf
    Rails+nginx server deployment4. Configure nginx (the most important part)
  3. sudo nano /opt/nginx/conf/nginx.conf
  4. <code>
       {
           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;
      }    
    }     
    </code>
    Copy after login

    4. Start nginx to access (refer to my blog shell command under linux , taking starting and stopping nginx as an example)

    5. Several nginx commands

    <code>
       #启动
       sudo nginx
       #停止
       sudo nginx -s stop
       #重启
       sudo nginx -s reload
    </code>
    Copy after login
    6. Part of the information in the article refers to using passenger to deploy nginx+Ruby on Rails on Centos7

    Copyright statement: This article is an original article by the blogger and may not be reproduced without the permission of the blogger.


    The above introduces the Rails+nginx server deployment, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template