秀米云香港服务器

因为最近的项目需要用到负载平衡,不消思量,虽然用台甫鼎鼎的Nginx啦。至于Nginx的先容,这里就不多说了,直接进入主题如安在Windows下设置。

我的系统是win7旗舰版的,到官网下载最新版本nginx/Windows-1.7.9解压到英文目次下(我刚开始是放到中文目次下的,启动时会有问题,下面常见错误里会讲到)。

序列号 CPU RAM HDD 带宽 售价(美元) 免费试用
香港服务器1 E5-2620 32G 1T HDD 50M/无限流量 $196.00 立即申请
香港服务器2 E5-2650 32G 1T HDD 50M/无限流量 $256.00 立即申请
香港服务器3 E5-2680 32G 1T HDD 50M/无限流量 $316.00 立即申请
香港服务器4 E5-2690 32G 1T HDD 50M/无限流量 $336.00 立即申请
香港服务器5 E5-2697 32G 1T HDD 50M/无限流量 $376.00 立即申请
香港服务器6 E5-2620*2 32G 1T HDD 50M/无限流量 $376.00 立即申请
香港服务器7 E5-2650*2 32G 1T HDD 50M/无限流量 $436.00 立即申请
香港服务器8 E5-2680*2 32G 1T HDD 50M/无限流量 $476.00 立即申请
香港服务器9 E5-2690*2 32G 1T HDD 50M/无限流量 $556.00 立即申请
香港服务器10 E5-2697*2 32G 1T HDD 50M/无限流量 $596.00 立即申请
香港服务器11 E5-2680v4*2 32G 1T HDD 50M/无限流量 $696.00 立即申请
香港服务器12 E5-2698v4*2 32G 1T HDD 50M/无限流量 $796.00 立即申请

一、 Nginx设置

找到 conf 目次里的 nginx.conf 文件,设置Nginx

#usernobody;#指定nginx历程数worker_processes1;#全局错误日志及PID文件#error_loglogs/error.log;#error_loglogs/error.lognotice;#error_loglogs/error.loginfo;#pidlogs/nginx.pid;events{#毗连数上限worker_connections1024;}#设定http处事器,操作它的反向署理成果提供负载平衡支持http{#设定mime范例,范例由mime.type文件界说includemime.types;default_typeapplication/octet-stream;#设定日志名目#log_formatmain'$remote_addr-$remote_user[$time_local]"$request"'#'$status$body_bytes_sent"$http_referer"'#'"$http_user_agent""$http_x_forwarded_for"';#利用哪种名目标日志#access_loglogs/access.logmain;#sendfile指令指定nginx是否挪用sendfile函数(zerocopy方法)来输出文件,对付普通应用,sendfileon;#tcp_nopushon;#毗连超时时间#keepalive_timeout0;keepalive_timeout65;#开启gzip压缩#gzipon;#设定负载平衡的处事器列表支持多组的负载平衡,可以设置多个upstream来处事于差异的Server.#nginx的upstream支持几种方法的分派#1)、轮询(默认)每个请求定时间顺序逐一分派到差异的后端处事器,假如后端处事器down掉,,能自动剔除。#2)、weight指定轮询几率,weight和会见比率成正比,用于后端处事器机能不均的环境。跟上面样,指定了权重。#3)、ip_hash每个请求按会见ip的hash功效分派,这样每个访客牢靠会见一个后端处事器,可以办理session的问题。#4)、fair#5)、url_hash#Urlhashupstreammysvr{#weigth参数暗示权值,权值越高被分派到的几率越大#1.down暗示单前的server临时不参加负载#2.weight默认为1.weight越大,负载的权重就越大。#3.backup:其它所有的非backup呆板down可能忙的时候,请求backup呆板。所以这台呆板压力会最轻。#server192.168.1.116down;#server192.168.1.116backup;server192.168.1.121weight=1;server192.168.1.122weight=2;}#设置署理处事器的地点,即Nginx安装的处事器地点、监听端口、默认地点server{#1.侦听80端口listen80;#对付server_name,假如需要将多个域名的请求举办反向署理,可以设置多个server_name来满意要求server_namelocalhost;#charsetkoi8-r;#access_loglogs/host.access.logmain;location/{#默认主页目次在nginx安装目次的html子目次。roothtml;indexindex.htmlindex.htm;proxy_passhttp://mysvr;#跟载平衡处事器的upstream对应}#error_page404/404.html;#redirectservererrorpagestothestaticpage/50x.html##界说错误提示页面#error_page500502503504/50x.html;#location=/50x.html{#roothtml;#}#proxythePHPscriptstoApachelisteningon127.0.0.1:80##location~.php${#proxy_passhttp://127.0.0.1;#}#passthePHPscriptstoFastCGIserverlisteningon127.0.0.1:9000##location~.php${#roothtml;#fastcgi_pass127.0.0.1:9000;#fastcgi_indexindex.php;#fastcgi_paramSCRIPT_FILENAME/scripts$fastcgi_script_name;#includefastcgi_params;#}#denyaccessto.htaccessfiles,ifApache'sdocumentroot#concurswithnginx'sone##location~/.ht{#denyall;#}}#anothervirtualhostusingmixofIP-,name-,andport-basedconfiguration##server{#listen8000;#listensomename:8080;#server_namesomenamealiasanother.alias;#location/{#roothtml;#indexindex.htmlindex.htm;#}#}#HTTPSserver##server{#listen443ssl;#server_namelocalhost;#ssl_certificatecert.pem;#ssl_certificate_keycert.key;#ssl_session_cacheshared:SSL:1m;#ssl_session_timeout5m;#ssl_ciphersHIGH:!aNULL:!MD5;#ssl_prefer_server_cipherson;#location/{#roothtml;#indexindex.htmlindex.htm;#}#}}

二、 启动Nginx

cmd 进入Nginx解压目次 执行 start nginx启动Nginx处事

启动后如何查抄是否启动乐成呢? 输入呼吁 tasklist /fi "imagename eq nginx.exe" 看到以下信息说明启动乐成了

一切停当,会见一下server 里设置的server_name 是不是被重定向到upstream设置的处事器上了,是不是很简朴!

三、常见错误

假如启动失败 可以看下logs目次下 error.log 文件里的错误信息。

我在第一次安装的时碰着两个错误,也是最容易遇到的问题,在这里列出来利便各人遇到沟通的问题时快速办理。

1. 端口占用问题

标题:windows系统下安装设置 Nginx 的常见问题

地址: https://www.yunhk.xyz/26068.html