LoginSignup
5
6

More than 5 years have passed since last update.

Django + mod_wsgi + Apache で複数Djangoプロジェクトを公開する

Posted at

なぜいまこの話題なのか

ググって出てくる内容が、全体的にvirtualhostを利用する手法ばかりだったのですが、私の環境では、DNSでの名前解決ができる環境でないためvirtualhostが利用ませんでした。その他の方法を探しました。ありました。

結論

WSGIDaemonProcess + WSGIScriptAlias + WSGIProcessGroup を使おう
参照:python - Multiple mod_wsgi apps on one virtual host directing to wrong app - Stack Overflow

回答訳

私は複数のWSGIアプリを1つのApacheで実行していました。そして、複数のプロセスグループを作成することが、一番簡単な方法であることに気が付きました。
しかしその欠点は、複数のアプリを実行しているのに対し、実体は1つのプロセスであることです。それは、他の方法を利用するよりも少し多くの常駐メモリを使用する恐れがあります。
しかし、それはアプリ同士をうまく分離し、混乱を避けることができるし、メモリ使用量が少し増えるかもしれないことはあなたにとってどうでも良いことかもしれません。

(それはどちらも悪くないかもしれない。憶測ですが、それらは多くのテキストページを共有することができるかもしれないし。私の環境はメモリ的な問題がないので、特にこの問題を解決しようとはしていません)

私のhttpd.confは以下のとおりです。

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>
5
6
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6