一台虚拟主机上的多个 mod_wsgi 应用程序指向错误的应用程序 [英] Multiple mod_wsgi apps on one virtual host directing to wrong app

查看:35
本文介绍了一台虚拟主机上的多个 mod_wsgi 应用程序指向错误的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在同一域下的子目录中设置两个(或更多)Django 应用程序,例如:

I'm trying to get two (or more) Django applications set up at subdirectories under the same domain, e.g.:

http://example.com/site1/
http://example.com/site2/

我知道通过设置这样的 apache 虚拟主机通常可以正常工作:

I know that normally this works fine by setting up an apache virtualhost like this:

<VirtualHost *:80>
    ...
    WSGIScriptAlias /site1 /path/to/site1.wsgi
    WSGIScriptAlias /site2 /path/to/site2.wsgi
</VirtualHost>

现在,我已经验证每个站点都可以单独运行.但是当我尝试并行运行时,apache 将我发送到工作进程首先加载的任何站点.示例:

Now, I've verified that each site works individually. But when I try to run both side-by-side, apache sends me to whichever site the worker process loaded first. Example:

  1. 重启配置为服务 6 个线程的 apache
  2. 加载example.com/site1/,获取正确的页面
  3. 加载example.com/site2/,获取正确的页面
  4. 重复 2 和 3 2 次以上.
  5. 反复刷新example.com/site1/,观察它从一个站点到另一个站点的循环.

实际上,对于任何给定数量的工作进程,它都会循环发送请求到它首先命中的任何一个,而不管 WSGIScriptAlias 指令如何.无论我做什么(设置 WSGIProcessGroup、守护进程模式与嵌入模式或指令),它都会继续表现出这种行为.

Effectively, for any given number of worker processes, it cycles through the total number of them sending the request to whichever one it hit first regardless of the WSGIScriptAlias directive. No matter what I do (setting WSGIProcessGroup, daemon mode vs. embedded mode, or directives) it continues to exhibit this behavior.

如果有人能指出我在这里做错了什么,那就太棒了!

If anyone can point out what I'm doing wrong here, that would be phenomenal!

推荐答案

我在一个 Apache 安装上运行了多个 WSGI 应用程序,发现最简单的方法就是拥有多个进程组——每个进程组一个的应用程序.

I've had multiple WSGI apps running on a single Apache install, and found that the easiest thing to do is just have multiple process groups-- one for each of the apps.

与实际尝试让单个进程运行两个(或多个)应用程序相比,一个缺点是这可能会使用比其他方式更多的驻留内存.但它使它们很好地分开并避免了麻烦.这可能不是你的问题(这不是我的问题).

One downside, versus actually trying to get a single process to run both (or more) apps, is that this might use a little more resident memory than you could get away with otherwise. But it keeps them pretty well separated and avoids hassle. And that might not be a concern for you (it wasn't for me).

(也可能没那么糟糕,他们可能能够共享很多文本页面?这只是闲置的猜测;我还没有以任何方式验证这一点,因为我的设置根本没有内存不足)

(It might not be that bad either, they might be able to share a lot of text pages? That's just idle speculation; I haven't verified this in any way, as my setup was not at all memory-starved)

这里是我的 httpd.conf 的一些片段,大概是:

Here's some snippets of my httpd.conf, approximately:

WSGIDaemonProcess khdx_wsgi user=galdosd group=galdosd maximum-requests=10000
WSGIScriptAlias /khdx /home/galdosd/khdxweb/rel/khdx/apache/django.wsgi
<Location /khdx>
WSGIProcessGroup khdx_wsgi
</Location>

WSGIDaemonProcess sauron_wsgi user=galdosd group=galdosd maximum-requests=10000
WSGIScriptAlias /sauron /home/galdosd/finalsauronweb/django-root/apache/django.wsgi
<Location /sauron>
WSGIProcessGroup sauron_wsgi
</Location>

这篇关于一台虚拟主机上的多个 mod_wsgi 应用程序指向错误的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆