Nginx 是一个高性能的http 和反向代理服务器,也是一个代理服务器。

  Nginx比Apache 更加轻量级,占用的资源少,抗并发,二apache是阻塞型的,在高并发下,nginx更占优势。

  我们先从官网上面下载一个windows版本的nginx。http://nginx.org/en/download.html

  

  配置文件:解压后,找到nginx.conf    我下载的是1.8

  

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

  nginx 集群的配置

  

#######################################所有的指定必须由分号结束#######################################
#user nobody; ######### 配置用户或者组
worker_processes 1; ######## 允许生成的进程数 #error_log logs/error.log;
#error_log logs/error.log notice; ########### 制定日志路径,级别。这个设置可以放入全局块,http块,server块,级别以此为:debug|info|notice|warn|error|crit|alert|emerg
#error_log logs/error.log info; #pid logs/nginx.pid; ############ 指定运行文件存放的地址 events {
accept_mutex on; ########## 设置网路连接序列化,防止惊群现象发生,默认为on
multi_accept on; ######### 设置一个进程是否同时接受多个网络连接,默认为off
#use epoll; ########## 事件驱动模型,select|poll|kqueue|epoll|resig|/dev/poll|eventport
worker_connections 1024; ############ 最大连接数
} http {
include mime.types; ########文件扩展名与文件类型映射表
default_type application/octet-stream; ########默认文件类型,默认为text/plain #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; ############# combined为日志格式的默认值 sendfile on; ############### 允许sendfile方式传输文件,默认为off,可以在http块,server块,location块。
#tcp_nopush on;
#sendfile_max_chunk 100k; ################# 每个进程每次调用传输数量不能大于设定的值,默认为0,即不设上限。 #keepalive_timeout 0;
keepalive_timeout 65; ############### keepalive_timeout 65; #连接超时时间,默认为75s,可以在http,server,location块。 #gzip on; upstream myservice {
server 127.0.0.1:7878 weight=1;
server 192.168.10.121:3333 weight=1; #热备
#ip_hash; ####### nginx会让相同的客户端ip请求相同的服务器 解决session共享的问题
} #error_page 404 https://www.baidu.com; ####### 错误页
#proxy_intercept_errors on; ######## 如果被代理服务器返回的状态码为400或者大于400,设置的error_page配置起作用。默认为off。
#proxy_method get; ######## 支持客户端的请求方法。post/get;
#proxy_http_version 1.0 ; ####### Nginx服务器提供代理服务的http协议版本1.0,1.1,默认设置为1.0版本
#proxy_connect_timeout 1; ###### nginx服务器与被代理的服务器建立连接的超时时间,默认60秒
#proxy_read_timeout 1; ######## nginx服务器想被代理服务器组发出read请求后,等待响应的超时间,默认为60秒。
#proxy_send_timeout 1; ####### nginx服务器想被代理服务器组发出write请求后,等待响应的超时间,默认为60秒。 server {
keepalive_requests 120; ######## 单连接请求上限次数。
listen 80; ######## 监听端口
server_name localhost; ######## 监听地址 #charset koi8-r; #access_log logs/host.access.log main; location / { ###### 请求的url过滤,正则匹配,~为区分大小写,~*为不区分大小写。
root html; #### 根目录
index index.html index.htm; ##### 设置默认页
proxy_pass http://myservice; ###### 请求转向mysvr 定义的服务器列表
#deny 127.0.0.1; ##### 拒绝的ip
#allow 172.18.5.54; ##### 允许的ip
} #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的启动和关闭(*****nginx启动不像tomcat启动有弹框,刚开始时,容易入这个坑,以为没有启动******)

  

nginx 关闭   使用windows 的时候出现很多的服务 可以使用这个关闭   taskkill /F /IM nginx.exe

本人建议使用命令的方式进行启动

启动Nginx:start nginx

 

快速停止或关闭Nginx:nginx -s stop

 

正常停止或关闭Nginx:nginx -s quit

 

配置文件修改重装载命令:nginx -s reload

上面会引发session共享的问题

nginx 新手入门的更多相关文章

  1. nginx新手入门

    nginx的应用 官网(nginx.org) nginx可以做1.web服务(http服务)2.http代理服务3负载均衡在官网(nginx.org)如下图处下载先点击 跳转下一页点击(nginx/w ...

  2. nginx 学习笔记(2) nginx新手入门

    这篇手册简单介绍了nginx,并提供了一些可以操作的简单的工作.前提是nginx已经被安装到你的服务器上.如果没有安装,请阅读上篇:nginx 学习笔记(1) nginx安装.这篇手册主要内容:1. ...

  3. 即时通讯新手入门:一文读懂什么是Nginx?它能否实现IM的负载均衡?

    本文引用了“蔷薇Nina”的“Nginx 相关介绍(Nginx是什么?能干嘛?)”一文部分内容,感谢作者的无私分享. 1.引言   Nginx(及其衍生产品)是目前被大量使用的服务端反向代理和负载均衡 ...

  4. nginx配置入门

    谢谢作者的分享精神,原文地址:http://www.nginx.cn/591.html nginx配置入门 之前的nginx配置是对nginx配置文件的具体含义进行讲解,不过对于nginx的新手可能一 ...

  5. nginx 配置入门

    之前的nginx配置是对nginx配置文件的具体含义进行讲解,不过对于nginx的新手可能一头雾水. 今天看到个文档不错,翻译过来分享给大家,可以让新手更详细地了解nginx配置,可以说是nginx配 ...

  6. Docker新手入门:基本用法

    Docker新手入门:基本用法 1.Docker简介 1.1 第一本Docker书 工作中不断碰到Docker,今天终于算是正式开始学习了.在挑选系统学习Docker以及虚拟化技术的书籍时还碰到了不少 ...

  7. 《IM开发新手入门一篇就够:从零开发移动端IM》

        登录 立即注册 TCP/IP详解 资讯 动态 社区 技术精选 首页   即时通讯网›专项技术区›IM开发新手入门一篇就够:从零开发移动端IM   帖子 打赏 分享 发表评论162     想开 ...

  8. 【代理是什么?】nginx快速入门+反向代理hexo个人博客

    @ 目录 前言 本文说明 请大家务必查看 工作原理 正向代理 反向代理 环境准备 详细版 入门:搭建步骤 配置阿里云epel源: yum安装nginx: 启动nginx: 配置default.conf ...

  9. 新手入门指导:Vue 2.0 的建议学习顺序

    起步 1. 扎实的 JavaScript / HTML / CSS 基本功.这是前置条件. 2. 通读官方教程 (guide) 的基础篇.不要用任何构建工具,就只用最简单的 <script> ...

随机推荐

  1. Prime Cryptarithm

    链接 分析:对于三位数我们限定为[100,999],两位数我们限定为[10,99],然后我们依次判断是否满足乘法式且各个数位是否在数列中,若都满足+1 /* PROB:crypt1 ID:wangha ...

  2. Linux Cache 机制

    在阅读文章前,您应该具备基本的存储器层次结构知识,至少要了解局部性原理.要详细了解cache基本原理,可以参考本书<深入理解计算机系统>中存储器体系结构一章: 带着疑问来看文章,cache ...

  3. JavaScript-Tool:Ext JS

    ylbtech-JavaScript-Tool:Ext JS extjs是一种软件.自动生成行号,支持checkbox全选,动态选择显示哪些列,支持本地以及远程分页,可以对单元格按照自己的想法进行渲染 ...

  4. ASP.NET Core:目录

    ylbtech-ASP.NET Core:目录 1.返回顶部   2.返回顶部   3.返回顶部   4.返回顶部   5.返回顶部     6.返回顶部   作者:ylbtech出处:http:// ...

  5. bzoj1783

    博弈论+dp 从未做过博弈论... 思路是这样的,我们倒着考虑,分别设f[i]表示先手选了a[i]后能取得的最大值,g[i]表示先手取了a[i]后后手能获得的最大值 g[i]=f[mx],f[mx]是 ...

  6. SVN进行代码的托管

    svn 使用的是集中服务器 就是只有一个服务器的意思 git 是分布式服务器  服务器: 存储客户端上传的源代码. 可以在Windows上通过安装 Visual SVN Sever .  客户端: 上 ...

  7. ibatis 中 $与#的区别

    ibatis 中 $与#的区别 使用#: select * from table where id = #id# 如果字段为整型:#id#表示成id select * from table where ...

  8. Ruby Proc 和 lambda的共同点和区别

    Proc 和 lambda 的目的是把block {....} 变成类似方法一样的对象,使其不需要重复编写同样的block. Proc 和 lambda 的共同点: 语法类似Proc.new{|n| ...

  9. ASP.NET Core MVC 2.x 全面教程_ASP.NET Core MVC 22. 再讲Tag Helpers

    深入的讲Tag Helpers 加载app下面的所有的文件夹以及各自文件夹下面所有的js文件. exclude是排除掉Services文件夹和其下面的子文件夹 使用cdn加载远程的js文件 找hidd ...

  10. iView 实战系列教程(21课时)_1.iView 实战教程之配置篇

    1.iView 实战教程之配置篇 点击添加插件,. 选中后安装 全部导入还是按需导入. 2.是否需要自定义主题变量 3.多语言的设置. 这里我们全部选择为默认 然后点击继续. 启动项目 入口文件导入了 ...