Nginx - Windows下Nginx初入门
公司刚使用nginx,预先学习下。鉴于机器没有Linux环境,在Windows熟悉下。
下载
目前(2015-07-11),nginx的稳定版本是1.8.0,在官网下载先,windows版的nginx1.8.0
这是一个zip文件,解压后即可使用
Windows下的安装与启动
绿色文件,无须安装,直接即可启动。
据我所知,3种启动途径,其实都类似:
一、双击nginx.exe图标,可见黑窗口一闪而过,启动完毕。
二、命令行到nginx目录,输入nginx启动。(注,此方式命令行窗口无任何提示,且被锁定)
三、命令行到nginx目录,输入start nginx启动,此方式不锁定
启动后,默认情况下(无修改配置),可见到有两个nginx的进程,1个是master process,1个是worker processes。

如果你在配置中配置2个worker_processes,进程中就可以看到1个是master process,2个是worker processes。
测试
默认nginx部署了些静态内容,我们可通过它测试nginx是否在工作。
默认的配置文件(NGINX_HOME/conf/nginx.conf)如下:
#user nobody;
worker_processes 1; #error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #pid logs/nginx.pid; events {
worker_connections 1024;
} http {
include mime.types;
default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on;
#tcp_nopush on; #keepalive_timeout 0;
keepalive_timeout 65; #gzip on; server {
listen 80;
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / {
root html;
index index.html index.htm;
} #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_pass http://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;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
} # another virtual host using mix of IP-, 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 {
# listen 443 ssl;
# server_name localhost; # ssl_certificate cert.pem;
# ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; # location / {
# root html;
# index index.html index.htm;
# }
#} }
通过观察配置文件的非注释项(参考Nginx配置文件nginx.conf中文详解),大概可知:
1、启动了1个worker processes
2、worker_connections,最大并发数为1024
3、include mime.types,引入mime.types文件所声明的文件扩展名与文件类型映射
4、application/octet-stream,默认使用application/octet-stream
5、sendfile,开启高效文件传输模式
6、监听本机“localhost”的80端口
7、映射目录为“当前目录的html目录”
8、出现500、502、503、504错误,则映射到50x.html
浏览地址http://localhost,即可访问其默认页面,即映射到NGINX_HOME/html/index.html
其他静态内容,如html、图片,可自行添加测试。
日志
日志默认位于NGINX_HOME/logs/,可见:
1、access.log,访问日志
2、error.log,异常日志
3、nginx.pid,进程(仅在启动nginx后才有此日志)
CentOS下Nginx的安装与启动
tar -zxvf nginx-1.8..tar.gz
cd nginx-1.8.
./configure
make
make install
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
安装完毕,查看进程及相关日志:
ps -ef | grep nginx
less /usr/local/nginx/logs/error.log
less /usr/local/nginx/logs/nginx.pid
less /usr/local/nginx/logs/access.log
较详细的Nginx在Linux的博文见《【Nginx】Nginx在Linux下的入门介绍》。
Nginx - Windows下Nginx初入门的更多相关文章
- Nginx - Windows下Nginx初入门,附CentOS下Nginx的安装
公司刚使用nginx,预先学习下.鉴于机器没有Linux环境,在Windows熟悉下. 下载 目前(2015-07-11),nginx的稳定版本是1.8.0,在官网下载先,windows版的nginx ...
- Nginx - Windows下Nginx基本安装和配置
Nginx 是一个轻量级的高性能 Http WebServer,以事件驱动方式编写,因此相比 Apache 而言,Nginx 更加稳定.性能更好,而且配置简单,资源占用较低. 1. 安装 Nginx ...
- Nginx - Windows下nginx定时分割日志
1.建立批处理脚本,c:\soft\demo.bat @echo off taskkill /F /IM nginx.exe > nul cd C:\soft\nginx-1.11.3 rem ...
- Windows下Nginx配置SSL实现Https访问(包含证书生成)
Vincent.李 Windows下Nginx配置SSL实现Https访问(包含证书生成) Windows下Nginx配置SSL实现Https访问(包含证书生成) 首先要说明为什么要实现https ...
- Windows下Nginx Virtual Host多站点配置详解
Windows下Nginx Virtual Host多站点配置详解 此教程适用于Windows系统已经配置好Nginx+Php+Mysql环境的同学. 如果您还未搭建WNMP环境,请查看 window ...
- windows下nginx的启动关闭
Windows下Nginx的启动.停止等命令 在Windows下使用Nginx,我们需要掌握一些基本的操作命令,比如:启动.停止Nginx服务,重新载入Nginx等,下面我就进行一些简单的介绍. .启 ...
- Windows下Nginx的启动、停止等命令
Windows下Nginx的启动.停止等命令 在Windows下使用Nginx,我们需要掌握一些基本的操作命令,比如:启动.停止Nginx服务,重新载入Nginx等,下面我就进行一些简单的介绍.1.启 ...
- Windows下Nginx的启动、停止等命令(转)
Windows下Nginx的启动.停止等命令 在Windows下使用Nginx,我们需要掌握一些基本的操作命令,比如:启动.停止Nginx服务,重新载入Nginx等,下面我就进行一些简单的介绍.1.启 ...
- windows下nginx+fastcgi不能使用file_get_contents/curl/fopen的原因
这两天一直在搞windows下nginx+fastcgi的file_get_contents请求.我想,很多同学都遇到当file_get_contents请求外网的http/https的php文件时毫 ...
随机推荐
- python之urllib
简单的web应用包括使用被称为url(统一资源定位器,uniform resource locator)的web地址 这个地址用来在web上定位一个文档,或调用一个CGI程序来为你的客户端产生一个文档 ...
- System.IO.Directory类
1.参考的博客:System.IO.Directory类和System.DirectoryInfo类(http://blog.sina.com.cn/s/blog_614f473101017du4.h ...
- Python3 多线程下载代码
根据http://www.oschina.net/code/snippet_70229_2407修改而来的增强版.貌似原版源自Axel这个多线程下载工具. ''' Created on 2014-10 ...
- 使用Dapper时,如何将MySqlParameters[] 变成Dapper.DynamicParameters动态对象
在开发过程中,如何替原生的参数化MySqlParameters[]换成Dpapper的参数化DynamicParameters对象正确的做法:var args = new DynamicParamet ...
- JSP中setattribute与setParameter的区别
HttpServletRequest类既有getAttribute()方法,也由getParameter()方法,这两个方法有以下区别: (1)HttpServletRequest类有setAttri ...
- 命令行参数 main()函数设计
一.main()函数的形式 int main( void )--无参数形式 { ... return 0; } int main( int argc, char *argv[] )--带参数形式 { ...
- 对象转型 casting
一个基类的引用类型变量可以"指向"其子类对象. 一个基类的引用不可以访问其子类对象新增加的成员(属性和方法). 基类强制转型成子类,则能访问子类独有的成员. 可以使用 引用变量in ...
- 浪潮不能进bios解决过程
开机时会有个提示一闪而过,经过拍摄视频观看发现是"Press DEL to SETUP or TAP to post" 但是,反复重启不停按Delete键都无效,都进入了Ctrl+ ...
- 有关eclipse连接SQL Server 2008的问题
1.首先,提供一个链接http://blog.163.com/jackie_howe/blog/static/19949134720122261121214/ 这个链接有详细更改SQL Server ...
- #import、#include、@class、@protocol、@interface
#include 它用于对系统自带的头文件的引用,编译器会在系统文件目录下去查找该文件.(注意重复引用) #import 是Objective-C针对#include的改进版本,确保引用的文件只会被引 ...