分享

nginx在WIN下的配置和安装 .

 唐僧0012 2012-09-14

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

 

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

 

3、然后配置好你的PHP;

 

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

cgi.force_redirect = 0

fastcgi.impersonate = 1

cgi.rfc2616_headers = 1

 

 

4、开始配置/nginx/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       88;
        #监听88端口,可以随意更改;
        server_name  localhost;

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

        #access_log  logs/host.access.log  main;

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

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

 

OK,应该就可以了。

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多