`

一 Nginx(Win32) 配置详解

阅读更多
1、下载:http://nginx.org/en/download.html


解压缩nginx-1.2.4.zip


2运行nginx.exe
打开“任务管理器”
会看到产生了两个进程:


一个进程是主过程,另一个是工作进程。

3、在浏览器中输入:http://localhost或者http://127.0.0.1
会看到如下页面,说明Nginx启动成功


4、常用基本命令:
start nginxstart nginx
nginx -s stopfast shutdown
nginx -s quitgraceful shutdown
nginx -s reloadchanging configuration, starting new worker processes with a new configuration, graceful shutdown of old worker processes


5、说一下配置文件 conf/nginx.conf

#定义Nginx运行的用户及组,如user www www;
#user  nobody;
#定义启动进程数,一般配置为小于cpu数
worker_processes  1;
#全局错误日志及PID文件 
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

#工作模式及连接数上限 
events {
    #use epoll;#参考事件模型
    worker_connections  1024;
}

#设定http服务器(利用它的反向代理功能提供负载均衡支持)
http {
    include       mime.types;#文件扩展名与文件类型映射表
    default_type  application/octet-stream;#默认文件类型
    #charset gb2312;#默认编码

    #日志设定
    #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;
    #server_names_hash_bucket_size 128; #服务器名字的hash表大小


    sendfile        on;
    #tcp_nopush     on;#防止网络阻塞
    #tcp_nodelay    on;#防止网络阻塞

    #keepalive_timeout  0;
    keepalive_timeout  65;#超时时间

    #FastCGI是为了改善网站的性能——减少资源占用,提高访问速度,详细资料:参阅 http://www.fastcgi.com
    #fastcgi_connect_timeout 300;

    #gzip  on;
    #gzip_min_length 1k; #最小压缩文件大小
    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;
    #    server_name  localhost;

    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_timeout  5m;

    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers   on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

研究完配置文件,对比了一下Tomcat服务器的配置,基本功能是一致的,现在我们单独摘除 首页配置
        
location / {
            root   html;
            index  index.html index.htm;
        }

改为
 location / {
            root   html;
            index  jiaozg.html index.html index.htm;
        }


并在nginx-1.2.4\html   目录下添加自定义的文件jiaozg.html
<html>
<head>
<title>jiaozg</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body bgcolor="white" text="black">
<center><h1>欢迎来到jiaozg  Nginx学习笔记页面</h1></center>
</body>
</html>


在命令号输入:
E:\nginx-1.2.4>nginx -s reload




注:
①如果Nginx未启动,可以在logs\error.log中查找原因
②如果日志文件没有被创建,可以在Windows事件日志中查找原因
③如果显示的是一个错误页面,而不是预期的页面,也可以在logs\error.log中查找原因
④尽管可以同时开多个Nginx线程,但是实际上只有其中一个在做所有的工作。一个Nginx可以处理 不超过1024个并发连接

ref:http://blog.csdn.net/m13666368773/article/details/8016673
  • 大小: 170.7 KB
  • 大小: 120.3 KB
  • 大小: 107.4 KB
  • 大小: 123.4 KB
  • 大小: 78.7 KB
分享到:
评论

相关推荐

    nginx正向代理与反向代理详解

    在Nginx中配置反向代理,同样需要编辑配置文件,但这次我们将指定一个或多个内部服务器作为目标。例如,我们可以设置一个监听80端口的虚拟主机,将所有到达该主机的请求转发到8080端口上的某个服务器: ```nginx ...

    nginx-rtmp-win32-master.rar

    在【标题】"nginx-rtmp-win32-master.rar"中提到的是 Nginx 的一个特殊版本,它集成了 RTMP(Real-Time Messaging Protocol)模块,特别适用于流媒体服务。RTMP 是一种广泛用于实时流媒体的数据传输协议,常用于直播...

    nginx-rtmp-win32-1.2.1.zip

    在Windows上,解压"nginx-rtmp-win32-1.2.1.zip"后,会得到Nginx的可执行文件和配置文件。首先,你需要根据自己的需求编辑`nginx.conf`配置文件,添加RTMP模块的相关配置段,例如: ```nginx rtmp { server { ...

    nginx-rtmp-win32-master.zip

    1. **下载Nginx-RTMP**:Nginx-RTMP-win32-master.zip包含了预编译的Windows版本Nginx服务器,以及Nginx-RTMP模块。 2. **配置Nginx**:解压后,需要编辑`nginx.conf`配置文件,添加RTMP模块的相关设置,如服务器...

    nginx-rtmp-win32-master.zip带rtmp模块的windows版nginx

    本压缩包 "nginx-rtmp-win32-master.zip" 提供的是针对 Windows 操作系统的 Nginx 配置,包含了 RTMP 模块,使得 Windows 用户也能方便地搭建流媒体服务器。 在 Windows 上安装和配置 Nginx RTMP 服务器,首先需要...

    nginx_https+tomcat_http配置.docx

    ### Nginx与Tomcat HTTPS至HTTP反向代理配置详解 #### 一、Windows环境下Nginx与Tomcat HTTPS至HTTP反向代理配置 ##### 1. 安装Nginx - **下载Nginx** - 普通版下载地址: [http://nginx.org/en/download.html]...

    windows系统下将nginx作为系统服务启动

    在Windows系统中,将Nginx配置为系统服务启动是一项重要的任务,这使得Nginx能够在每次系统开机时自动运行,无需手动启动。本教程详细介绍了如何在Windows Server 2008 R2上将Nginx-1.12.2版本设置为系统服务,确保...

    Nginx服务器fair负载访问安装配置

    ### Nginx Fair 负载均衡模块详解与配置 #### 概述 Nginx 是一款广泛使用的高性能 HTTP 和反向代理 Web 服务器。它以其稳定、丰富的特性及低资源消耗而闻名。Nginx 支持多种负载均衡算法,其中之一就是 **Fair**...

    WIN下Nginx缓存加速配置方法

    ### WIN下Nginx缓存加速配置方法 在Windows环境下配置Nginx进行缓存加速是一种常见的优化方式,尤其对于需要频繁访问静态资源的应用场景来说,可以显著提高响应速度、减轻后端服务器的压力以及降低带宽消耗。下面将...

    nginx-1.17.8-win.zip

    **Nginx 1.17.8 Windows 版本详解** Nginx 是一个高性能的 Web 和反向代理服务器,以其高效的并发处理能力和轻量级的内存占用而闻名。在给定的压缩包 "nginx-1.17.8-win.zip" 中,包含了 Nginx 的最新1.17.8版本,...

    nginx免安装版(包含nginx服务启动和停止bat)

    **Nginx免安装版详解** Nginx是一款高性能、轻量级的Web服务器和反向代理服务器,常用于静态内容的处理和高并发场景。本资源提供的“nginx免安装版”是经过预配置和优化的版本,无需复杂的安装过程,可直接在...

    Nginx 安装成Windows 服务方法

    ### Nginx安装成Windows服务方法详解 在Web服务器领域,Nginx因其高效、稳定以及灵活的配置能力而备受青睐。然而,在Windows操作系统上,将Nginx配置为系统服务,以便于管理和自动化运行,是一项重要的技能。本文将...

    W7下的nginx+php配置

    ### W7下的nginx+php配置详解 #### 一、引言 随着Web开发技术的不断发展,服务器端语言如PHP和Web服务器软件如Nginx的需求日益增加。在Windows 7 (W7)环境下配置Nginx与PHP环境,对于开发者来说是一项基本技能。...

    nginx-1.21.6

    **Nginx 1.21.6:高性能Web服务器与反向代理详解** Nginx,又称为“engine x”,是一款广泛应用于互联网行业的高性能HTTP和反向代理服务器,同时支持IMAP/POP3/SMTP服务。其核心优势在于其优秀的并发处理能力,轻量...

    nginx-1.21.6.zip和nginx-1.21.6.tar.gz

    1. Nginx 1.21.6版本详解 Nginx的每个版本迭代都会带来性能优化和新功能的添加。1.21.6版本可能包含了一些修复的bug、安全更新以及对HTTP/2协议、WebSocket支持等方面的改进。具体改动需参考官方发布日志,以获取...

    nginx 1.9.7服务器windows版

    **Nginx 1.9.7 Windows Server详解** Nginx是一款高性能、轻量级的Web服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,由俄罗斯的Igor Sysoev开发。它以其高效稳定、低内存占用、支持高并发连接和丰富的...

Global site tag (gtag.js) - Google Analytics