Articles of mod wsgi

Django + Apache + mod_wsgi:为什么多次执行wsgi脚本?

我对所有服务器技术都比较陌生,我遵循本教程,使用mod_wsgi在Apache Web服务器上部署我的django应用程序: http://thecodeship.com/deployment/deploy-django-apache-virtualenv-and-mod_wsgi/ 这是我的虚拟主机文件: <VirtualHost *:80> ServerName www.abcxyz.org ServerAlias abcxyz.org WSGIScriptAlias / /var/www/abcxyz/django/abcxyz/wsgi_prod.py Alias /static/ /var/www/abcxyz/static/ <Location "/static/"> Options -Indexes </Location> </VirtualHost> 据我了解, wsgi_prod.py文件应该只在服务器启动时执行一次(或者当它得到第一个请求 – 我不确定这一点)。 但在我的应用程序中执行多次,发送请求到服务器。 它不是在所有请求上执行,而是在其中一些上执行。 还有一些请求,有时只触发wsgi_prod.py的执行。 这是我的wsgi_prod.py文件: import os import sys import site import thread # Add the site-packages of the chosen virtualenv to work with site.addsitedir('/etc/Envs/abcxyz/local/lib/python2.7/site-packages') # Add the app's directory […]

在Mac OS X上将mod_wsgi安装到apache2上?

我用Homebrew来构build和安装mod_wsgi: $ brew install mod_wsgi ==> Downloading http://modwsgi.googlecode.com/files/mod_wsgi-3.2.tar.gz ######################################################################## 100.0% ==> ./configure –prefix=/usr/local/Cellar/mod_wsgi/3.2 –disable-debug –disabl ==> make install ==> Caveats NOTE: "brew install -v mod_wsgi" will fail! You must install in non-verbose mode for this to succeed. Patches to fix this are welcome (and should be sent upstream too.) * You must manually edit /etc/apache2/httpd.conf […]

django的Apache + mod_wsgi httpd.conf设置是否影响mysql?

我有一个使用Apache和mod_wsgi的Django网站。 自从上一个4-5天以来,我一直在我的pipe理员电子邮件上收到这种types的错误。 OperationalError: (1040, 'Too many connections') 我已经安装了Django的debugging工具栏,我有平均每个页面100-150查询和小于300毫秒的响应时间。 我不认为我重载我的MySql服务器。 另一方面,在我尝试重新configuration我的httpd.conf设置后,发生了一段时间。 我的网站每天收到800-1000次点击。 这些是我的httpd.conf设置 KeepAlive Off Listen 13646 MaxSpareThreads 15 MinSpareThreads 8 MaxClients 20 ServerLimit 20 SetEnvIf X-Forwarded-SSL on HTTPS=1 ThreadsPerChild 5 MaxRequestsPerChild 1000000 StartServers 20 WSGIDaemonProcess <project> processes=7 threads=12 python-path=<path> WSGIProcessGroup <project> WSGIRestrictEmbedded off WSGILazyInitialization On 任何帮助将非常感激。 PS。 我正在共享主机计划。 我的主机scheme有512MB RAM,300MB是免费的。

在apache + mod_wsgi下有多个python版本

我有几个虚拟主机在redhat上的相同的Apache实例下configuration: Apache的2.2.15 mod_wsgi-3.5用默认的系统python-2.6编译 对于每个虚拟主机, WSGIScriptAlias设置都指向激活虚拟环境的python文件: activate_this = '/path_to_the_virtualenv/bin/activate_this.py' execfile(activate_this, dict(__file__=activate_this)) 现在,我打算将其中一个项目升级到python-2.7,另一个项目是python-3.x。 我知道我可以有不同的虚拟环境,单独的python沙箱。 所以,python方面一切都很好。 问题是:是否有可能在相同的apache + mod_wsgi实例下为不同的apache虚拟主机使用不同的python版本? 如果不是,那么最好的select是什么? 有一个相关的WsgiPythonHome设置,但它是在“服务器configuration”上下文中全局定义的,而不是每个虚拟主机。 另外,mod_wsgi是为特定的python版本编译的,所以我不确定它可以处理这种情况。

mod_wsgi在标题之前的脚本输出结束

我的networking应用程序有问题。 有时当人们上传一个图像(似乎只发生在大图像),我有mod_wsgi谁与这个消息崩溃: End of script output before headers: wsgi.py, referer:http:::… Process 'wsgi' has died, restarting. Process 'wsgi' terminated by signal 9 所以引发了一个内部错误。 这是我的wsgi文件: import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") from django.core.wsgi import get_wsgi_application application = get_wsgi_application() 这里是wsgi conf文件 LoadModule wsgi_module modules/mod_wsgi.so WSGIPythonHome /opt/python/run/baselinenv WSGISocketPrefix run/wsgi WSGIRestrictEmbedded On <VirtualHost *:80> Alias /static/ /opt/python/current/app/static/ <Directory /opt/python/current/app/static/> Order allow,deny Allow […]

Elastic Beanstalk应用程序部署(用户 – > ELB – > Elastic Beanstalk mod_wsgi)

我有一个Python Elastic Beanstalk负载平衡应用程序。 以下是用户请求进入Elastic Beanstalk应用程序的path: user -> Elastic Beanstalk ELB -> Elastic Beanstalk mod_wsgi 问题: 在eb deploy新的应用程序版本之后,来自user的前2-4个请求将从ELB生成504个错误。 经过这些〜2-4个生成504的请求,一切都很好! 到处都是200s。 当504s发生时,根据/var/httpd/access_log ,零请求将传递到Elastic Beanstalk mod_wsgi应用程序。 在ELB决定重新开始工作之后,我只看到了200年代。 我已经尝试过的事情没有奏效: 我将Elastic Beanstalk ELB空闲超时增加到了300秒 我将Elastic Beanstalk mod_wsgi apache KeepAliveTimeout增加到了300秒,如下所示: http : //docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/ts-elb-error-message.html 有人可能会说,“只是和504一起生活!” 但是,实际的问题是,在我的生产环境中, user和Elastic Beanstalk ELB之间有CloudFlare 。 CloudFlare设置为积极caching.css和.js文件,因为我将md5散列添加到静态文件URL。 当这些重要文件的请求失败时,CloudFlare似乎将这些失败caching为404。 对这些文件的进一步请求404,从而打破了每个部署的站点的视觉样式。 再次使用相同的应用程序版本部署Elastic Beanstalk应用程序将修复CloudFlare 404问题。 这不是一个好的解决scheme。 我想继续使用CloudFlare,因为它使得一个优秀的透明CDN,所以摆脱它也不是一个解决scheme。 很难相信我对这个问题一无所知,但是Google,stackoverflow / serverfault和AWS论坛还没有find任何解决scheme,甚至是类似的问题报告。 我希望我对这种行为的描述在这里与某人敲响。 提前致谢。

限制基于IP的WSGI

所以我有Trac在我的debian服务器上运行,VirtualHost文件如下所示: … WSGIScriptAlias / /srv/domain/trac.wsgi WSGIScriptReloading On <Directory /srv/domain/tracprojects> WSGIApplicationGroup %{GLOBAL} Order deny,allow Deny from all </Directory> … 我认为这可能会拒绝所有人(我想要做的testing,这将工作)。 尽pipetrac应用程序仍在运行,但这并不影响安装。 有什么我需要把我的wsgi文件来限制访问,而不是在我的虚拟主机文件?

我怎样才能让Apache的403错误的configuration文件path和行号

我在Debian unstable上运行Apache 2.4.7。 当我尝试使用mod_wsgi模块运行supysonic时,出现了403错误。 我把日志级别为wsgi和authz_core达到trace6 ,但我仍然没有得到任何有用的消息。 请注意,我正在使用mod_access_compat ,因此Order … Allow组合是有效的。 我想特别看到什么configuration文件(例如某个.htaccess文件,或者标准的apache或debianconfiguration文件之一),以及哪一行包含生成403错误的规则。 我已经手动走树,检查在每个级别的Web服务器正在运行的用户已经读取权限的文件,并阅读和执行的目录。 我的/etc/apache2/apache.conf文件包括行: LogLevel info authz_core:trace6 wsgi:trace6 supysonic的/etc/apache2/conf-enabled/supysonic.conf的apacheconfiguration文件是: WSGIScriptAlias /supysonic /mnt/large_vol/home/bminton/public_html/programs/supysonic <Directory /mnt/large_vol/home/bminton/public_html/programs/supysonic> WSGIApplicationGroup %{GLOBAL} Order deny,allow Allow from all </Directory> 错误日志包含以下行: [Wed Jan 15 08:40:34.106119 2014] [authz_core:debug] [pid 13558] mod_authz_core.c(802): [client 127.0.0.1:58438] AH01626: authorization result of Require all denied: denied [Wed Jan 15 08:40:34.106197 […]

如何使用mod_wsgl而不使用CGI来使用apache使用apache来显示“Hello world”

我已经安装了Python,Apache。 命令行程序正在使用python。 我有两个虚拟主机在Apache site1.local site2.local 我想要的是我把文件放在site1的根目录下,并在浏览器中显示你好 只有mod_wsgl没有cgi

Apache,mod_wsgi上的权限被拒绝,用WSGISocketPrefix修复 – 但是为什么?

在似乎是一个随机发生的情况下,一个网站在今晚晚上去了,看了Apache的错误日志,这是这个问题: (13)Permission denied: mod_wsgi (pid=2751): Unable to connect to WSGI daemon process 'mysite.com-ssl' on '/var/run/apache2/wsgi.2579.0.2.sock' after multiple attempts. 现在我读了mod_wsgi的ConfigurationIssues wiki,修复看起来很合理。 无法写入该目录,因此必须使用WSGISocketPrefix指定替代scheme 所以我设定了: WSGISocketPrefix /var/run/wsgi 它解决了这个问题,并且该站点可以在Apache重启之后加载。 但是,我很好奇 – 为什么这个dirctory停止写入? 我错过了什么吗? /var/run/apache2目录由root:root拥有,但现在在/var/run/wsgi*.sock下运行的新套接字是www-data:root 。有一个服务器重新启动,但就是这样。 也许有什么东西现在接pipe对该目录启动权限? 有任何想法吗? 谢谢!