最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Windows系統(tǒng)下使用flup搭建Nginx和Python環(huán)境的方法

 更新時(shí)間:2015年12月25日 16:40:58   作者:蒙奇D路飛  
這篇文章主要介紹了Windows系統(tǒng)下使用flup搭建Nginx和Python環(huán)境的方法,文中使用到了flup這個(gè)Python的FastCGI工具,需要的朋友可以參考下

首先確保你的電腦里已經(jīng)安裝了Python和Django,接下來我們還需要兩個(gè)組件,nginx服務(wù)器和flup(Python的FastCGI組件)
nginx下載地址:http://nginx.org/en/download.html
flup下載地址:http://www.saddi.com/software/flup/dist/flup-1.0.2.tar.gz
與Linux下不同的是,nginx在windows下是以一個(gè)應(yīng)用程序的方式運(yùn)行,而不是以一個(gè)服務(wù)運(yùn)行(難怪沒人在windows服務(wù)器上用nginx)
把剛剛下載好的兩個(gè)壓縮包都解壓到C:\nginx\, C:\flup\(目錄可自己選擇,這里只做個(gè)演示)然后用python setup.py install 命令

安裝flup,接著就要配置nginx了,打開C:\nginx\conf\nginx.conf,我的配置文件如下,大家可根據(jù)需要自行修改:

#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; 
 
    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; 
    #} 
     
    # 靜態(tài)資源 
    location ~* ^.+\.(html|jpg|jpeg|gif|png|ico|css|js)$ 
    { 
      root e:/gin/gin/; 
      expires 30d; 
      break; 
    } 
 
    location ~ ^/static/ { 
      root e:/gin/gin/; 
      expires 30d; 
      break; 
    }  
 
    location ~ ^/ { 
      # 指定 fastcgi 的主機(jī)和端口 
      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; 
  #  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 HIGH:!aNULL:!MD5; 
  #  ssl_prefer_server_ciphers  on; 
 
  #  location / { 
  #    root  html; 
  #    index index.html index.htm; 
  #  } 
  #} 
 
} 

需要注意的是,對(duì)于不需要url rewrite的目錄,比如存放css和圖片的目錄,需要在配置文件里指明,否則將無法訪問這些文件

    location ~ ^/static/ {
      root e:/gin/gin/;
      expires 30d;
      break;
    }

最后一步就是運(yùn)行nginx服務(wù)器,并且用FastCGI運(yùn)行你的Django項(xiàng)目了
進(jìn)入nginx的目錄:

  cd c:\nginx\
  start nginx

然后在瀏覽器里訪問http://loaclhost/ 就應(yīng)該可以看到nginx的歡迎界面了。最后進(jìn)入你的Django項(xiàng)目的根目錄,然后用一下命令來運(yùn)行服務(wù)器:

  python manage.py runfcgi method=threaded host=127.0.0.1 port=8051

刷新localhost頁面,你就能看到你的項(xiàng)目主頁啦~~
補(bǔ)充一點(diǎn)windwos下nginx操作的命令(來自官方文檔)

nginx -s stop quick exit
nginx -s quit graceful quit
nginx -s reload changing configuration, starting a new worker, quitting an old worker gracefully
nginx -s reopen reopening log files

大功告成,開始django之旅,ohye?。?!

相關(guān)文章

  • python3.8 微信發(fā)送服務(wù)器監(jiān)控報(bào)警消息代碼實(shí)現(xiàn)

    python3.8 微信發(fā)送服務(wù)器監(jiān)控報(bào)警消息代碼實(shí)現(xiàn)

    這篇文章主要介紹了python3.8 微信發(fā)送服務(wù)器監(jiān)控報(bào)警消息代碼實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2019-11-11
  • Flask學(xué)習(xí)之全局異常處理詳解

    Flask學(xué)習(xí)之全局異常處理詳解

    Flask是一個(gè)基于Python的Web框架,它提供了全局異常處理的機(jī)制來捕獲和處理應(yīng)用程序中的異常,下面就帶大家深入了解一下Flask是如何實(shí)現(xiàn)異常處理的,希望對(duì)大家有所幫助
    2023-06-06
  • 使用python實(shí)現(xiàn)語音文件的特征提取方法

    使用python實(shí)現(xiàn)語音文件的特征提取方法

    今天小編就為大家分享一篇使用python實(shí)現(xiàn)語音文件的特征提取方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2019-01-01
  • python Xpath語法的使用

    python Xpath語法的使用

    這篇文章主要介紹了python Xpath語法的使用,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-11-11
  • 一文帶你深入了解Python中的二次移動(dòng)平均法

    一文帶你深入了解Python中的二次移動(dòng)平均法

    二次移動(dòng)平均法,也稱為指數(shù)加權(quán)移動(dòng)平均法,是一種用于平滑時(shí)間序列數(shù)據(jù)的算法。這篇文章主要通過示例來和大家聊聊二次移動(dòng)平均法的使用,需要的可以了解一下
    2023-02-02
  • Python定時(shí)任務(wù)sched模塊用法示例

    Python定時(shí)任務(wù)sched模塊用法示例

    這篇文章主要介紹了Python定時(shí)任務(wù)sched模塊用法,結(jié)合實(shí)例形式分析了定時(shí)任務(wù)sched模塊的基本功能、參數(shù)含義、多線程定時(shí)任務(wù)等相關(guān)操作技巧,需要的朋友可以參考下
    2018-07-07
  • 詳解在Python中處理異常的教程

    詳解在Python中處理異常的教程

    這篇文章主要介紹了詳解在Python中處理異常的教程,是Python入門中的基礎(chǔ)知識(shí),需要的朋友可以參考下
    2015-05-05
  • Python+PyQt手搓一個(gè)簡單的記事本

    Python+PyQt手搓一個(gè)簡單的記事本

    這篇文章主要為大家詳細(xì)介紹了Python如何結(jié)合PyQt手搓一個(gè)簡單的記事本,文中的示例代碼簡潔易懂,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2025-02-02
  • Python中的字符串常用方法整理概述

    Python中的字符串常用方法整理概述

    Python中的字符串是一種不可變的序列類型,使用單引號(hào)(')或雙引號(hào)(")括起來。本文整理概述了python中字符串常用方法,文中有詳細(xì)的代碼示例,對(duì)學(xué)習(xí)或工作有一定的幫助,需要的同學(xué)可以參考一下
    2023-05-05
  • python實(shí)現(xiàn)寫數(shù)字文件名的遞增保存文件方法

    python實(shí)現(xiàn)寫數(shù)字文件名的遞增保存文件方法

    今天小編就為大家分享一篇python實(shí)現(xiàn)寫數(shù)字文件名的遞增保存文件方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-10-10

最新評(píng)論

黄梅县| 四川省| 玉田县| 汉中市| 平阳县| 仪征市| 高陵县| 东台市| 大庆市| 新野县| 赫章县| 资中县| 盘锦市| 包头市| 山阴县| 揭东县| 焦作市| 沙雅县| 华坪县| 山阴县| 黄梅县| 西充县| 大港区| 绥化市| 宜州市| 姜堰市| 普兰店市| 武汉市| 留坝县| 平谷区| 乌拉特前旗| 南和县| 锡林浩特市| 扎赉特旗| 兴安盟| 太仆寺旗| 博野县| 汽车| 襄垣县| 通海县| 西城区|