官术网_书友最值得收藏!

  • NGINX Cookbook
  • Tim Butler
  • 249字
  • 2021-07-03 00:04:19

How to do it...

By default, NGINX will have two main configuration files. The first is /etc/nginx/nginx.conf, which contains the main server configuration. The second is /etc/nginx/default.conf, which defines a basic site out of the box for you.

Warning: Don't just increase values expecting a higher performance.

Before you make any changes, be 100 percent sure that you understand the implications. Out of the box, NGINX is a highly performant web server which already gives great performance. The age-old programmer's saying that premature optimization is the root of all evil continually rings true here. Simply increasing some figures may lead to increased memory usage, decreased stability, and decreased performance. In Chapter 11, Performance Tuning, we'll go through some of the more advanced areas to tweak, but make sure to hit limits before attempting this.

Here's the default configuration:

user  nginx;
worker_processes 1; 
 
error_log  /var/log/nginx/error.log warn; 
pid        /var/run/nginx.pid; 
 
events { 
    worker_connections  1024; 
} 
 
http { 
    include       /etc/nginx/mime.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 /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; }

The configuration files have two main components in them—simple directives and block directives. Simple directives are one-line items which are simple name and value, followed by a semicolon (;). A block directive has a set of brackets and allows configuration items to be set within a specific context. This makes the configuration files easier to follow, especially as they get more complex.

主站蜘蛛池模板: 寿光市| 沅陵县| 磴口县| 东港市| 沁阳市| 仁怀市| 潼南县| 吉安市| 涞源县| 星座| 灵台县| 林芝县| 万安县| 靖远县| 旺苍县| 孙吴县| 台中县| 饶平县| 钟祥市| 宁河县| 宜君县| 大余县| 石渠县| 柳河县| 什邡市| 白水县| 湟源县| 霍林郭勒市| 松阳县| 梧州市| 湟中县| 卢龙县| 长乐市| 章丘市| 水富县| 文化| 孟州市| 汕头市| 弥渡县| 开远市| 滨州市|