Nginx

想了解nginx的代理能够先看这篇:php

https://baijiahao.baiducom/s?id=1652608869911988442&wfr=spider&for=pchtml

  •  nginx经常使用命令

nginx  -t  ##检查配置文件,通常修改完配置文件都建议必定先执行这条命令检查一下,无误再继续下一步
nginx –s reload   ##从新加载配置文件,动态加载使你能够不用重启nginxnginx

nginx -s reopen            # 重启 Nginx
nginx -s stop              # 中止 Nginx
  •  nginx配置

咱们能够打开nginx的配置文件 nginx.conf 先看看session

#user  nobody;   #Nginx用户及组:用户 组。window下不指定
worker_processes  1;    #工做进程:数目。根据硬件调整,一般等于CPU数量或者2倍于CPU。

#错误日志:存放路径。
#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       8088;
        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;
    #    }
    #}

}
events模块配置:
 events事件指令是设定Nginx的工做模式及链接数上限。每一个配置选项的含义解释以下:
a、use
如:use epoll;
use是事件模块指令,用来指定Nginx的工做模式。Nginx支持的工做模式有select、poll、kqueue、epoll、rtsig和/dev/poll 。其中select 和poll 都是标准的工做模式,kqueue和epoll是高效的工做模式,不一样的是epoll用在Linux平台上,而kqueue用在BSD系统中。对于Linux系统,epoll工做模式是首选。


b、worker_connections
如:worker_connections65536;

work_connections也是个事件模块指令,用于定义Nginx每一个进程的最大链接数,默认是1024。
相关文章
相关标签/搜索