fhg2010 发表于 2013-2-7 03:27:02

nginx在WIN下的配置和安装

1、首先到:http://nginx.net/去下载最新的nginx/Windows,这里我用的版本是:nginx/Windows-0.8.46


2、下载下来后只需要解压缩到任意地方即可;

3、然后配置好你的应用;

配置PHP的时候需要注意一下几个参数和APACHE的可能不太一样:

    cgi.force_redirect = 0

    fastcgi.impersonate = 1

    cgi.rfc2616_headers = 1

4、开始配置/nginx/conf下的nginx.conf;

帖一下我的配置:

    #usernobody;
    worker_processes1;

    #error_loglogs/error.log;
    #error_loglogs/error.lognotice;
    #error_loglogs/error.loginfo;

    #pid      logs/nginx.pid;

    events {
      worker_connections1024;
    }
    http {
      include       mime.types;
      default_typeapplication/octet-stream;

      #log_formatmain'$remote_addr - $remote_user [$time_local] "$request" '
      #                  '$status $body_bytes_sent "$http_referer" '
      #                  '"$http_user_agent" "$http_x_forwarded_for"';

      #access_loglogs/access.logmain;

      sendfile      on;
      #tcp_nopush   on;

      #keepalive_timeout0;
      keepalive_timeout65;

      #gzipon;

      server {
            listen       88;
            #监听88端口,可以随意更改;
            server_namelocalhost;

            charset utf-8;
            #设置服务器的字符集

            #access_loglogs/host.access.logmain;

            location / {
   #设置网站跟路径;
   root   E:/root;
   #默认网页文件;
                indexindex.html index.htm index.php;
   #如果没有页面的话,那么列出文件夹资源;
   autoindex on;
            }

            #error_page404            /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
            #配置PHP最关键的地方:
            location ~ /.php$ {
                #rootE:/root;
   #配置监听端口,需要和PHP-CGI的端口一样;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_indexindex.php;
   #这个是设置路径的,应该和root一样(我没有试过不一样什么效果);
                fastcgi_paramSCRIPT_FILENAMEE:/root$fastcgi_script_name;
   #fastcgi_paramSCRIPT_FILENAME$fastcgi_script_name;
                include      fastcgi_params;
            }
      }


   }

5、设置完成以后在CMD中输入:start nginx;

6、然后进入PHP文件夹,输入:php-cgi.exe -b 127.0.0.1:9000 ;

7、可以写一下自己的重启批处理命令:tskill nginx,start nginx;
页: [1]
查看完整版本: nginx在WIN下的配置和安装