源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

Windows Server 2016 Nginx 安装配置详细图文教程

  • 时间:2021-01-08 00:21 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:Windows Server 2016 Nginx 安装配置详细图文教程
[img]http://files.jb51.net/file_images/article/201708/2017080622334868.png[/img]
[b]1、下载Nginx[/b] 官网地址: [url=http://nginx.org/]http://nginx.org/[/url] 下载地址: [url=http://nginx.org/en/download.html]http://nginx.org/en/download.html[/url]  [img]http://files.jb51.net/file_images/article/201708/2017080622334869.png[/img] 2、下载Windows Service Wrapper 官网地址: [url=https://github.com/kohsuke/winsw/]https://github.com/kohsuke/winsw/[/url] 下载地址: [url=http://repo.jenkins-ci.org/releases/com/sun/winsw/winsw/]http://repo.jenkins-ci.org/releases/com/sun/winsw/winsw/[/url] [img]http://files.jb51.net/file_images/article/201708/2017080622334870.png[/img]   [img]http://files.jb51.net/file_images/article/201708/2017080622334871.png[/img]   3、解压Nginx压缩包文件到C盘根目录,并且重命名为nginx [img]http://files.jb51.net/file_images/article/201708/2017080622334872.png[/img]   4、将"winsw-1.19-bin.exe"重命名为"nginx-service.exe",并且复制到nginx根目录 [img]http://files.jb51.net/file_images/article/201708/2017080622334873.png[/img]   5、在nginx根目录编写nginx-service.xml文件 [img]http://files.jb51.net/file_images/article/201708/2017080622334974.png[/img]   [b] nginx-service.xml文件内容[/b] 
<?xml version="1.0" encoding="UTF-8" ?>
<service>
 <id>Nginx</id>
 <name>Nginx</name>
 <description>本服务用于加载Nginx服务,请确保开机启动。</description>
 <logpath>C:\nginx\logs</logpath>
 <executable>nginx.exe</executable>
 <stopexecutable>nginx.exe</stopexecutable>
 <stopargument>-s</stopargument> 
 <stopargument>stop</stopargument>
 <logmode>rotate</logmode>
</service>
 6、安装Nginx系统服务或者卸载Nginx系统服务 6.1、安装Nginx系统服务 按下Win+X+A键 打开命令提示符(管理员) 输入: [code]C:\nginx\nginx-service.exe install[/code]  [img]http://files.jb51.net/file_images/article/201708/2017080622334975.png[/img]   6.2、卸载Nginx系统服务 按下Win+X+A键 打开命令提示符(管理员) 输入: C:\nginx\nginx-service.exe uninstall [img]http://files.jb51.net/file_images/article/201708/2017080622334976.png[/img]   7、查看系统服务 7.1、进入服务
运行Win+R输入:
services.msc
[img]http://files.jb51.net/file_images/article/201708/2017080622334977.png[/img]
[img]http://files.jb51.net/file_images/article/201708/2017080622334978.png[/img]
7.2、启动Nginx服务
[img]http://files.jb51.net/file_images/article/201708/2017080622334979.png[/img]
8、成功启动之后,在IE浏览器中输入:[u]http://localhost/[/u]
[img]http://files.jb51.net/file_images/article/201708/2017080622334868.png[/img] 9、用命令方式启动、关闭Nginx服务 9.1、启动Nginx服务 按下Win+X+A键 打开命令提示符(管理员) 输入:net start nginx [img]http://files.jb51.net/file_images/article/201708/2017080622334980.png[/img]   9.2、关闭Nginx服务 按下Win+X+A键 打开命令提示符(管理员) 输入:net stop nginx [img]http://files.jb51.net/file_images/article/201708/2017080622334981.png[/img]   10、Windows查看进程和杀死进程 10.1、查看Nginx进程号 tasklist | findstr 服务名 按下Win+X+A键 打开命令提示符(管理员) 输入: tasklist | findstr nginx [img]http://files.jb51.net/file_images/article/201708/2017080622334982.png[/img]   10.2、使用tskill命令杀死进程(tskill PID) [img]http://files.jb51.net/file_images/article/201708/2017080622335083.png[/img]   11、配置Nginx文件 Nginx配置文件目录: C:\nginx\conf [img]http://files.jb51.net/file_images/article/201708/2017080622335084.png[/img]   11.1、编辑Nginx核心配置文件nginx.conf
# 根据你服务器的cpu核数来确定此值
worker_processes 2;
# events事件主要用来确定Nginx使用哪种算法
events {
  worker_connections 1024;
}
 
http {
  #隐藏Nginx版本信息
  server_tokens off;
  include    mime.types;
  default_type application/octet-stream;
  sendfile    on;
  keepalive_timeout 65;
   
 #代理的相关参数设置 
 fastcgi_connect_timeout 300;
 fastcgi_send_timeout 300;
 fastcgi_read_timeout 300;
 fastcgi_buffer_size 128k;
 fastcgi_buffers 4 128k;
 fastcgi_busy_buffers_size 256k;
 fastcgi_temp_file_write_size 256k;
 
 #启用gzip压缩,提高用户访问速度
 gzip on;
 gzip_min_length 1k;
 gzip_buffers   4 32k;
 gzip_http_version 1.1;
 gzip_comp_level 2;
 gzip_types    text/plain application/x-javascript text/css application/xml;
 gzip_vary on;
 gzip_disable "MSIE [1-6].";
 
 server_names_hash_bucket_size 128;
 client_max_body_size   100m; 
 client_header_buffer_size 256k;
 large_client_header_buffers 4 256k;
 
#增加虚拟主机
include vhosts.conf;
 
}
 11.2、编辑Nginx虚拟主机配置文件vhosts.conf  
#NGINX安装初始化
server { 
    listen   80;
    charset utf-8;        
    server_name 127.0.0.1;
    location / {
        #打开浏览目录
        autoindex on;
        #显示出文件的大概大小
        autoindex_exact_size off;
        #显示的文件时间为文件的服务器时间
        autoindex_localtime on;
    root  C:\wwwroot\html;
    index index.html index.htm;
    }
 } 
    
 12、创建网站根目录 12.1、在C盘根目录创建网站目录,命名为"wwwroot"。 [img]http://files.jb51.net/file_images/article/201708/2017080622335085.png[/img]   12.2、在网站根目录放入站点目录,命名为"html"。 [img]http://files.jb51.net/file_images/article/201708/2017080622335086.png[/img]   12.3、浏览网页 [img]http://files.jb51.net/file_images/article/201708/2017080622335087.png[/img]  
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部