首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > windows >

nginx windows上安装

2012-09-20 
nginx windows下安装?第一步 下载nginx ,windows版本,解压保存在D:/nginx-1.0.4下( 用的1.0.4版)?第二步

nginx windows下安装

?第一步 下载nginx ,windows版本,解压保存在D:/nginx-1.0.4下( 用的1.0.4版)

?第二步 下载 php fast-cgi版本(我用的是 VC9 x86 Non Thread Safe),解压到D:/php-5.3.3下

?第三步 把D:/php-5.3.3./php.ini-development重命名成D:/php-5.3.3/php.ini,找到#cgi.fix_pathinfo=1,把#号去掉

?第四步? 修改D:/nginx-1.0.4/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;

???????

??????? #增加负载配置,单机以不同端口方式配置

??????? upstream localhost {
????
???????????? server 127.0.0.1:8080 weight=2;
???????????? server 127.0.0.1:8081 weight=1;
?????? ?}

??????? location / {
??????????? #root?? html;?????????? //此处为默认路径
??????????? root?? D:/PHPWeb;?? //此处为我修改,要运行PHP程序的路径
??????????? index? index.php index.html index.htm;? //增加了 index.php

?

??????????? #以下配置为服务器负载时进行的配置
??????????? proxy_pass http://localhost;
??????????? proxy_set_header Host $host;
??????????? proxy_set_header X-Real-IP $remote_addr;
??????????? proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
??????? }

??????? #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$ {
??? ??? ?#?? root???????? php;
??? ??? ??? #index??????? index.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?????????? D:/PHPWeb;??????? //运行的PHP程序路径
??????????? fastcgi_pass?? 127.0.0.1:9000;?
??????????? fastcgi_index? index.php;????????? //默认首页程序

??????????? #$document_root 指的是上面的 D:/PHPWeb
??????????? fastcgi_param? SCRIPT_FILENAME?? $document_root$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? ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
??? #??? ssl_prefer_server_ciphers?? on;

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

}

?

第五步、PHP以fast-cgi形式运行

?

启动PHP fastcgi执行环境,我们编写bat文件来启动Nginx和PHP的fastcgi

新建记事本,写入如下内容:

@echo off

start D:\php-5.3.3\php-cgi.exe -b 127.0.0.1:9000 -c D:\php-5.3.3\php.ini

start D:\nginx-1.0.4\nginx.exe

将此记事本改名为test.bat;

双击bat文件,即可启动Nginx和PHP的fastcgi

?

热点排行