下载安装
主站
http://nginx.org/
下载
http://nginx.org/en/download.html
下载稳定版
http://nginx.org/download/nginx-0.7.67.zip
书
http://nginx.org/en/docs/
中文wiki
http://wiki.nginx.org/NginxChs
解压,运行nginx.exe,查看 http://localhost/,没问题就出现:
中止nginx进程
手工,做个bat批处理,多复制几行,因为至少有2个nginx.exe在运行中,taskkill是Window自带的
X:/> taskkill /f /im nginx.exe
配置
配置文件在 conf/nginx.conf
假设项目在E:/project/python/mysite
对应配置文件的写法 /cygdrive/E/project/python/mysite
对应配置文件的写法(或者是这种) E:/project/python/mysite
假设Python安装在 F:/Python25/
对应配置文件的写法 /cygdrive/F/Python25/
对应配置文件的写法(或者是这种) F:/Python25/
两种写法都测试一下
先用这段替换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 64; } 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; #root /cygdrive/D/html; root /cygdrive/E/project/python/mysite; # 使用哪行,调试一下 #root E:/project/python/mysite; index index.html index.htm; charset utf-8; #access_log logs/host.access.log main; location ^~ /media/ { alias F:/Python25/Lib/site-packages/django/contrib/admin/media/; # 使用哪行,调试一下 #alias /cygdrive/F/Python25/Lib/site-packages/django/contrib/admin/media/; } # 静态资源 location ~* ^.+/.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$ { expires 30d; break; } location / { # 指定 fastcgi 的主机和端口 fastcgi_pass 127.0.0.1:8051; fastcgi_param PATH_INFO $fastcgi_script_name; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param QUERY_STRING $query_string; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_NAME $server_name; fastcgi_pass_header Authorization; fastcgi_intercept_errors off; } #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 ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} }安装flup
简介
flup是用python实现的WSGI(网页网关接口)
主站
http://www.saddi.com/software/flup/dist/
下载
http://www.saddi.com/software/flup/dist/flup-1.0.2.tar.gz
解压
D:/setup/python/flup-1.0.2/flup-1.0.2
安装
X:/解压目录>python setup.py install
成功提示
Installed f:/python25/lib/site-packages/flup-1.0.2-py2.5.egg
Processing dependencies for flup==1.0.2
Finished processing dependencies for flup==1.0.2
或者用这种方式,只要环境配置好了(点这里 )
X:/任意目录下>easy_install http://www.saddi.com/software/flup/dist/flup-1.0.2-py2.5.egg
django的fastcgi模式
在8051这个端口为nginx提供服务,对应nginx配置文件中写的。还是做成bat处理,可以做成服务形式
X:/项目>python manage.py runfcgi method=threaded host=127.0.0.1 port=8051
manage.py runfcgi里面有一堆参数,查看参数
X:/项目> manage.py help runfcgi
都配置好了查看
http://localhost/
ok
参考
在windows上装 nginx + fastcgi + flup +django 终于装好了
http://hi.baidu.com/sinomazing/blog/item/611b8516e701d912972b43c9.html
nginx详细配置说明
http://www.westphp.com/bbs/thread-62-1-1.html
为nginx配置python环境
http://zhiwei.li/text/2008/10/为nginx配置python环境/
Python 开发:flup、WSGI及Django
http://www.fresh3g.net/blog/tag/django/