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