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,应该是
- nginx -s stop
请参考官方文档nginx/Windows usage
或者使用windows的taskkill命令:
- 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.
常用配置如下:
- 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平台编译版支持哪些模块。我这里的结果为:
- 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
- --with-http_random_index_module
- --with-http_secure_link_module
- --with-mail
- --with-mail_ssl_module
- --with-ipv6
显然,最经常用的memcache, rewrite模块都没在其中,因此该win32编译版本仅能供基本开发测试使用,对于产品平台,应该重新编译自己想要的win32版本,或者在linux下使用更方便。
Nginx - Windows下Nginx基本安装和配置的更多相关文章
- windows下Anaconda的安装与配置正解
一.下载anaconda 第一步当然是下载anaconda了,官方网站的下载需要用迅雷才能快点,或者直接到清华大学镜像站下载. 清华大学提供了镜像,从这个镜像下载速度很快,地址: https://mi ...
- Nginx - Windows下Nginx初入门,附CentOS下Nginx的安装
公司刚使用nginx,预先学习下.鉴于机器没有Linux环境,在Windows熟悉下. 下载 目前(2015-07-11),nginx的稳定版本是1.8.0,在官网下载先,windows版的nginx ...
- Nginx - Windows下Nginx初入门
公司刚使用nginx,预先学习下.鉴于机器没有Linux环境,在Windows熟悉下. 下载 目前(2015-07-11),nginx的稳定版本是1.8.0,在官网下载先,windows版的nginx ...
- Windows下的maven安装及配置
有时候开发需要用到maven来进行项目管理,说下怎么配置maven吧 环境&工具: windows系统 jdk1.8 apache-maven-3.2.5.zip eclipse 首先需要去A ...
- windows下mysql5.7安装及配置
装完msi后,复制my-default.ini文件,黏贴为my.ini文件,内容修改如下: # For advice on how to change settings please see# htt ...
- windows下Maven的安装与配置
1 安装maven前首先确认计算机已正确安装JDK2 下载maven 地址:http://maven.apache.org/download.html安装文件格式如下:apache-maven-3.0 ...
- Windows下MySQL下载安装、配置与使用
用过MySQL之后,不论容量的话,发现比其他两个(sql server .oracle)好用的多,一下子就喜欢上了.下面给那些还不知道怎么弄的童鞋们写下具体的方法步骤. (我这个写得有点太详细了,甚至 ...
- Windows下Git的安装及配置
Git的BASH Git的为Windows提供了用于命令行运行的一个仿真BASH的Git.习惯LINUX和UNIX环境的你,可以在该BASH环境中输入“git”命令来完成各种版本控制的操作. 简介 G ...
- windows下Emacs的安装与配置
1.下载 到这个网址可以下载到Emacs的windows版本:http://ftp.gnu.org/pub/gnu/emacs/windows/ 只需要一个压缩文档,如emacs-23.2-bin-i ...
随机推荐
- Android笔记——JDK实现WebService服务
以天气预报为例,国家气象局计算的天气信息后在其服务器Server通过WebService对外暴露天气信息数据,客户端无论是java平台,ios平台,c#平台都可以通过WebService获取数据.体现 ...
- VS2010/MFC编程入门之二(利用MFC向导生成单文档应用程序框架)
VS2010/MFC编程入门之二(利用MFC向导生成单文档应用程序框架)-软件开发-鸡啄米 http://www.jizhuomi.com/software/141.html 上一讲中讲了VS20 ...
- Java:Collection集合类
特点:只能用于存储对象,集合长度时可变的,集合可以存储不同类型的对象. 数组和集合类同时容器,不同的是: 1.数组虽然也可以存储对象,但是长度是固定的:集合长度时可变的. 2.数组中可以存储基本数据类 ...
- O(1)时间内删除指定链表结点
题目 给定单链表头指针和一个结点指针,定义一个函数在O(1)时间内删除该结点. 分析 对于上图实例链表(a)删除指针p有两种方式 思路1:(b)找到前一个指针pre,赋值pre->next = ...
- github不小心同步覆盖了本地文件
昨天不小心github的commit还没push就同步了,导致本地文件被覆盖,一度以为没救了. 后来得微博 @空非无和 @柳烟堆雪 指点,用git reflog 恢复了文件. 事情是这样的... 我在 ...
- vb.net 写入文件同步锁
<SoapHeader("oHeader")> _ <WebMethod()> _ <ScriptMethod(ResponseFormat:=Res ...
- jsp+servlet+jquery 用jquery uploadify最新版本实现多文件上传
//这是script代码 <link rel="stylesheet" type="text/css" href="uploadify/uplo ...
- 如何从List<T>中筛选符合条件的数据的集合或个数
方法一:Linq ChannelList就是一个List类型的数据,IsOpen 是其元素的属性 channelCount = (from channel in DevicesManager.Inst ...
- C#将list转换为datatable
DataTable dt = new DataTable(); if (_list != null) { //通过反射获取list中的字段 System.Reflection.PropertyInfo ...
- 无锁编程(五) - RCU(Read-Copy-Update)
RCU(Read-Copy Update) RCU就是指读-拷贝修改,它是基于其原理命名的.对于被RCU保护的共享数据结构,读操作不需要获得任何锁就可以访问,但写操作在访问它时首先拷贝一个副本,然后对 ...