`

Nginx - Windows下Nginx基本安装和配置

 
阅读更多

Nginx 是一个轻量级的高性能 Http WebServer,以事件驱动方式编写,因此相比 Apache 而言,Nginx 更加稳定、性能更好,而且配置简单,资源占用较低。 

1. 安装 Nginx 
从 v0.7.52 开始,Nginx 开始发布 Windows 版本的 Nginx,你可以在其官方网站上面下载:http://nginx.net 
下载后直接解压即可,这里解压缩到c:\nginx目录。 

2. 启动Nginx 
命令行进入c:\nginx目录,运行nginx.exe,启动控制台窗口。默认启用80端口。用过Tomcat的人都希望能在控制台看到启动日志,nginx的日志却不得不查看logs目录下的相应log文件。 

3. 访问欢迎html页 
在浏览器中访问http://localhost,可以看到默认的欢迎页. 

4. 停止Nginx 
Ctrl+C没反应。于是关闭控制台窗口。可是再访问http://localhost依然有效。查看进程,发现nginx根本没有被关闭。因此如果想彻底关闭nginx,应该是 

Command代码  收藏代码
  1. nginx -s stop  


请参考官方文档nginx/Windows usage 
或者使用windows的taskkill命令: 

Command代码  收藏代码
  1. taskkill /F /IM nginx.exe > nul  



5. Ngnix常用配置 
Nginx的所有配置都默认使用conf/nginx.conf文件,其地位相当于apache的httpd.conf文件 。当运行nginx.exe暗含运行了nginx -c conf\nginx.conf. 如果想使用自己定义的conf文件如my.conf,命令为nginx -c conf\my.conf. 
常用配置如下: 

Nginx.conf代码  收藏代码
  1. http {  
  2.   server {  
  3.     #1.侦听80端口   
  4.     listen  80;   
  5.     location / {  
  6.         # 2. 默认主页目录在nginx安装目录的html子目录。  
  7.         root   html;  
  8.         index  index.html index.htm;  
  9.         # 3. 没有索引页时,罗列文件和子目录  
  10.         autoindex on;  
  11.         autoindex_exact_size on;  
  12.         autoindex_localtime on;  
  13.     }  
  14.     # 4.指定虚拟目录  
  15.     location /tshirt {  
  16.     alias D:\programs\Apache2\htdocs\tshirt;  
  17.     index index.html index.htm;  
  18.     }  
  19.   }  
  20.   # 5.虚拟主机www.emb.info配置  
  21.   server {  
  22.     listen          80;  
  23.     server_name     www.emb.info;  
  24.     access_log emb.info/logs/access.log;  
  25.     location / {  
  26.       index index.html;  
  27.       root  emb.info/htdocs;  
  28.     }  
  29.   }  
  30. }  



小提示: 
运行nginx -V可以查看该Win32平台编译版支持哪些模块。我这里的结果为: 

Log代码  收藏代码
  1. nginx version: nginx/0.7.65  
  2. TLS SNI support enabled  
  3. configure arguments:   
  4. --builddir=objs.msvc8   
  5. --crossbuild=win32   
  6. --with-debug --prefix=   
  7. --conf-path=conf/nginx.conf   
  8. --pid-path=logs/nginx.pid   
  9. --http-log-path=logs/access.log   
  10. --error-log-path=logs/error.log   
  11. --sbin-path=nginx.exe   
  12. --http-client-body-temp-path=temp/client_body_temp   
  13. --http-proxy-temp-path=temp/proxy_temp   
  14. --http-fastcgi-temp-path=temp/fastcgi_temp   
  15. --with-cc-opt=-DFD_SETSIZE=1024   
  16. --with-pcre=objs.msvc8/lib/pcre-7.9   
  17. --with-openssl=objs.msvc8/lib/openssl-0.9.8k   
  18. --with-openssl-opt=enable-tlsext   
  19. --with-zlib=objs.msvc8/lib/zlib-1.2.3   
  20. --with-select_module   
  21. --with-http_ssl_module   
  22. --with-http_realip_module   
  23. --with-http_addition_module   
  24. --with-http_sub_module   
  25. --with-http_dav_module   
  26. --with-http_stub_status_module   
  27. --with-http_flv_module   
  28. --with-http_gzip_static_module   
  29. --with-http_random_index_module   
  30. --with-http_secure_link_module   
  31. --with-mail   
  32. --with-mail_ssl_module   
  33. --with-ipv6  


显然,最经常用的memcache, rewrite模块都没在其中,因此该win32编译版本仅能供基本开发测试使用,对于产品平台,应该重新编译自己想要的win32版本,或者在linux下使用更方便。 

分享到:
评论

相关推荐

    nginx-1.19.3-http-flv.zip

    资源说明: 1. 采用nginx最新版编译,包含最新的nginx-http-flv-module,以及基础模块openssl、prce、zlib 2. 整体打包,已配置好nginx.conf的http-flv直播流,以及http web环境...3. 使用nginxservice.exe install安装

    Nginx-windows 下安装配置 Nginx 详解 - CSDN博客1

    windows 下安装配置 Nginx 详解 - CSDN博客装配置 Nginx 详解阅读数:4348装配置 Nginx 详解本地服务器,通过配置server_

    Nginx-GUI-For-Windows-x64-v1.6.zip

    nginx配置启动状态,系统状态可视化管理,降低配置难易程度,提供维护和可视化效果。

    redis-nginx-linux-windows部署软件.rar

    redis-nginx-linux-windows部署软件

    windows安装nginx-1.14.0,附带有清理日志任务程序XML文件

    windows安装nginx-1.14.0,附带有清理日志任务程序XML文件。安装服务后,设置服务自动启动。修改XML配置(对应文件路径),然后倒入到任务程序运行。

    Windows下Nginx的安装与配置

    此文档详细介绍了Windows下Nginx的安装与配置,可以让用户在最短的时间内完全配置好nginx!

    nginx-1.11windows版免安装

    nginx-1.11.10的windows版免安装版本。 安装目录执行nginx -t -c conf/nginx.conf检测配置文件是否有效。

    nginx-rtmp-server

    windows下已经配置好的nginx-rtmp服务器,可以实现实时流数据的发送,一键开启rtmp-server服务器,非常方便。

    免部署的Windows 平台下的nginx-rtmp-win32 流媒体服务器

    免部署的Windows 平台下的nginx-rtmp-win32 流媒体服务器,直接解压运行nginx.exe 即可开启RTMP流媒体直播服务器功能,集直播和网页直播功能,内置web版的流媒体推流,播放工具,网页端口见配置文件nginx.conf

    nginx-1.8.1-windows

    nginx1.8.1工具包,windows下使用的,绿色版,直接下载解压,运行nginx.exe即可,配置文件在conf下的nginx.conf

    nginx-1.14.0.tar.gz和nginx-1.14.0.zip(Linux和windows)

    Nginx 安装非常的简单,配置文件 非常简洁(还能够支持perl语法),Bugs非常少的服务器: Nginx 启动特别容易,并且几乎可以做到7*24不间断运行,即使运行数个月也不需要重新启动。你还能够在 不间断服务的情况下进行...

    nginx for windows 傻瓜配置

    nginx for windows nginx-1.14.0.rar 第一步: nginx-1.14.0.rar右键解压文件到D盘(不支持中文目录) D:\nginx-1.14.0\nginx.exe 第二步: 拷贝证书到目录cert 第三步: conf/vhosts.conf 修改网站配置文件 server { ....

    nginx for windows下载以及详细安装与配置

    1.目前官方 Nginx 并不支持Windows,您只能在包括Linux,UNIX,BSD系统下安装和使用,现在提供nginx for windows下载以及详细安装与配置,供windows下的nginx应用。 2.Nginx 本身只是一个HTTP和反向代理服务器,它无法...

    Nginx-Service.zip

    解压后放在Nginx目录下,并修改配置文件nginx-service.xml后在CMD窗口中执行nginx-service.exe install,详细参考:https://blog.csdn.net/ounumman/article/details/107630987

    nginx with nginx-http-flv-module

    windows下编译的nginx,添加了nginx-http-flv-module,可用作实时流媒体服务器使用,具体是使用和配置方面可参照https://github.com/winshining/nginx-http-flv-module进行使用和配置。

    nginx-0.7.65在windows下整合php5

    windows下整合nginx-0.7.65+php5生产配置。 nginx-0.7.65.zip php-5.3.2-nts-Win32-VC6-x86.zip

    windows-nginx-rtmp.zip

    该资源为Windows系统下的nginx版本,并在nginx.conf中配置rtmp模块,可实现视频的点播与直播功能,通过该工具可在Windows下搭建基于nginx的视频直播和点播系统

Global site tag (gtag.js) - Google Analytics