windows下搭建基于nginx的rtmp服务器
- 格式:doc
- 大小:26.50 KB
- 文档页数:5
流媒体服务器的搭建1.确定服务器的需求在开始搭建流媒体服务器之前,我们应该明确自己的需求。
例如,我们需要支持的用户数量、业务类型,以及预算等。
这些因素将指导我们选择合适的服务器硬件和软件。
2.选择流媒体服务器软件目前比较流行的流媒体服务器软件有Nginx、Apache、Wowza Media Server等。
根据自己的需求选择合适的服务器软件。
在本文中,将以Nginx为例进行搭建。
3.准备服务器硬件和操作系统根据自己的需求选择合适的服务器硬件,例如CPU、内存、硬盘等。
同时,选择一个支持的操作系统。
常用的操作系统有Linux(如Ubuntu、CentOS)、Windows Server等。
4.安装流媒体服务器软件5.配置流媒体服务器在安装完成后,需要进行一些配置工作。
例如,配置Nginx作为流媒体服务器、设置监听端口、支持的流媒体格式等。
在配置文件中,可以设置HTTP流媒体选项,如hls(HTTP Live Streaming)、rtmp(Real-Time Messaging Protocol)等。
6.创建流媒体内容在完成服务器的基本配置后,需要创建流媒体内容。
可以将音频、视频文件上传至服务器,或使用ffmpeg等工具进行转码。
转码后的内容保存在服务器上特定的目录中,供用户访问。
7.安全设置8.测试流媒体服务器在完成所有配置后,需要进行测试以确保服务器正常工作。
可以使用不同的终端设备,如电脑、手机、平板等,通过指定的URL访问流媒体内容。
如果能够正常播放,说明服务器搭建成功。
9.监控和维护流媒体服务器的搭建是一个持续的过程。
在运行过程中,需要定期进行监控和维护。
可以使用监控工具,如Nagios、Zabbix等,监控服务器的负载、带宽、连接数等。
同时,定期更新服务器软件和安全补丁,保持服务器的稳定和安全性。
总结流媒体服务器的搭建是一个复杂的过程,需要根据自己的需求选择合适的硬件和软件,并进行相应的配置和测试。
windows10系统配置nginx⽂件服务器的图⽂教程Nginx官⽹下载Windows版本的Nginx:将下载的软件包进⾏解压:注意:解压包的路径不能包含中⽂字符,否则Nginx服务启动不了启动Nginx服务:“Windows键+R键"打开运⾏,输⼊"cmd"进⼊"Dos终端”C:\Users\Administrator>f:F:\>cd GX\nginx-1.16.1# 启动命令F:\GX\nginx-1.16.1>start nginxF:\GX\nginx-1.16.1>服务启动成功后,在任务管理器中会有两个"nginx"进程修改配置⽂件,重启Nginx在"nginx.conf"⽂件"HTTPS server块"上⽅新增以下⼏⾏# 添加⽂件管理器# 显⽰⽬录autoindex on;# 显⽰⽂件⼤⼩autoindex_exact_size on;# 显⽰⽂件时间autoindex_localtime on;server {listen 8888;server_name localhost ;# 本地⽂件路径# 注意不能直接以整个逻辑磁盘F:\ 为⽬录路径,要F:\英⽂⽬录名root F:\GX\Chiron ;}重新加载Nginx服务# 重新加载Nginx服务命令F:\GX\nginx-1.16.1>nginx.exe -s reloadF:\GX\nginx-1.16.1>注意:1. ⽬录名与⽂件名要求使⽤英⽂字符才能正常下载;2. 带有中⽂字符的⽂件可能会显⽰乱码,并且下载时,可能会报"500 Internal Server Error"错误Windows 版本的Nginx相关命令:nginx -s stop //停⽌nginxnginx -s reload //重新加载nginxnginx -s quit //退出nginxstart nginx //启动nginx设置PC机开机⾃启动C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup将“nginx.exe”⽣成快捷⽅式到上⾯⽬录下即可总结以上所述是⼩编给⼤家介绍的windows10 系统配置nginx⽂件服务器,希望对⼤家有所帮助,如果⼤家有任何疑问请给我留⾔,⼩编会及时回复⼤家的。
nginx搭建rtmp协议流媒体服务器总结最近在ubuntu12.04上搭建了一个rtmp服务器,感觉还挺麻烦的,所以记录下。
大部分都是参考网络上的资料。
前提:在linux下某个目录中新建一个nginx目录。
然后进入该目录去下载搭建环境所需要的一些资源包。
此处在/root/ 目录下新建一个nginx目录即:/root/nginx/====================================1、安装依赖包:#yum -y install gcc glibc glibc-devel make nasm pkgconfig lib-devel openssl-devel expat-devel gettext-devel libtool mhash.x86_64 perl-Digest-SHA1.x86_642、安装相关工具包1). git# mkdir soft-source# cd soft-source# wget :///projects/git-snapshots/git/git-latest.tar.xz# xz -d git-latest.tar.xz# tar xzvf git-latest.tar# cd git-2014-06-27# autoconf# ./configure# make && make install# git --versiongit version 2.0.0.GIT# cd ..2). zlib# wget :///zlib-1.2.8.tar.gz# tar -zxvf zlib-1.2.8.tar.gz cd zlib-1.2.8# ./configure# make# make install# cd ..3). pcre# wget ://exim.mirror.fr/pcre/pcre-8.12.tar.gz# tar zxvf pcre-8.12.tar.gz# cd pcre-8.12# ./configure# make && make install# cd ..4). yadmiyadmi的作用是为flv文件添加关键帧,才能实现拖动播放# wget :///projects/yamdi/files/yamdi/1.4/yamdi-1.4.tar.gz/download# tar xzvf download# cd yamdi-1.4# make && make install# cd ..使用方法:# yamdi -i input.flv -o out.flv给input.flv文件添加关键帧,输出为out.flv文件5). OpenSSL# wget :///source/openssl-1.0.1c.tar.gz# tar -zxvf openssl-1.0.1c.tar.gz# ./config# make# make install3、安装ffmpeg及其依赖包:1). Yasm# wget :///projects/yasm/releases/yasm-1.2.0.tar.gz# tar xzvf yasm-1.2.0.tar.gz# cd yasm-1.2.0# ./configure# make# make install# cd ..2). x264# git clone git:///x264# cd x264# ./configure --enable-shared# make# make install# cd ..3). LAME# wget :///project/lame/lame/3.99/lame-3.99.5.tar.gz# tar xzvf lame-3.99.5.tar.gz# cd lame-3.99.5#./configure --enable-nasm# make# make install# cd ..4). libogg# wget :///releases/ogg/libogg-1.3.0.tar.gz# tar xzvf libogg-1.3.0.tar.gz# cd libogg-1.3.0# ./configure# make# make install# cd ..5). libvorbis# wget :///releases/vorbis/libvorbis-1.3.3.tar.gz# tar xzvf libvorbis-1.3.3.tar.gz# cd libvorbis-1.3.3# ./configure# make# make install# cd ..6). libvpx# git clone :///webm/libvpx.git# cd libvpx# ./configure --enable-shared# make# make install# cd ..7). FAAD2# wget :///project/faac/faad2-src/faad2-2.7/faad2-2.7.tar.gz # tar zxvf faad2-2.7.tar.gz# cd faad2-2.7# ./configure# make# make install# cd ..8). FAAC# wget :///project/faac/faac-src/faac-1.28/faac-1.28.tar.gz # tar zxvf faac-1.28.tar.gz# cd faac-1.28# ./configure# make# make install# cd ..注:编译时可能遇到一下错误:mpeg4ip.h:126: error: new declaration ‘char* strcasestr(const char*, const char*)’解决方法:从123行开始修改此文件mpeg4ip.h,到129行结束。
搭建最简单的NginxTenginetcp反向代理WEB服务器-电脑资料1. 下载nginx或者tengine2. 解压nginx或者tengine进入到刚刚下载的tengine所在的目录,然后执行:tar -xvf tengine-2.0.0.tar.gz3. 下载nginx_tcp_proxy_module如果你安装了git 那么直接clone模块,执行git clone **************:yaoweibin/nginx_tcp_proxy_module.git4. 确认模块所在的目录如果是下载的模块压缩包,那么解压模块得到nginx_tcp_proxy_module-master目录如果是clone的模块,那么就是该nginx_tcp_proxy_module目录5. 进入nginx或者tengine解压的目录6. 执行patch –p1 < /第四步的目录/tcp.patch7. 执行./configure --add-module=/第四步的目录/8. 执行make9. 执行make install注意:如果make make install出现问题,那么请查找其他资料安装依赖如果你懒得找,可以执行: sudo apt-get install libpcre3libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev 一键安装常见缺失的依赖10. 编辑nginx.conf,在http配置下面添加:tcp { upstream cluster { # simple round-robin server localhost:8890; server localhost:8891; check interval=3000 rise=2 fall=5 timeout=1000; #check interval=3000 rise=2 fall=5 timeout=1000 type=ssl_hello; #check interval=3000 rise=2 fall=5 timeout=1000 type=http; #check_http_send "GET / HTTP/1.0\r\n\r\n"; #check_http_expect_alive http_2xx http_3xx; } server { listen 8888; proxy_pass cluster; } }这里是用nginx/tengine的本地8888tco/ip端口代理到本机的8890和8891端口11. 启动nginx执行/nginx目录/sbin/nginx。
Windows下编译Nginx并添加模块一.准备工作1.环境安装1.安装vs2010或vs2013等vs工具。
2.安装ActivePerl,安装完成后,将其安装路径加入到PATH环境变量。
3.安装MinGW,下载mingw-get-setup.exe,安装完成后,将其安装路径加入到PATH环境变量。
(记得安装的时候装上msys,不懂就全勾了)4.安装nasm,安装完成后,将其安装路径加入到PATH环境变量。
2.下载编译nginx源码文件1.nginx源码:nginx-1.12.22.pcre:pcre-8.403.zlib:zlib-1.2.114.openssl:openssl-1.0.2l3.下载添加模块文件1.文件上传模块: nginx-upload-module2.rtmp模块:nginx-rtmp-module3.文件上传进度条模块:nginx-upload-progress-module二.编译并添加模块1.将上述7个压缩包文件解压至文件夹msys文件目录下,如C:\MinGW\msys\1.0\home\$UESRNAME\。
2.找到msys.bat的路径并双击msys.bat,运行。
如下图所示3.打开msys.bat后如下所示右击上方编辑栏,选择编辑,粘贴,可进行粘贴复制功能。
4.cd 至nginx源码路径,并在源码路径下执行下面语句:auto/configure --with-cc=cl --builddir=objs --prefix= \--conf-path=conf/nginx.conf --pid-path=logs/nginx.pid \--http-log-path=logs/access.log --error-log-path=logs/error.log \ --sbin-path=nginx.exe--http-client-body-temp-path=temp/client_body_temp \--http-proxy-temp-path=temp/proxy_temp \--http-fastcgi-temp-path=temp/fastcgi_temp \--with-cc-opt=-DFD_SETSIZE=1024 --with-pcre=../pcre-8.40 \--with-zlib=../zlib-1.2.11 --with-openssl=../openssl-1.0.2l \--with-select_module --with-http_ssl_module \--with-http_sub_module \--add-module=../nginx-upload-module-2.255 \--add-module=../nginx-upload-progress-module-master \--add-module=../nginx-rtmp-module-master \其中pcre,zlib,openssl的语句需根据版本号的不同进行改变,最后增加的模块也需更具实际情况进行相应的改变,步骤4操作如下图所示:下图表示正在形成Makefile文件,请等待。
Nginx+Tomcat在Windows下做负载均衡一、为什么需要对Tomcat服务器做负载均衡:Tomcat服务器作为一个Web服务器,其并发数在300-500之间,如果有超过500的并发数便会出现Tomcat不能响应新的请求的情况,严重影响网站的运行。
另外,在访问量大的情况下,Tomcat的线程数会不断增加。
由于Tomcat自身对内存的占用有控制,当对内存的占用达到最大值时便会出现内存溢出,对网站的访问严重超时等现象,这时便需要重新启动Tomcat以释放占用的内存,这样做便会阻断网站运行。
所以对Tomcat做负载均衡便很有必要。
目前可以和Tomcat做负载均衡的主流服务器是Apache,但是Nginx由于功能多、配置简单等优点逐渐成为很多负载均衡服务器的首选。
Nginx的并发数可达到50000,所以理论上可以和Tomcat以1:100的比例来配置,这样便可以很好的解决网站并发瓶颈问题。
二、Nginx+Tomcat在Windows下负载均衡配置方法:Nginx+Tomcat在Windows下做负载均衡相对在Linux下简单不少,因为不论是Nginx 还是Tomcat只需要下载Windows下的安装包解压到某个目录下,然后就可以做配置了。
我选择的Nginx是nginx-0.8.49这个版本,Tomcat选择的是apache-tomcat-6.0.26。
下面就是配置过程:1.将nginx-0.8.49.rar压缩包直接解压到某个目录下(如D:/负载均衡/nginx)。
2.将apache-tomcat-6.0.26.rar压缩包解压,因为是做负载均衡,所以至少要解压两个。
(如分别解压到D:/负载均衡/tomcat_1和D:/负载均衡/tomcat_2下面)。
3.将要发布的项目发布到两个Tomcat根目录下的webapps下,保证两个Tomcat下面的项目名称相同。
4.修改其中一个Tomcat的配置文件,该配置文件位于Tomcat目录下的/conf/下,文件名为server.xml,修改其中的<Server port="8005" shutdown="SHUTDOWN">为<Serverport="8006" shutdown="SHUTDOWN">,修改其中的<Connector port="8080" protocol="HTTP/1.1"connectionTimeout="20000"redirectPort="8443" />为<Connector port="8088" protocol="HTTP/1.1"connectionTimeout="20000"redirectPort="8443" />修改后的文件如下:<?xml version='1.0' encoding='utf-8'?><!--Licensed to the Apache Software Foundation (ASF) under one or morecontributor license agreements. See the NOTICE file distributed withthis work for additional information regarding copyright ownership.The ASF licenses this file to You under the Apache License, Version 2.0(the "License"); you may not use this file except in compliance withthe License. You may obtain a copy of the License at/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.--><!-- Note: A "Server" is not itself a "Container", so you may notdefine subcomponents such as "Valves" at this level.Documentation at /docs/config/server.html--><Server port="8006" shutdown="SHUTDOWN"><!--APR library loader. Documentation at /docs/apr.html --><Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /><!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html --><Listener className="org.apache.catalina.core.JasperListener" /><!-- Prevent memory leaks due to use of particular java/javax APIs--><Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /><!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html --><Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" /><Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /><!-- Global JNDI resourcesDocumentation at /docs/jndi-resources-howto.html--><GlobalNamingResources><!-- Editable user database that can also be used byUserDatabaseRealm to authenticate users--><Resource name="UserDatabase" auth="Container"type="erDatabase"description="User database that can be updated and saved"factory="ers.MemoryUserDatabaseFactory"pathname="conf/tomcat-users.xml" /></GlobalNamingResources><!-- A "Service" is a collection of one or more "Connectors" that sharea single "Container" Note: A "Service" is not itself a "Container",so you may not define subcomponents such as "Valves" at this level.Documentation at /docs/config/service.html--><Service name="Catalina"><!--The connectors can use a shared executor, you can define one or more named thread pools--><!--<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"maxThreads="150" minSpareThreads="4"/>--><!-- A "Connector" represents an endpoint by which requests are receivedand responses are returned. Documentation at :Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)Java AJP Connector: /docs/config/ajp.htmlAPR (HTTP/AJP) Connector: /docs/apr.htmlDefine a non-SSL HTTP/1.1 Connector on port 8080--><Connector port="8088" protocol="HTTP/1.1"connectionTimeout="20000"redirectPort="8443" /><!-- A "Connector" using the shared thread pool--><!--<Connector executor="tomcatThreadPool"port="8080" protocol="HTTP/1.1"connectionTimeout="20000"redirectPort="8443" />--><!-- Define a SSL HTTP/1.1 Connector on port 8443This connector uses the JSSE configuration, when using APR, theconnector should be using the OpenSSL style configurationdescribed in the APR documentation --><!--<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"maxThreads="150" scheme="https" secure="true"clientAuth="false" sslProtocol="TLS" />--><!-- Define an AJP 1.3 Connector on port 8009 --><Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /><!-- An Engine represents the entry point (within Catalina) that processesevery request. The Engine implementation for Tomcat stand aloneanalyzes the HTTP headers included with the request, and passes themon to the appropriate Host (virtual host).Documentation at /docs/config/engine.html --><!-- You should set jvmRoute to support load-balancing via AJP ie :<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">--><Engine name="Catalina" defaultHost="localhost"><!--For clustering, please take a look at documentation at:/docs/cluster-howto.html (simple how to)/docs/config/cluster.html (reference documentation) --><!--<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>--><!-- The request dumper valve dumps useful debugging information about the request and response data received and sent by Tomcat.Documentation at: /docs/config/valve.html --><!--<Valve className="org.apache.catalina.valves.RequestDumperValve"/>--><!-- This Realm uses the UserDatabase configured in the global JNDIresources under the key "UserDatabase". Any editsthat are performed against this UserDatabase are immediatelyavailable for use by the Realm. --><Realm className="erDatabaseRealm"resourceName="UserDatabase"/><!-- Define the default virtual hostNote: XML Schema validation will not work with Xerces 2.2.--><Host name="localhost" appBase="webapps"unpackWARs="true" autoDeploy="true"xmlValidation="false" xmlNamespaceAware="false"><!-- SingleSignOn valve, share authentication between web applications Documentation at: /docs/config/valve.html --><!--<Valve className="org.apache.catalina.authenticator.SingleSignOn" />--><!-- Access log processes all example.Documentation at: /docs/config/valve.html --><!--<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>--></Host></Engine></Service></Server>5.修改Nginx配置文件nginx.conf,该文件位于Nginx根目录下的/conf下面。
搭建nginx+tomcat配置攻略1.准备工作大家都知道配置nginx+tomcat需要有前期准备工作,如果不知道需要配置哪些文件,改哪些参数,就好像大海捞针,盲人摸象!配置nginx+tomcat需要修改4个配置文件。
(1).hosts文件(如果客户端为win32)。
(2).tomcat下服务配置文件server.xml。
(3). Nginx安装程序下nginx.conf文件。
(4) index页面(index.jsp index.htm index.html index.shtml) 2.如何配置各个参数文件下面就以访问域名: 为例。
仅作参考。
2.1.hosts文件中需要加一行192.168.100.197 说明:192.168.100.197 为部署tomcat服务器的ip.2.2 Tomcat文件修改<?xml version='1.0' encoding='utf-8'?><Server port="8028" shutdown="SHUTDOWN">…………………..此处省略<Service name="Catalina"><Connector address="192.168.100.197" port="8068" maxHttpHeaderSize="8192"URIEncoding="utf-8" maxThreads="1000" minSpareThreads="75" maxSpareThreads="350"enableLookups="false" redirectPort="8443" acceptCount="750"debug="1" connectionTimeout="90000" disableUploadTimeout="true" /> …………………..此处省略" debug="0"</Context></Host></Server>(port=等等……#Nginx mmt58commmt58com一样,具}##url,#此处为配置tomcat的web项目路径root /work/opt/tomcat_dp/webapps/;#此处为访问web项目首页配置(nginx会首先访问任何存在的页面) index index.jsp index.htm index.html index.shtml;#如果不是做优化处理(初学者或菜鸟),以下配置直接拷贝,不用修改。
原来一直以为nginx只能在Linux下搭建,最近查了些资料才恍然大悟,Windows下其实也可以跑nginx。
当你的网站访问量越来越高的时候,一台服务器已经没有办法承受流量压力,后果可想而知,怎么办呢?那就增加几台服务器来做负载吧。
但当下的硬件设施又是贵得离谱,比如F5,所以这种情况下,免费的nginx成了我们不错的选择,nginx目前好多门户网站与大访问量的网站都在使用做为HTTP服务器,所以nginx是相当优秀的……实验环境:(2台服务器)第一台:系统:Win2003nginx:nginx/Windows-0.8.32IP:192.168.0.51环境:本地第二台:系统:Win2003IP:192.168.0.52环境:远程说明:本次测试,软件nginx放在本地(192.168.0.51),也就是说放在域名绑定的那台服务器,这台服务器的IIS不能使用80端口,因为等一下nginx软件要使用80这个端口。
(为了方便,我将本机的hosts文件添加了我要测试的域名192.168.0.51 )下载nginx的地址如下:nginx下载:/下载解压到C:\,把目录名改成nginx一切准备就绪,开始实验:No.1:在本地(192.168.0.51)这台服务器IIS创建一个网站,使用端口为808,如下图:IIS 网站绑定设置图No.2:在远程192.168.0.52的IIS创建一个网站,使用端口为80,如下图:No.3:好了,以上已经设置好两台服务器的IIS了,下面配置nginx软件来实现网站负载均衡,打开如下文件:C:\nginx\conf\nginx.conf1、找到内容server {在它的上面加入如下内容:upstream {server 192.168.0.51:808;server 192.168.0.52:80;}(这是负载切换使用的服务器网站IP)2、找到location / {root html;index index.html index.htm;}把内容更改如下:location / {proxy_pass ;proxy_redirect default;}3、找到server {listen 80;server_name localhost;把内容改成如下:server {listen 80;server_name 192.168.0.51;(这是监听访问域名绑定那台服务器80端口的请求)好,在这里就这么简单配置好了,下面看下以上3步配置的图:负载配置图No.4:都配置好了,下面启动nginx这软件进入命令提示符CMD,进入c:\nginx>,输入nginx命令,如下图:启动nginx这时候,系统进程有两个nginx.exe进程,如下图:系统nginx进程(停止nginx运行输入nginx -s stop 即可)No.5:经过以上的配置,现在我们看下负载效果:在本地(192.168.0.51)这服务器打开IE,输入:http://192.168.0.51第一次打开网站的结果:第一次访问网站图刷新一下网页,出现的结果:再次访问网站图OK,测试成功o(∩_∩)o经过这次测试,可见网站的负载平衡并不是难事。
win版Nginx安装配置上次我们学习了在一台电脑上安装了多个Tomcat,这次我们学习Windows下面如何安装Nginx和配置负载均衡①,首先下载一个Windows版本的Nginx附上下载地址/en/download.html②,解压稳定版的Nginx 如下图:以下是目录结构介绍:③,配置文件介绍,我们主要是修改conf目录中的nginx.conf这个文件。
配置文件介绍如下此次负载均衡的方式是轮询权重都是一样的:worker_processes 2;#工作进程的个数,一般与计算机的cpu核数一致events {worker_connections 2048;#单个进程最大连接数(最大连接数=连接数*进程数)}http {include mime.types; #文件扩展名与文件类型映射表default_type application/octet-stream;#默认文件类型sendfile on;#开启高效文件传输模式,sendfile指令指定nginx 是否调用sendfile函数来输出文件,对于普通应用设为 on,如果用来进行下载等应用磁盘IO重负载应用,可设置为off,以平衡磁盘与网络I/O处理速度,降低系统的负载。
注意:如果图片显示不正常把这个改成off。
keepalive_timeout 65; #长连接超时时间,单位是秒gzip on;#启用Gizp压缩#服务器的集群upstream { #服务器集群名字server 127.0.0.1:18080 weight=1;#服务器配置 weight是权重的意思,权重越大,分配的概率越大。
server 127.0.0.1:28080 weight=1;server 127.0.0.1:38080 weight=1;server 127.0.0.1:48080 weight=1;}#当前的Nginx的配置server {listen 8088;#监听80端口,可以改成其他端口server_name localhost;############## 当前服务的域名location / {proxy_pass ;proxy_redirect default;}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}}}④,启动Nginx ,WIN+R 输入cmd 跳转到安装目录执行nginx.exe 如下图:⑤,修改Tomcat\webapps\ROOT\index.jsp在里面写一个标识符一次标记1,2,3,4⑥,启动Tomcat⑦,测试Nginx是否成功输入配置地址及监听端口http://localhost:8088/⑧,刷新查看是否负载均衡成功如下图⑨,看到这个效果说明 Nginx负载均衡就成功了。
如何把Nginx安装成Windows服务
预览说明:预览图片所展示的格式为文档的源格式展示,下载源文件没有水印,内容可编辑和复制
如何把Nginx安装成Windows服务
可以使用.NET Framework加winsw-1.9-bin.exe 来实现把Nginx安装到Windows服务器管理器中。
.NET Framework下载地址
WinSW-1.9-bin下载地址
把NGINX安装到C:\\RUNTIME\ginx目录。
平时的启动命令为:C:\\RUNTIME\ginx\ginx.exe
停止它有两种方法,一种是打开进程管理器,把所有的nginx进程都杀死,而且看着它们都被杀死为止才行。
一种是用命令行:C:\\RUNTIME\ginx\ginx.exe -s stop
要自动启动,你可以把winsw-1.9-bin.exe复制到C:\\RUNTIME\ginx目录,改名为NginxServer.exe。
保存后,执行命令:
NginxServer.exe install
如果成功,就会返回命令行光标,没有提示。
如果有错误提示,请确认你的电脑正确安装了.NET Framework 2.0.5或以上的环境。
卸载命令为:
NginxServer.exe uninstall
现在服务的起停,你可以打开“服务器管理器”来操作了。
windows下搭建基于nginx的rtmp服务器Windows机器配置:Windows7旗舰版64位Intel(R) Core(TM)i5-2520 CPU @2.50GHz 2.50 GHz内存: 4GB1. 下载nginx 1.7.11.3 Gryphon下载链接:http://nginx-win.ecsds.eu/download/nginx 1.7.11.3 Gryphon.zip 下载完成后解压;将解压后的目录名: nginx 1.7.11.3 Gryphon改成: nginx-1.7.11.3-Gryphon2. 下载服务器状态检查程序stat.xslhttps:///arut/nginx-rtmp-module/将nginx-rtmp-module-master.zip解压后复制到目录:nginx-1.7.11.3-Gryphon下,保证stat.xls的目录为:nginx-1.7.11.3-Gryphon\nginx-rtmp-module\stat.xsl3. 配置文件conf\nginx-win-rtmp.conf 内容如下:#user nobody;# multiple workers works !worker_processes 2;#error_loglogs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;events{ worker_connections 8192; # max value 32768, nginx recycling connections+registry optimization = # this.value * 20 = max concurrent connections currently tested with one worker # C1000K should be possible depending there is enough ram/cpu power # multi_accept on;}rtmp { server { listen 1935;chunk_size 4000; application live { live on; } }}http { #include/nginx/conf/naxsi_core.rules; include mime.types; default_type application/octet-stream; #log_format main '$remote_addr:$remote_port - $remote_user [$time_local] "$request" ' # '$status$body_bytes_sent "$http_referer" ' #'"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main;# # loadbalancing PHP# upstream myLoadBalancer {# server 127.0.0.1:9001 weight=1 fail_timeout=5;# server 127.0.0.1:9002 weight=1 fail_timeout=5;# server 127.0.0.1:9003 weight=1 fail_timeout=5;# server 127.0.0.1:9004 weight=1 fail_timeout=5;# server 127.0.0.1:9005 weight=1 fail_timeout=5;# server 127.0.0.1:9006 weight=1 fail_timeout=5;# server 127.0.0.1:9007 weight=1 fail_timeout=5;# server 127.0.0.1:9008 weight=1 fail_timeout=5;# server 127.0.0.1:9009 weight=1 fail_timeout=5;# server 127.0.0.1:9010 weight=1 fail_timeout=5;# least_conn;# } sendfile off; #tcp_nopush on;server_names_hash_bucket_size 128;## Start: Timeouts ##client_body_timeout 10; client_header_timeout 10; keepalive_timeout 30; send_timeout 10; keepalive_requests 10;## End: Timeouts ## #gzip on; server { listen 80; server_name localhost; location /stat { rtmp_stat all; rtmp_stat_stylesheet stat.xsl; } location/stat.xsl { root nginx-rtmp-module/; } location /control { rtmp_control all; }#charset koi8-r; #access_log logs/host.access.log main; ## Caching Static Files, put before first location #location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ { # expires 14d; # add_header Vary Accept-Encoding; #}# For Naxsi remove the single # line for learn mode, or the ## lines for full WAF mode location /{ #include /nginx/conf/mysite.rules; # see also http block naxsi include line##SecRulesEnabled; ##DeniedUrl "/RequestDenied"; ##CheckRule "$SQL >= 8" BLOCK;##CheckRule "$RFI >= 8" BLOCK; ##CheckRule "$TRA VERSAL >= 4" BLOCK; ##CheckRule "$XSS >= 8" BLOCK; root html;index index.html index.htm; }# For Naxsi removethe ## lines for full WAF mode, redirect location block used by naxsi ##location /RequestDenied { ## return 412; ##}## Lua examples !# location /robots.txt {# rewrite_by_lua '# if ngx.var.http_host ~= "localhost" then# return ngx.exec("/robots_disallow.txt");# end#';# } #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_passhttp://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; # single backend process # fastcgi_pass myLoadBalancer; # or multiple, see example above # fastcgi_index index.php;# fastcgi_param SCRIPT_FILENAME$document_root$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccessfiles, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # another virtual host using mix ofIP-, 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 { # listen443 ssl spdy; # server_name localhost; # ssl on; # ssl_certificate cert.pem; #ssl_certificate_key cert.key; # ssl_session_timeout5m; # ssl_prefer_server_ciphers On; #ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:ECDH+3 DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!eNUL L:!MD5:!DSS:!EXP:!ADH:!LOW:!MEDIUM; #location / { # root html; # index index.html index.htm; # } #}}4. 启动服务器进入windows的cmd; > cd nginx-1.7.11.3-Gryphon> nginx.exe -c conf\nginx-win-rtmp.conf。