nginx常用变量

一、安装命令:

--prefix=path:配置nginx安装部署的根目录,也就是工作目录。默认是:/usr/local/nginx/,便于一个系统可以配置多种nginx

--with-stream: 启用nginx的stream模块,让nginx直接启动tcp/udp协议

--with-threads:启动nginx线程池机制

--with-pcre=dir ,--with-openssl=dir:指定自己安装的pcre(正则表达式)源码和ssl(https源码)地址

--with-xxx_module:启用xxx功能模块

--without-xxx_module:关闭xxx功能模块

--add-module=path:增加某个模块,path指定源码目录

--add-dynamic-module=path:增加动态模块,path指定源码目录,编译后会生成*.so形式的动态库,nginx.conf需要引入这个动态模块:load_module path;path为动态模块路径

--with-dubge:启动dubug模式,输出dubug及其级别以上的信息,级别dubug最低

二、nginx.conf配置变量

#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;//系统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;//监听端口

        resolver:114.114.114.114//dns服务器解析地址

        server_name  localhost;//虚拟主机名称如:ip、域名

        #charset koi8-r;//HTTP请求字节码格式

        #access_log  logs/host.access.log  main;//http请求日志文件

        location / {

            root  html;//根目录

            index  index.html index.htm;//默认文件地址

             proxy_pass  http://127.0.0.1;//代理服务器请求地址

        }

        #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;

    #    }

    #}

}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。