: This article describes how to deploy the Rails + nginx server. if you are interested in the PHP Tutorial, refer to it.
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:
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.