gpt4 book ai didi

ec2 上的 Python uwsgi 设置

转载 作者:太空宇宙 更新时间:2023-11-04 10:55:48 24 4
gpt4 key购买 nike

我正尝试按照 http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html 上的教程进行操作.按照我的指示:

(env1)ubuntu@ip-172-31-**-**:~/tproxy/tp$ uwsgi --http :8000 --wsgi-file test.py
*** Starting uWSGI 2.0.9 (64bit) on [Tue Mar 3 11:25:12 2015] ***
compiled with version: 4.8.2 on 03 March 2015 02:58:28
os: Linux-3.13.0-44-generic #73-Ubuntu SMP Tue Dec 16 00:22:43 UTC 2014
nodename: ip-172-31-**-**
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /home/ubuntu/tproxy/tp
detected binary path: /home/ubuntu/.virtualenvs/env1/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 7862
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 http bound on :8000 fd 4
spawned uWSGI http 1 (pid: 11221)
uwsgi socket 0 bound to TCP address 127.0.0.1:55522 (port auto-assigned) fd 3
Python version: 3.4.0 (default, Apr 11 2014, 13:08:40) [GCC 4.8.2]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x786830
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72760 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
failed to open python file test.py
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 11220, cores: 1)

因为我在 ec2 ubuntu 实例上,所以我尝试在端口 8000 上打开公共(public)和私有(private) ips,例如 http://172.31 ..*:8000/,但请求超时。我做错了什么?

编辑:我尝试进行您建议的更改。这是输出:

(env1)ubuntu@ip-172-31-28-196:~$ ls
host_type.py requirements.txt test.py tproxy
(env1)ubuntu@ip-172-31-28-196:~$ sudo chmod 666 test.py
(env1)ubuntu@ip-172-31-28-196:~$ uwsgi --http :8000 --wsgi-file test.py
*** Starting uWSGI 2.0.9 (64bit) on [Tue Mar 3 14:45:58 2015] ***
compiled with version: 4.8.2 on 03 March 2015 02:58:28
os: Linux-3.13.0-44-generic #73-Ubuntu SMP Tue Dec 16 00:22:43 UTC 2014
nodename: ip-172-31-28-196
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /home/ubuntu
detected binary path: /home/ubuntu/.virtualenvs/env1/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 7862
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)
probably another instance of uWSGI is running on the same address (:8000).
bind(): Address already in use [core/socket.c line 764]
(env1)ubuntu@ip-172-31-28-196:~$ ls -la
total 60
drwxr-xr-x 7 ubuntu ubuntu 4096 Mar 3 03:03 .
drwxr-xr-x 3 root root 4096 Feb 20 22:20 ..
-rw------- 1 ubuntu ubuntu 1554 Mar 3 11:35 .bash_history
-rw-r--r-- 1 ubuntu ubuntu 220 Apr 9 2014 .bash_logout
-rw------- 1 ubuntu ubuntu 3751 Feb 27 19:49 .bashrc
drwx------ 3 ubuntu ubuntu 4096 Feb 27 21:08 .cache
-rw-rw-r-- 1 ubuntu ubuntu 0 Feb 23 17:15 host_type.py
drwxrwxr-x 2 ubuntu ubuntu 4096 Feb 25 18:02 .pip
-rw-r--r-- 1 ubuntu ubuntu 675 Apr 9 2014 .profile
-rw-rw-r-- 1 ubuntu ubuntu 73 Mar 2 02:35 requirements.txt
drwx------ 2 ubuntu ubuntu 4096 Feb 20 22:20 .ssh
-rw-rw-rw- 1 root root 136 Mar 3 03:02 test.py
drwxrwxr-x 3 ubuntu ubuntu 4096 Mar 2 18:33 tproxy
-rw------- 1 ubuntu ubuntu 4119 Feb 27 19:51 .viminfo
drwxrwxr-x 3 ubuntu ubuntu 4096 Feb 28 02:17 .virtualenvs
(env1)ubuntu@ip-172-31-28-196:~$

最佳答案

找不到 test.py。确保它对该文件具有权限。你用 sudo 做了你的 virtuslenv 吗?如果是这样,请执行 chmod 并将文件夹权限更改为您的 nginx 和 uwsgi 可以访问的内容。或者它可能是我们错误的 test.py 文件的路径,仔细检查。

关于ec2 上的 Python uwsgi 设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28830917/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com