Nginx入门教程

来源:互联网 发布:木工软件 编辑:程序博客网 时间:2024/06/01 22:28

下载nginx

http://nginx.org/en/download.html

解压

这里写图片描述

常用命令

启动: start nginx
重启:nginx -s reload
终止:nginx -s stop

配置文件

这里只说明nginx.conf文件

#全局变量worker_processes  1;error_log  logs/error.log;error_log  logs/error.log  notice;error_log  logs/error.log  info;# 工作链接数events {    worker_connections  1024;}# http监听http {    #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;    #多个代理模块 可以设置分发权重   upstream mkxweb {   #     sticky;        server 127.0.0.1:8082;# tomcat开放的端口    }    #监听服务模块  可以通过正则进行匹配    server {        listen       80;#端口  用户访问使用的端口        server_name  localhost; #保持默认local即可        #一般情况proxy_pass 配合upstream使用  在配合tomcat的时候需要使用          location / {            proxy_pass http://mkxweb;           # root   d:\webappdir;           # index  index.html index.htm;        }        #通过正则 拦截包含 /image/的请求  转换资源地址        location ^~ /image/ {            root  e:/fileproxy;        }        location ~ /.*\.(mp4|flv|mov|MOV|avi)$ {            root e:/fileproxy/video;        }        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;        }         }}

日志文件

access.log #正常通过的日志
error.log #错误日志
nginx.pid #nginx用户id

阅读全文
0 0
原创粉丝点击