[求助]ubuntu Nginx uwsgi 配置: 使用 uwsgi --http 可以, 使用 uwsgi --socket 是无法连接到服务器 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
myxinn

[求助]ubuntu Nginx uwsgi 配置: 使用 uwsgi --http 可以, 使用 uwsgi --socket 是无法连接到服务器

  •  
  •   myxinn 2018 年 4 月 11 日 4535 次点击
    这是一个创建于 2937 天前的主题,其中的信息可能已经有所发展或是发生改变。

    按着文档 https://uwsgi.readthedocs.io/en/latest/tutorials/Django_and_nginx.html 做的

    uwsgi --http :8000 --wsgi-file test.py 

    可以显示

     uwsgi --socket :8001 --wsgi-file test.py 

    无法连接服务器

    uwsgi log:

    (venv) ubuntu@VM-49-116-ubuntu:~/code/blog/mmxy$ uwsgi --socket :8001 --wsgi-file test.py *** Starting uWSGI 2.0.17 (64bit) on [Wed Apr 11 02:19:40 2018] *** compiled with version: 5.4.0 20160609 on 09 April 2018 17:37:14 os: Linux-4.4.0-91-generic #114-Ubuntu SMP Tue Aug 8 11:56:56 UTC 2017 nodename: VM-49-116-ubuntu machine: x86_64 clock source: unix detected number of CPU cores: 1 current working directory: /home/ubuntu/code/blog/mmxy detected binary path: /home/ubuntu/code/blog/venv/bin/uwsgi !!! no internal routing support, rebuild with pcre support !!! *** WARNING: you are running uWSGI without its master process manager *** your processes number limit is 3306 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 :8001 fd 3 Python version: 3.6.4 (default, Apr 10 2018, 00:02:46) [GCC 5.4.0 20160609] *** Python threads support is disabled. You can enable it with --enable-threads *** Python main interpreter initialized at 0xe92290 your server socket listen backlog is limited to 100 connections your mercy for graceful operations on workers is 60 seconds mapped 72920 bytes (71 KB) for 1 cores *** Operational MODE: single process *** WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0xe92290 pid: 8870 (default app) *** uWSGI is running in multiple interpreter mode *** spawned uWSGI worker 1 (and the only) (pid: 8870, cores: 1) 

    nginx 配置 mysite_nginx.conf

     upstream django { # server unix:///tmp/mmxy.sock; server 127.0.0.1:8001; # for a web port socket (we'll use this first) } server { listen 8000; server_name 140.143.242.243; # server_name sususuus.xyz; charset utf-8; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; # max upload size client_max_body_size 75M; # adjust to taste # Django media location /media { alias /home/ubuntu/code/blog/mmxy/media; } location /static { alias /home/ubuntu/code/blog/mmxy/static; } # Finally, send all non-media requests to the Django server. location / { uwsgi_pass django; include /etc/nginx/uwsgi_params; } } 

    直接访问服务器, 有 Nginx 的欢迎界面

    尝试给 uwsgi --socket :8001 --wsgi-file test.py 加一些参数 --protocol=http -b 30000 limit 128 都是无法连接服务器

    nginx 下的 /var/log/nginx/error.log 是个空文件, 不知道为什么

    尝试了各种办法, 重装了两次系统了, /(ㄒoㄒ)/~~

    coffeSlider
        1
    coffeSlider  
       2018 年 4 月 11 日 via Android
    一言不合就重装系统.....
    你看看 Nginx 日志,

    没记错的话,
    应该是 socket 包大小限制了。
    MonoBiao
        2
    MonoBiao  
       2018 年 4 月 11 日
    用 socket 文件进行通信呢?
    julyclyde
        3
    julyclyde  
       2018 年 4 月 11 日
    “无法连接服务器”是浏览器给出的提示(浏览器无法连接 nginx )
    还是 nginx 给出的提示( nginx 无法连接 uwsgi )
    myxinn
        4
    myxinn  
    OP
       2018 年 4 月 11 日
    @coffeSlider
    Nginx 没有错误日志
    `
    access.log
    223.72.97.144 - - [11/Apr/2018:11:06:17 +0800] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/604.3.5 (KHTML, like Gecko) Version/11.0.1 Safari/604.3.5"
    223.72.97.144 - - [11/Apr/2018:11:06:21 +0800] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/604.3.5 (KHTML, like Gecko) Version/11.0.1 Safari/604.3.5"
    ^[[A^C
    (venv) ubuntu@VM-49-116-ubuntu:/var/log/nginx$ tail -10f error.log
    ^C
    (venv) ubuntu@VM-49-116-ubuntu:/var/log/nginx$ ll error.log
    -rw-r----- 1 www-data adm 0 Apr 10 01:45 error.log
    `

    解决了, 通过 sudo nginx -t 测试 Nginx:
    Nginx 的 error.log 无权限, /var/nginx/pid 无权限
    都给了个 664 权限,
    不知道为什么, Nginx 的 access.log 可以, error.log 却没权限
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2925 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 55ms UTC 13:11 PVG 21:11 LAX 06:11 JFK 09:11
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86