Rails+nginx server deployment
-
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- 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
4. Configure nginx (the most important part)
-
<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 login4. Start nginx to access (refer to my blog shell command under linux , taking starting and stopping nginx as an example)
5. Several nginx commands6. Part of the information in the article refers to using passenger to deploy nginx+Ruby on Rails on Centos7<code> #启动 sudo nginx #停止 sudo nginx -s stop #重启 sudo nginx -s reload </code>
Copy after login
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.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to configure Nginx in Windows? Install Nginx and create a virtual host configuration. Modify the main configuration file and include the virtual host configuration. Start or reload Nginx. Test the configuration and view the website. Selectively enable SSL and configure SSL certificates. Selectively set the firewall to allow port 80 and 443 traffic.

You can query the Docker container name by following the steps: List all containers (docker ps). Filter the container list (using the grep command). Gets the container name (located in the "NAMES" column).

Docker container startup steps: Pull the container image: Run "docker pull [mirror name]". Create a container: Use "docker create [options] [mirror name] [commands and parameters]". Start the container: Execute "docker start [Container name or ID]". Check container status: Verify that the container is running with "docker ps".

How to confirm whether Nginx is started: 1. Use the command line: systemctl status nginx (Linux/Unix), netstat -ano | findstr 80 (Windows); 2. Check whether port 80 is open; 3. Check the Nginx startup message in the system log; 4. Use third-party tools, such as Nagios, Zabbix, and Icinga.

Create a container in Docker: 1. Pull the image: docker pull [mirror name] 2. Create a container: docker run [Options] [mirror name] [Command] 3. Start the container: docker start [Container name]

The methods that can query the Nginx version are: use the nginx -v command; view the version directive in the nginx.conf file; open the Nginx error page and view the page title.

How to configure an Nginx domain name on a cloud server: Create an A record pointing to the public IP address of the cloud server. Add virtual host blocks in the Nginx configuration file, specifying the listening port, domain name, and website root directory. Restart Nginx to apply the changes. Access the domain name test configuration. Other notes: Install the SSL certificate to enable HTTPS, ensure that the firewall allows port 80 traffic, and wait for DNS resolution to take effect.

Starting an Nginx server requires different steps according to different operating systems: Linux/Unix system: Install the Nginx package (for example, using apt-get or yum). Use systemctl to start an Nginx service (for example, sudo systemctl start nginx). Windows system: Download and install Windows binary files. Start Nginx using the nginx.exe executable (for example, nginx.exe -c conf\nginx.conf). No matter which operating system you use, you can access the server IP
