博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Ubuntu Nginx uwsgi django 初试
阅读量:6842 次
发布时间:2019-06-26

本文共 6509 字,大约阅读时间需要 21 分钟。

/************************************************************************************** *                         Ubuntu Nginx uwsgi django 初试 * 说明: *     最近打算通过Python搭建一个数据收集的网站,先做一个搭建测试。 *                  *                                                  2016-8-5 深圳 南山平山村 曾剑锋 *************************************************************************************/一、参考文章:    1. Ubuntu下搭建Nginx+Uwsgi+Python+Mysql开发环境        http://blog.csdn.net/hchuchuan/article/details/49718521    2. 基于nginx和uWSGI在Ubuntu上部署Django        http://www.jianshu.com/p/e6ff4a28ab5a    3. Install uwsgi 1.2.5 via pip        http://askubuntu.com/questions/182313/install-uwsgi-1-2-5-via-pip    4. How To Install the Django Web Framework on Ubuntu 14.04        https://www.digitalocean.com/community/tutorials/how-to-install-the-django-web-framework-on-ubuntu-14-04    5. Nginx+uWSGI 入门        http://my.oschina.net/u/877567/blog/201577二、Django目录结构:    zengjf@zengjf:~/website$ pwd    /home/zengjf/website    zengjf@zengjf:~/website$ tree    .    └── mysite        ├── manage.py        └── mysite            ├── __init__.py            ├── __init__.pyc            ├── settings.py            ├── settings.pyc            ├── urls.py            ├── urls.pyc            └── wsgi.py    2 directories, 8 files    zengjf@zengjf:~/website$三、nginx配置:    root@zengjf:/etc/nginx/sites-available# pwd    /etc/nginx/sites-available    root@zengjf:/etc/nginx/sites-available# cat default    # You may add here your    # server {    #   ...    # }    # statements for each of your virtual hosts to this file        ##    # You should look at the following URL's in order to grasp a solid understanding    # of Nginx configuration files in order to fully unleash the power of Nginx.    # http://wiki.nginx.org/Pitfalls    # http://wiki.nginx.org/QuickStart    # http://wiki.nginx.org/Configuration    #    # Generally, you will want to move this file somewhere, and start with a clean    # file but keep this around for reference. Or just disable in sites-enabled.    #    # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.    ##        server {        listen 8000 default_server;        listen [::]:8000 default_server ipv6only=on;            root /home/zengjf/website/mysite;        index index.html index.htm;            # Make site accessible from http://localhost/        server_name localhost;            location / {            # First attempt to serve request as file, then            # as directory, then fall back to displaying a 404.            # try_files $uri $uri/ =404;            include  uwsgi_params;            uwsgi_pass  127.0.0.1:9091;              #必须和uwsgi中的设置一致            # Uncomment to enable naxsi on this location            # include /etc/nginx/naxsi.rules        }            # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests        #location /RequestDenied {        #   proxy_pass http://127.0.0.1:8080;            #}            #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 /usr/share/nginx/html;        #}            # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000        #        #location ~ \.php$ {        #   fastcgi_split_path_info ^(.+\.php)(/.+)$;        #   # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini        #        #   # With php5-cgi alone:        #   fastcgi_pass 127.0.0.1:9000;        #   # With php5-fpm:        #   fastcgi_pass unix:/var/run/php5-fpm.sock;        #   fastcgi_index index.php;        #   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;    #   root html;    #   index index.html index.htm;    #    #   location / {    #       try_files $uri $uri/ =404;    #   }    #}            # HTTPS server    #    #server {    #   listen 443;    #   server_name localhost;    #    #   root html;    #   index index.html index.htm;    #    #   ssl on;    #   ssl_certificate cert.pem;    #   ssl_certificate_key cert.key;    #    #   ssl_session_timeout 5m;    #    #   ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;    #   ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";    #   ssl_prefer_server_ciphers on;    #    #   location / {    #       try_files $uri $uri/ =404;    #   }    #}    root@zengjf:/etc/nginx/sites-available# 四、运行uwsgi命令:    root@zengjf:/home/zengjf/website# uwsgi --socket 127.0.0.1:9091 --chdir /home/zengjf/website/mysite --wsgi-file mysite/wsgi.py --master --processes 2 --threads 2    *** Starting uWSGI 2.0.13.1 (64bit) on [Fri Aug  5 21:47:55 2016] ***    compiled with version: 4.8.4 on 04 August 2016 21:12:52    os: Linux-3.16.0-30-generic #40~14.04.1-Ubuntu SMP Thu Jan 15 17:43:14 UTC 2015    nodename: zengjf    machine: x86_64    clock source: unix    pcre jit disabled    detected number of CPU cores: 2    current working directory: /home/zengjf/website    detected binary path: /usr/local/bin/uwsgi    uWSGI running as root, you can use --uid/--gid/--chroot options    *** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***     chdir() to /home/zengjf/website/mysite    your processes number limit is 15313    your memory page size is 4096 bytes    detected max file descriptor number: 1024    lock engine: pthread robust mutexes    thunder lock: disabled (you can enable it with --thunder-lock)    uwsgi socket 0 bound to TCP address 127.0.0.1:9091 fd 3    Python version: 2.7.6 (default, Jun 22 2015, 18:01:27)  [GCC 4.8.2]    Python main interpreter initialized at 0x24ae640    python threads support enabled    your server socket listen backlog is limited to 100 connections    your mercy for graceful operations on workers is 60 seconds    mapped 249168 bytes (243 KB) for 4 cores    *** Operational MODE: preforking+threaded ***    WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x24ae640 pid: 4120 (default app)    *** uWSGI is running in multiple interpreter mode ***    spawned uWSGI master process (pid: 4120)    spawned uWSGI worker 1 (pid: 4121, cores: 2)    spawned uWSGI worker 2 (pid: 4122, cores: 2)

 

你可能感兴趣的文章
解决python中文处理乱码,先要弄懂“字符”和“字节”的差别
查看>>
Linux~连接windows的ftp,unzip出现的问题
查看>>
将不确定变为确定~感谢异或,是你让我彻底摆脱“否定式”
查看>>
动态改变EnterpriseLibary数据库访问链接字符串的三种方法
查看>>
25.6. 数值函数
查看>>
进制转换
查看>>
原来JScript中的关键字'var'还是有文章的
查看>>
JPA的事务注解@Transactional使用总结
查看>>
定时组件quartz系列<二>quartz的集群原理
查看>>
nuget常用命令
查看>>
圣诞节,把你的 JavaScript 代码都装扮成圣诞树吧
查看>>
适用于仪表盘项目的7个优秀JavaScript库
查看>>
丘吉尔与数据分析
查看>>
如何在Ubuntu以及Debian中安装DHCP服务器
查看>>
Linux基础命令介绍六:网络
查看>>
哪些智能家居产品最易遭受入侵?
查看>>
小练习6:统计出现最多的字母和次数
查看>>
CVPR 2018|Cascade R-CNN:向高精度目标检测器迈进
查看>>
阿拉伯数字转换成中文大写,中文货币的表达方式 python
查看>>
JS function
查看>>