我正在尝试将Django应用程序部署到Elastic Beanstalk.当我访问页面时,它永远不会加载.日志说:
Script timed out before returning headers: wsgi.py
Run Code Online (Sandbox Code Playgroud)
我可以进入服务器并运行manage.py runserver,然后curl 127.0.0.1:8000从另一个终端运行,这将成功返回页面.所以我认为它必须是Apache配置的一个问题,它被设置为Elastic Beanstalk的一部分.
这里有更多的日志:
[pid 15880] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[so:warn] [pid 15880] AH01574: module wsgi_module is already loaded, skipping
[auth_digest:notice] [pid 15880] AH01757: generating secret for digest authentication ...
[lbmethod_heartbeat:notice] [pid 15880] AH02282: No slotmem from mod_heartmonitor
[mpm_prefork:notice] [pid 15880] AH00163: Apache/2.4.9 (Amazon) mod_wsgi/3.4 Python/2.7.5 configured -- resuming normal operations
[core:notice] [pid 15880] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[:error] [pid 15881] /opt/python/run/venv/lib/python2.7/site-packages/numpy/oldnumeric/__init__.py:11: …Run Code Online (Sandbox Code Playgroud) 我不清楚为什么子解释器API存在以及为什么它在诸如mod_wsgi apache模块之类的模块中使用.它主要用于为同一进程中运行的不同应用程序创建安全沙箱,还是一种允许多线程并发的方法?也许两者?还有其他目的吗?
我有一个来自HTTP标头的字符串,但它已被转义..我可以使用什么功能来解决它?
myemail%40gmail.com -> myemail@gmail.com
Run Code Online (Sandbox Code Playgroud)
urllib.unquote()是否可行?
有人可以解释守护进程模式下的apache mod_wsgi和线程模式下的django fastcgi之间的区别.我认为它们都使用线程来实现并发性. 假设我使用nginx作为apache mod_wsgi的前端.
更新:
我正在比较内置fastcgi(./ manage.py方法=线程maxchildren = 15)的django和'daemon'模式下的mod_wsgi(WSGIDaemonProcess示例threads = 15).他们都使用线程并获得GIL,对吗?
UPDATAE 2:
所以,如果它们都相似,那么apache mod_wsgi对fastcgi有什么好处.我看到fastcgi的这些优点:
UPDATAE 3:
我现在对nginx + uwsgi很满意.
UPDATAE 4:
我现在对nginx + gunicorn很满意:)
这是这个问题的延续,但它已经偏离,所以我开始了一个新问题.我想使用Python 2.5而不是OS X的默认2.6.我已经为我的终端和诸如此类的东西设置了这个,但是每当apache运行时它给我以下错误输出:
[Thu Jun 23 00:01:42 2011] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Thu Jun 23 00:01:42 2011] [warn] mod_wsgi: Compiled for Python/2.5.4.
[Thu Jun 23 00:01:42 2011] [warn] mod_wsgi: Runtime using Python/2.6.1.
[Thu Jun 23 00:01:42 2011] [notice] Digest: generating secret for digest authentication ...
[Thu Jun 23 00:01:42 2011] [notice] Digest: done
[Thu Jun 23 00:01:42 2011] [notice] Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8l DAV/2 mod_wsgi/3.3 Python/2.6.1 configured -- resuming normal operations
Run Code Online (Sandbox Code Playgroud)
我已经设置了WSGIPythonPath以匹配sys.path在python shell中提供的内容: …
我想将我的Django项目部署到EC2服务器.我安装了mod_wsgi.
并在django的教程中进行了配置.
我得到以下内容:
Invalid command 'WSGIScriptAlias', perhaps misspelled or defined by a module not included in the server configuration
Run Code Online (Sandbox Code Playgroud)
是什么原因?mod_wsgi安装不正确?
LoadModule wsgi_module libexec/httpd/mod_wsgi.so
LoadModule alias_module libexec/httpd/mod_alias.so
WSGIScriptAlias / /usr/local/apache2/htdocs/mysite/mysite/wsgi.py
WSGIPythonPath /usr/local/apache2/htdocs/mysite/mysite
<Directory /path/to/mysite.com/mysite>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
Run Code Online (Sandbox Code Playgroud) 我正在研究django项目,我收到了这封错误邮件.
堆栈跟踪
File "/usr/local/lib/python2.7/dist-packages/Django-1.4.3-py2.7.egg/django/core/handlers/wsgi.py", line 180, in _get_post
self._load_post_and_files()
File "/usr/local/lib/python2.7/dist-packages/Django-1.4.3-py2.7.egg/django/http/__init__.py", line 379, in _load_post_and_files
self._post, self._files = QueryDict(self.body, encoding=self._encoding), MultiValueDict()
File "/usr/local/lib/python2.7/dist-packages/Django-1.4.3-py2.7.egg/django/http/__init__.py", line 335, in body
self._body = self.read()
File "/usr/local/lib/python2.7/dist-packages/Django-1.4.3-py2.7.egg/django/http/__init__.py", line 391, in read
return self._stream.read(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.4.3-py2.7.egg/django/core/handlers/wsgi.py", line 98, in read
result = self.buffer + self._read_limited()
File "/usr/local/lib/python2.7/dist-packages/Django-1.4.3-py2.7.egg/django/core/handlers/wsgi.py", line 92, in _read_limited
result = self.stream.read(size)
UnreadablePostError: request data read error
Run Code Online (Sandbox Code Playgroud)
为什么会出现这种错误?
怎么解决?
我在AWS上有一个现有的Elastic Beanstalk烧瓶应用程序偶尔不会初始化并给出以下错误:
[Mon Jan 23 10:06:51.550205 2017] [core:error] [pid 7331] [client 127.0.0.1:43790] script timed out before returning headers: application.py
[Mon Jan 23 10:10:43.910014 2017] [core:error] [pid 7329] [client 127.0.0.1:43782] End of script output before headers: application.py
Run Code Online (Sandbox Code Playgroud)
任何想法为什么会这样?最近我将项目requirements.txt改为包括在内pandas==0.19.2.在更改之前,程序将在返回相同错误之前工作几天.更多日志/计划详情:
[Mon Jan 23 10:05:36.877664 2017] [suexec:notice] [pid 7323] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Jan 23 10:05:36.886151 2017] [so:warn] [pid 7323] AH01574: module wsgi_module is already loaded, skipping
AH00557: httpd: apr_sockaddr_info_get() failed for ip-10-55-254-33
AH00558: httpd: Could not …Run Code Online (Sandbox Code Playgroud) 在我的Ubuntu 16.04服务器上,我有一个Apache conf文件/etc/apache2/sites-enabled/000-default.conf,看起来像这样(缩写):
WSGIApplicationGroup %{GLOBAL}
<VirtualHost *:80>
ServerName example.com
WSGIDaemonProcess myprocess user=ubuntu group=ubuntu threads=10 home=/home/ubuntu/myapp
WSGIProcessGroup myprocess
...
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
它在HTTP模式下工作正常,但是当我运行$ sudo certbot --apache设置HTTPS时,它会失败并显示错误Syntax error on line 7 of /etc/apache2/sites-enabled/000-default.conf: Name duplicates previous WSGI daemon definition. 第7行是以行开头的行WSGIDaemonProcess.
我正在尝试使用virtualenv设置运行WSGI.我的virtualenv一切正常:
(virtualenv)dev:/var/www/app$ which python
/var/www/virtualenv/bin/python
(virtualenv)dev:/var/www/app$ python
Python 2.6.1 (r261:67515, Dec 5 2008, 22:09:34)
[GCC 4.1.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import importlib
>>>
Run Code Online (Sandbox Code Playgroud)
而在我的httpd.conf中,我有以下方面的描述在这里:
WSGIPythonHome /var/www/virtualenv
WSGIPythonPath /var/www/virtualenv/lib/python2.6/site-packages
Run Code Online (Sandbox Code Playgroud)
但是当我尝试通过apache加载应用程序时,我收到以下错误:
[Wed Dec 28 12:28:15 2011] [error] [client 127.0.0.1] mod_wsgi (pid=15026): Exception occurred processing WSGI script '/var/www/app/wsgi.py'.
[Wed Dec 28 12:28:15 2011] [error] [client 127.0.0.1] Traceback (most recent call last):
[Wed Dec 28 12:28:15 2011] [error] [client 127.0.0.1] File "/var/www/app/wsgi.py", line 29, …Run Code Online (Sandbox Code Playgroud) mod-wsgi ×10
python ×7
apache ×4
django ×4
wsgi ×2
certbot ×1
deployment ×1
fastcgi ×1
flask ×1
header ×1
http ×1
lets-encrypt ×1
ubuntu-16.04 ×1
urllib2 ×1