ec2 上的 Python uwsgi 设置

标签 python linux ubuntu amazon-ec2

我正尝试按照 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/

相关文章:

linux - docker构建失败没有repomd文件

linux - 将来自英特尔 MKL 的 LAPACK 与 gfortran 链接起来

ubuntu - 如何在 Ubuntu 中克隆 HG/Mercurial 远程存储库并运行 sh 文件?

linux - 打印 'find' linux 命令找到匹配项的目录

python - 如何根据第一列和第二列之间的差异获取数据框中第三列的值?

python - 程序功能不起作用。它不能传递变量

python - 是否有 Python 的可视化分析器?

c++ - Cassandra CPP 驱动程序

python - 尽管在同一目录中,但无法找到模块/文件夹

python - C++ 重载输入流运算符的公认 python 替代方案是什么?