windows下nginx安装、配置与使用

本文主要介绍windows下nginx安装、配置与使用的方法,讲解的比较全面,需要的朋友可以参考一下。
  目前国内各大门户网站已经部署了Nginx,如新浪、网易、腾讯等;国内几个重要的视频分享网站也部署了Nginx,如六房间、酷6等。新近发现Nginx 技术在国内日趋火热,越来越多的网站开始部署Nginx。

相比apeach、iis,nginx以轻量级、高性能、稳定、配置简单、资源占用少等优势广受欢迎。

1)下载地址:

http://nginx.org

2)启动

解压至c:\nginx,运行nginx.exe(即nginx -c conf\nginx.conf),默认使用80端口,日志见文件夹C:\nginx\logs

3)使用

http://localhost

4)关闭

nginx -s stop 或taskkill /F /IM nginx.exe > nul

5)常用配置

C:\nginx\conf\nginx.conf,使用自己定义的conf文件如my.conf,命令为nginx -c conf\my.conf

常用配置如下:

复制代码 代码如下:Nginx.conf代码
http {
server {
#1.侦听80端口
listen 80;
location / {

2. 默认主页目录在nginx安装目录的html子目录。

root html;
index index.html index.htm;

3. 没有索引页时,罗列文件和子目录

autoindex on;
autoindex_exact_size on;
autoindex_localtime on;
}

4.指定虚拟目录

location /tshirt {
alias D:\programs\Apache2\htdocs\tshirt;
index index.html index.htm;
}
}

5.虚拟主机www.emb.info配置搜索引擎大全

server {
listen 80;
server_name www.emb.info;
access_log emb.info/logs/access.log;
location / {
index index.html;
root emb.info/htdocs;
}
}
}

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

复制代码 代码如下:nginx version: nginx/0.7.65
TLS SNI support enabled
configure arguments:
–builddir=objs.msvc8
–crossbuild=win32
–with-debug --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=objs.msvc8/lib/pcre-7.9
–with-openssl=objs.msvc8/lib/openssl-0.9.8k
–with-openssl-opt=enable-tlsext
–with-zlib=objs.msvc8/lib/zlib-1.2.3
–with-select_module
–with-http_ssl_module
–with-http_realip_module
–with-http_addition_module
–with-http_sub_module
–with-http_dav_module
–with-http_stub_status_module
–with-http_flv_module
–with-http_gzip_static_module

猜你喜欢

转载自blog.csdn.net/weixin_44400506/article/details/89445663