电竞比分网-中国电竞赛事及体育赛事平台

分享

nginx在WIN下的配置和安裝 .

 唐僧0012 2012-09-14

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

 

2、下載下來后只需要解壓縮到任意地方即可;

 

3、然后配置好你的PHP;

 

配置PHP的時候需要注意一下幾個參數(shù)和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;
        #監(jiān)聽88端口,可以隨意更改;
        server_name  localhost;

        charset utf-8;
        #設(shè)置服務(wù)器的字符集

        #access_log  logs/host.access.log  main;

        location / {
 #設(shè)置網(wǎng)站跟路徑;
 root   E:/root;
 #默認(rèn)網(wǎng)頁文件;
            index  index.html index.htm index.php;
 #如果沒有頁面的話,那么列出文件夾資源;
 autoindex on;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #設(shè)置錯誤頁面;
        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最關(guān)鍵的地方:
        location ~ /.php$ {
            #root  E:/root;
 #配置監(jiān)聽端口,需要和PHP-CGI的端口一樣;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
 #這個是設(shè)置路徑的,應(yīng)該和root一樣(我沒有試過不一樣什么效果);
            fastcgi_param  SCRIPT_FILENAME  E:/root$fastcgi_script_name;
 #fastcgi_param  SCRIPT_FILENAME  $fastcgi_script_name;
            include        fastcgi_params;
        }
    }


   }

5、設(shè)置完成以后在CMD中輸入:start nginx;

 

6、然后進入PHP文件夾,輸入:php-cgi.exe -b 127.0.0.1:9000 ;

 

7、可以寫一下自己的重啟批處理命令:tskill nginx,start nginx;

 

OK,應(yīng)該就可以了。

分享到:

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多