Nginx + django windows下配置
1.下载nginx, 去http://nginx.org/en/download.html 下载,我下载的是1.8 stable版本。
2.配置文件/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;
#root /cygdrive/D/myjango;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#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;
#}
location ~* ^.+\.(html|jpg|jpeg|gif|png|ico|css|js)$
{
root D:/myjango;
expires 30d;
break;
} location ~ ^/static/ {
root D:/myjango;
expires 30d;
break;
}
location ~ ^/ {
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;
}
}
# 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 ssl;
# server_name localhost; # ssl_certificate cert.pem;
# ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; # location / {
# root html;
# index index.html index.htm;
# }
#} }
其他都没有改动,最重要的部分就是在server{}配置项里添加FASTCGI的配置和静态文件的路劲配置。
3. python 安装flup(Python的FastCGI组件)
pip install flup
4. 运行nginx服务器
D:\Users\rick.xu>cd D:\nginx-1.8.0\nginx-1.8.0 D:\nginx-1.8.0\nginx-1.8.0>start nginx.exe
5. 用FastCGI运行你的Django项目
D:\Users\rick.xu>cd D:\myjango D:\myjango>python manage.py runfcgi method=threaded host=127.0.0.1 port=8051
6. 在刷新localhost就能看到你的界面了
Nginx + django windows下配置的更多相关文章
- nginx在windows下配置反向代理
转自:https://blog.csdn.net/comeonyangzi/article/details/72466310 下载地址:http://nginx.org/download/ 下载后直接 ...
- Nginx + Tomcat Windows下的负载均衡配置
Nginx + Tomcat Windows下的负载均衡配置 一.为什么需要对Tomcat服务器做负载均衡? Tomcat服务器作为一个Web服务器,其并发数在300-500之间,如果超过50 ...
- windows 下配置 Nginx 常见问题(转)
windows 下配置 Nginx 常见问题 因为最近的项目需要用到负载均衡,不用考虑,当然用大名鼎鼎的Nginx啦.至于Nginx的介绍,这里就不多说了,直接进入主题如何在Windows下配置. 我 ...
- Windows下配置Nginx
一.今天是2017年1月18日.揣着一种也许叫做冲动的心情,决定以后每天都记录和回顾新涉及的技术,巩固已学到的知识,坚持. 二.回归到今天的技术主题,因为之前对于[反向代理]这种技术充满了好奇,借此机 ...
- windows 下配置 Nginx 常见问题
因为最近的项目需要用到负载均衡,不用考虑,当然用大名鼎鼎的Nginx啦.至于Nginx的介绍,这里就不多说了,直接进入主题如何在Windows下配置. 我的系统是win7旗舰版的,到官网下载最新版本 ...
- 在CentOS/Windows下配置Nginx(以及踩坑)
在CentOS/Windows下配置Nginx(以及踩坑) 1. 序言 因为这类文章网上比较多,实际操作起来也大同小异,所以我并不会着重于详细配置方面,而是将我配置时踩的坑写出来. 2. CentOS ...
- windows下配置wnmp
最近尝试windows下配置nginx+php+mysql,在这里总结一下. 1.下载windows版本的nginx,官网下载地址:http://nginx.org/en/download.htm, ...
- nginx+php windows安装配置
https://blog.csdn.net/zjiang1994/article/details/72876193 https://blog.csdn.net/bruce_wang_janet/art ...
- Windows下配置使用 MemCached
Windows下配置使用MemCached 工具: memcached-1.2.6-win32-bin.zip MemCached服务端程序(for win) Memcached Manage ...
随机推荐
- 开源项目:X265
1 Windows下编译X265 具体的编译环境: Windows 7(64bit) + Visual Stdio 2010 + Cmake 3.4.3 + vsyasm-1.3.0-win64 a. ...
- ASP.NET Razor 视图引擎编程参考
ASP.NET Razor 视图引擎编程参考 转载请注明出处:http://surfsky.cnblogs.com Rasor 视图引擎 http://msdn.microsoft.com/ ...
- 2搭建Android开发环境
这一章主要是讲解如何搭建Android开发环境,需要准备的工具有: (1) JDK6或以上的版本: (2) Eclipse (3) ADT(用于开发Android应用程序) (4) C ...
- 码农谷 求前N项之和
题目描述 有一分数序列:2/1.3/2.5/3.8/5.13/8.21/13.......求出这个数列的前N项之和,保留两位小数. 输入描述 N 输出描述 数列前N项和 样例 输入: 输出: 16.4 ...
- 条款20 STL函数对象
继承标准STL的函数对象 1: struct PopLess : public atd::binary_function<state,state,bool> 2: { 3: bool op ...
- POJ C程序设计进阶 编程题#2:四大湖
编程题#2:四大湖 来源: POJ(Coursera声明:在POJ上完成的习题将不会计入Coursera的最后成绩.) 注意: 总时间限制: 1000ms 内存限制: 65536kB 描述 我国有4大 ...
- Python-2.7.11+Django-1.9.4安装配置
1.去python官网下载2.7的最新版本 https://www.python.org/downloads 1.1 解压Python-2.7.11.tgz tar xvf Python-2.7.11 ...
- scribe日志分析工具安装
系统CentOS6.2 x86_64 1.yum安装gcc,flex,m4,python/python-devel,ruby,libevent/libevent-devel,openssl/opens ...
- Knockout.Js官网学习(监控属性Observables)
前言 1.创建一个ViewModel <script type="text/javascript"> //1.创建一个ViewModel var myViewModel ...
- 兼容ie7的导航下拉菜单
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...