Windows 下载、安装、配置 Nginx1.18.0

Nginx下载

nginx官方下载页

Windows 下载、安装、配置 Nginx1.18.0_第1张图片
nginx的Windows版简介:

Version of nginx for Windows uses the native Win32 API (not the Cygwin emulation layer). Only the and (1.15.9) connection processing methods are currently used, so high performance and scalability should not be expected. Due to this and some other known issues version of nginx for Windows is considered to be a beta version. At this time, it provides almost the same functionality as a UNIX version of nginx except for XSLT filter, image filter, GeoIP module, and embedded Perl language. select()poll()

安装与启动

将下载好的文件,在合适的地方进行解压,解压后,打开文件夹,双击nginx即可启动nginx文件:
Windows 下载、安装、配置 Nginx1.18.0_第2张图片

nginx命令

# 查看帮助信息
nginx -h
# 查看nginx版本
nginx -v
# 启动nginx
start nginx
# 关闭nginx,完整有序的停止nginx,保存相关信息
nginx -s quit
# 关闭nginx,快速停止nginx,可能不保存相关信息
nginx -s stop
# 重新载入nginx,当配置信息需要重新加载配置时使用
nginx -s reload
# 测试nginx配置文件是否正确
nginx -t -c filename
# 重新打开日志文件
nginx -s reopen

修改nginx配置

解压文件夹下:
/conf/nginx.conf
文件即是nginx配置文件;

#user  nobody;
# worker_processes指明了nginx要开启的进程数,官方的建议是修改成CPU的内核数;
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       8080;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

		# 原始代码
        # location / {
        #     root   html;
        #     index  index.html index.htm;
        # }
        # 设置代理
        location / {
            proxy_pass http://localhost:8001;
        }
        location /api/ {
            proxy_pass http://localhost:8000;
            proxy_set_header Host $host;
        }

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

}

你可能感兴趣的:(nginx)