在EC2上的Python uwsgi设置Python、uwsgi

2023-09-12 23:35:46 作者:阿狸的狐狸精。

我想按照教程在的http:// uwsgi -docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html 。继指示我:

 (ENV1)的ubuntu @ IP-172-31  -  **  -  **:〜/ tproxy / TP $ uwsgi --http:8000 --wsgi文件test.py
***开始uWSGI 2.0.9(64位)在[星期二3月3日11时25分十二秒2015年] ***
4.8.2在2015年03月2时58分28秒:版本编译
操作系统:Linux-3.13.0-44-通用#73,Ubuntu的SMP周二12月16日零时22分43秒UTC 2014年
节点名:IP-172-31  -  **  -  **
机:x86_64的
时钟源:UNIX
CPU内核的检测数量:1
当前的工作目录:/家居/ Ubuntu的/ tproxy / TP
检测二进制文件路径:/home/ubuntu/.virtualenvs/env1/bin/uwsgi
!没有内部路由支持,重建与PCRE支持!
***警告:您正在运行uWSGI没有它的主进程管理器***
您的流程数量限制为7862
你的内存页面大小为4096字节
检测到的最大文件描述符数:1024
锁定引擎:PTHREAD强大的互斥体
雷鸣锁:禁用(你可以用--thunder锁启用它)
uWSGI HTTP绑定在:8000 FD 4
催生uWSGI HTTP 1(PID:11221)
uwsgi插槽0绑定到TCP地址127.0.0.1:55522(端口自动分配)。FD 3
Python版本:3.4.0(默认情况下,2014年4月11日,13点08分四十○秒)[GCC 4.8.2]
*** Python的线程支持被禁用。你可以用--enable-线程使其***
在0x786830 Python的主跨preTER初始化
你的服务器监听套接字积压限制为100个连接
你的怜​​悯工人优雅的操作是60秒
映射72760字节(71 KB)为1芯
***操作模式:单一进程***
无法打开Python文件test.py
无法加载应用程序0(挂载点='')(可调用未找到或导入错误)
***没有应用程序加载。要在全动态模式下***
*** uWSGI在多个跨preTER模式下运行***
催生uWSGI工人1(也是唯一)(PID:11220,芯:1)
 

由于我在一个EC2实例Ubuntu的我试图打开公共和私人IPS在8000端口,如 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文件test.py
***开始uWSGI 2.0.9(64位)在[星期二3月3日14时45分58秒2015年] ***
4.8.2在2015年03月2时58分28秒:版本编译
操作系统:Linux-3.13.0-44-通用#73,Ubuntu的SMP周二12月16日零时22分43秒UTC 2014年
节点名:IP-172-31-28-196
机:x86_64的
时钟源:UNIX
CPU内核的检测数量:1
当前的工作目录:/家居/ Ubuntu的
检测二进制文件路径:/home/ubuntu/.virtualenvs/env1/bin/uwsgi
!没有内部路由支持,重建与PCRE支持!
***警告:您正在运行uWSGI没有它的主进程管理器***
您的流程数量限制为7862
你的内存页面大小为4096字节
检测到的最大文件描述符数:1024
锁定引擎:PTHREAD强大的互斥体
雷鸣锁:禁用(你可以用--thunder锁启用它)
(8000)可能uWSGI的另一个实例是在同一个地址上运行。
绑定():地址已在使用[核心/ socket.c线764]
(ENV1)的ubuntu @ IP-172-31-28-196:〜$ LS -la
共有60个
drwxr-XR-x 7的Ubuntu的Ubuntu的4096 3月3日03:03。
drwxr-XR-×3根根4096 2月20日22:20 ..
-rw ------- 1 Ubuntu的Ubuntu的1554 3月3日11:35 .bash_history的
-rw-R  -  R-- 1 Ubuntu的Ubuntu的220 2014年4月9日.bash_logout中
-rw ------- 1 Ubuntu的Ubuntu的3751 02月27日19:49的.bashrc
drwx ------ 3 Ubuntu的Ubuntu的4096 02月27日21:08 .cache
-rw-RW-R-- 1 Ubuntu的Ubuntu的0 2月23日17:15 host_type.py
drwxrwxr-X 2 Ubuntu的Ubuntu的4096年02月25 18:02将该.pip
-rw-R  -  R-- 1 Ubuntu的Ubuntu的675 2014年4月9日的.profile
-rw-RW-R-- 1 Ubuntu的Ubuntu的73 3月2日02:35 requirements.txt
drwx ------ 2 Ubuntu的Ubuntu的4096 2月20日22:20的.ssh
-rw-RW-RW-1根136根3月3日03:02 test.py
drwxrwxr-X 3的ubuntu ubuntu的4096 3月2日18:33 tproxy
-rw ------- 1 Ubuntu的Ubuntu的4119 02月27日19:51 .viminfo
drwxrwxr-X 3的Ubuntu Ubuntu的4096年02月28 02:17 .virtualenvs
(ENV1)的ubuntu @ IP-172-31-28-196:〜$
 

解决方案

据找不到test.py.请确保它有该文件的权限。你让你的virtuslenv使用sudo?如果这样做了chmod和更改文件夹权限的东西您的Nginx和uwsgi访问。或者,它可能是路径test.py文件我们的错误,仔细检查。

详解使用Nginx和uWSGI配置Python的web项目的方法

I'm trying to follow the tutorial at http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html. Following the directions I have:

(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)

Since I'm on an ec2 ubuntu instance I tried the opening public and private ips at port 8000, eg http://172.31..*:8000/ , but the request times out. What am I doing wrong?

edit: I tried to make the changes you suggested. Here is the output:

(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:~$

解决方案

It couldn't find test.py. Make sure it has permissions to the file. Did you make your virtuslenv with sudo? If so do a chmod and change the folder permissions to something your nginx and uwsgi has access to. Or it could be the path to the test.py file us wrong, double check that.