A: Introduction
Tomcat handles dynamic requests in highly concurrent environments with low performance and is more vulnerable to handling static pages. Although the latest version of Tomcat supports Epoll, it is much better to handle static pages through Nginx than with Tomcat.
Two: Download the installation (take the Windows environment as an example)
1. Download Address
Download Address: Click here
2. Directory structure
Nginx- |_ conf 配置目录 |_ contrib |_ docs 文档目录 |_ logs 日志目录 |_ temp 临时文件目录 |_ html 静态页面目录 |_ nginx.exe 主程序
Three: Start and stop Nginx service
CMD into Nginx unzip directory
Execute start Nginx to start the service (either Nginx or Nginx.exe)
It is recommended to use the first type,
The other two will keep your cmd window in execution and cannot be manipulated by other commands
Perform nginx-s stop to stop Nginx service
Execute nginx-t to check that the Nginx configuration file is correct.
Four: nginx main configuration file nginx.conf
For all profile downloads, please click here
#Nginx所用用户和组#user NIUMD NIUMD;#工作的子进程数量 (usually equal to the number of CPUs or twice times the CPU)Worker_processes2;#错误日志存放路径#error_log Logs/error.log;#error_log logs/error.log notice;Error_log Logs/error.log Info;#指定pid存放文件PID Logs/nginx.pid;events {#使用网络IO模型linux建议epoll, FreeBSD recommends using Kqueue#use Epoll;#允许最大连接数Worker_connections2048;} HTTP {includeMime.types; Default_type Application/octet-stream;#定义日志格式#log_format main ' $remote _addr-$remote _user [$time _local] $request '# ' $status ' $body _bytes_sent "$http _referer" '# ' "$http _user_agent" "$http _x_forwarded_for" ';#access_log off;Access_log Logs/access.log; Client_header_timeout3M Client_body_timeout3M Send_timeout3M Client_header_buffer_size1K Large_client_header_buffers44K Sendfile on; Tcp_nopush on; Tcp_nodelay on;#keepalive_timeout;includegzip.conf; Upstream localhost {server localhost:8080weight=5; Server localhost:9091weight=1; } Server {Listen the; server_name localhost; Location/{Proxy_connect_timeout3; Proxy_send_timeout -; Proxy_read_timeout -; Proxy_pass http://localhost; } }}
V: Load Balancing weight configuration
upstream localhost { server localhost:8080 weight=5; server localhost:9091 weight=1; }
'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
'). Text (i)); }; $numbering. FadeIn (1700); }); });
The above describes the Nginx load balancing configuration, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.