zoukankan      html  css  js  c++  java
  • linux下利用nginx部署python网站

    首先目标机器需要安装python nginx uwsgi,其次,需要给Nginx写配置文件,大体内容如下,
    具体内容可见 http://blog.cn2p.com/web-server/nginx-uwgsi-python.html 比较具体。
    server {
    #修改监听端口
    listen 80;
    #修改域名
    server_name zone4j.com;

    #301重定向
    if ($host != ‘zone4j.com’) {
    rewrite ^/(.*)$ http://zone4j.com/? permanent;
    }

    #charset koi8-r;
    #access_log /var/log/nginx/log/host.access.log main;

    #动态内容,将http协议转uWSGI协议,转发给uWSGI处理
    location / {
    include uwsgi_params;
    uwsgi_pass 127.0.0.1:8023;
    }

    #静态内容nginx直接处理
    location ~.*(html|css|js|gif|jpg|jpeg|png|bmp|ico|txt)$ {
    root /var/www/html;
    }

    #404
    error_page 404 /404.html;
    location = /404.html {
    root /var/www/html;
    }

    # redirect server error pages to the static page /50x.html
    #
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root /usr/share/nginx/html;
    }
    }
    然后用Uwsgi执行server.py 文件(必须在项目的根目录文件下),命令如下 uwsgi_python3 -s 0.0.0.0:8080 --file server文件的绝对路径


    作者:wangqc
    出处:http://www.cnblogs.com/wangqc/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
    该文章也同时发布在我的独立博客中-wangqc

  • 相关阅读:
    TI科学家谈浮点DSP未来发展
    请爱护你的JTAG烧录口---记录
    程序猿必看
    富人与穷人的区别--转自红尘
    DSP已经英雄迟暮了吗?FPGA才是未来的大杀器?
    FPGA+ARM or FPGA+DSP?
    DDR3调试记录
    调试记录1
    有关FPGA
    Nginx常见配置说明
  • 原文地址:https://www.cnblogs.com/wangqc/p/nginxPython.html
Copyright © 2011-2022 走看看