- cd /usr/local/nginx/conf/
- [[email protected] conf]# ls
- fastcgi.conf koi-utf nginx.conf uwsgi_params
- fastcgi.conf.default koi-win nginx.conf.default uwsgi_params.default
- fastcgi_params mime.types scgi_params win-utf
- fastcgi_params.default mime.types.default scgi_params.default
2,Nginx 配置文件组成 (三部分组成: 全局块, events 快, http 块)
- #user nobody;
- worker_processes 1;
- #error_log logs/error.log;
- #error_log logs/error.log notice;
- #error_log logs/error.log info;
- #pid logs/nginx.pid;
- events {
- worker_connections 1024;
- }
- http {
- include 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 logs/access.log main;
- sendfile on;
- #tcp_nopush on;
- #keepalive_timeout 0;
- keepalive_timeout 65;
- #gzip on;
- server {
- listen 80;
- server_name localhost;
- #charset koi8-r;
- #access_log logs/host.access.log main;
- location / {
- root html;
- index index.HTML index.htm;
- }
- #error_page 404 /404.HTML;
- # redirect server error pages to the static page /50x.HTML
- #
- error_page 500 502 503 504 /50x.HTML;
- location = /50x.HTML {
- root HTML;
- }
- # proxy the PHP scripts to Apache listening on 127.0.0.1:80
- #
- #location ~ \.PHP$ {
- # proxy_pass http://127.0.0.1;
- #}
- # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
- #
- #location ~ \.PHP$ {
- # root HTML;
- # fastcgi_pass 127.0.0.1:9000;
- # fastcgi_index index.PHP;
- # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
- # include fastcgi_params;
- #}
- # deny access to .htaccess files, if Apache's document root
- # concurs with nginx's one
- #
- #location ~ /\.ht {
- # deny all;
- #}
- }
- # another virtual host using mix of IP-, name-, and port-based configuration
- #
- #server {
- # listen 8000;
- # listen somename:8080;
- # server_name somename alias another.alias;
- # location / {
- # root HTML;
- # index index.HTML index.htm;
- # }
- #}
- # HTTPS server
- #
- #server {
- # listen 443 ssl;
- # server_name localhost;
- # ssl_certificate cert.pem;
- # ssl_certificate_key cert.key;
- # ssl_session_cache shared:SSL:1m;
- # ssl_session_timeout 5m;
- # ssl_ciphers HIGH:!aNULL:!MD5;
- # ssl_prefer_server_ciphers on;
- # location / {
- # root HTML;
- # index index.HTML index.htm;
- # }
- #}
- }
(1) 全局块: 设置影响 Nginx 整体运行的服务指令, 主要包括 Nginx 服务器的用户 (组), 允许生成的 wokers process 数, 进程 PID 存放路径, 日志存放路径和类型以及配置文件的引入等
例子:
worker_processes 1;# 这个参数配置越大, 处理并发量越多
(2)events 块: events 会涉及的指令主要影响 Nginx 服务器用户网络连接
例子:
worker_connections 1024;# 支持的最大连接数模块的配置都在这里
(3)http 块: 配置最平凡的部分, 代理, 缓存, 和日志定义的绝大多数功能和第三方
(3.1) 全局块
(3.2)server 块
(3.2.1) 全局 server 块
(3.2.2)location 块
来源: http://www.bubuko.com/infodetail-3282661.html