Как разместить два приложения django на windows с помощью apache и mod_wsgi?
Я знаю, как запустить 1 приложение django на сервере windows с помощью mod_wsgi & apache. Теперь я хочу запустить более одного приложения django на одном сервере.
У меня есть следующие конфигурации
httpd.conf
В конце файла я добавил
LoadFile "C:/Python312/python312.dll"
LoadModule wsgi_module "C:/Python312/Lib/site-packages/mod_wsgi/server/mod_wsgi.cp312-win_amd64.pyd"
#WSGIPythonHome "C:/Python312"
windows_wsgi.py
для приложения app1
# Activate this path from virtual env
activate_this = "C:/Users/rahee/.virtualenvs/app1-jCWLzbvP/Scripts/activate_this.py"
exec(open(activate_this).read(),dict(__file__=activate_this))
import os
# import site
import sys
from decouple import config
# Add the site-packages of the selected virtual env to work with
# site.addsitedir = "C:/Users/rahee/.virtualenvs/app1-jCWLzbvP/Lib/site-packages"
sys.path.append("C:/Users/rahee/.virtualenvs/app1-jCWLzbvP/Lib/site-packages")
sys.path.insert(0, "C:/Users/rahee/.virtualenvs/app1-jCWLzbvP/Lib/site-packages")
# Add teh app directory to the PYTHON PATH
sys.path.append("C:/Apache24/htdocs/app1")
sys.path.append("C:/Apache24/htdocs/app1/app1")
os.environ['DJANGO_SETTINGS_MODULE'] = config('DJANGO_SETTINGS_MODULE')
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
windows_wsgi.py
для app2
# Activate this path from virtual env
activate_this = "C:/Users/rahee/.virtualenvs/app2-mArRrqZl/Scripts/activate_this.py"
exec(open(activate_this).read(),dict(__file__=activate_this))
import os
# import site
import sys
from decouple import config
# Add the site-packages of the selected virtual env to work with
# site.addsitedir = "C:/Users/rahee/.virtualenvs/app2-mArRrqZl/Lib/site-packages"
sys.path.append("C:/Users/rahee/.virtualenvs/app2-mArRrqZl/Lib/site-packages")
sys.path.insert(0, "C:/Users/rahee/.virtualenvs/app2-mArRrqZl/Lib/site-packages")
# Add the app directory to the PYTHON PATH
sys.path.append("C:/Apache24/htdocs/app2")
sys.path.append("C:/Apache24/htdocs/app2/app2")
os.environ['DJANGO_SETTINGS_MODULE'] = config('DJANGO_SETTINGS_MODULE')
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
httpd-vhosts.conf
настройки
<VirtualHost *:92>
ServerName app1.localhost
WSGIPassAuthorization On
ErrorLog "logs/app1.error.log"
CustomLog "logs/app1.access.log" combined
WSGIScriptAlias / "C:\Apache24\htdocs\app1\app1\wsgi_windows.py" application-group=%{app1}
<Directory "C:\Apache24\htdocs\app1\app1">
<Files wsgi_windows.py>
Require all granted
</Files>
</Directory>
Alias /static "C:\Apache24\htdocs\app1\assets"
<Directory "C:\Apache24\htdocs\app1\assets">
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:91>
ServerName app2.local
WSGIPassAuthorization On
ErrorLog "logs/app2.error.log"
CustomLog "logs/app2.access.log" combined
WSGIScriptAlias / "C:\Apache24\htdocs\app2\app2\wsgi_windows.py" application-group=%{app2}
<Directory "C:\Apache24\htdocs\app2\app2">
<Files wsgi_windows.py>
Require all granted
</Files>
</Directory>
Alias /static "C:\Apache24\htdocs\app2\assets"
<Directory "C:\Apache24\htdocs\app2\assets">
Require all granted
</Directory>
</VirtualHost>
Когда я перезапускаю apache
Когда app1 работает, я получаю ошибку на app2, что ModuleNotFoundError: No module named 'app1'\r
и Когда app2 работает, я получаю ошибку на app1, что ModuleNotFoundError: No module named 'app2'\r