I know how to run 1 django application on windows server using mod_wsgi & apache. Now I want to run more than one django application on the same server.
I have the following configurations
httpd.conf
at the end of the file I added
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
for application 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
for 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
settings
<VirtualHost *:92>
ServerName app1.localhost
WSGIPassAuthorization On
ErrorLog "logs/app1.error.log"
CustomLog "logs/app1.access.log" combined
WSGIScriptAlias / "C:Apache24htdocsapp1app1wsgi_windows.py" application-group=%{app1}
<Directory "C:Apache24htdocsapp1app1">
<Files wsgi_windows.py>
Require all granted
</Files>
</Directory>
Alias /static "C:Apache24htdocsapp1assets"
<Directory "C:Apache24htdocsapp1assets">
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:Apache24htdocsapp2app2wsgi_windows.py" application-group=%{app2}
<Directory "C:Apache24htdocsapp2app2">
<Files wsgi_windows.py>
Require all granted
</Files>
</Directory>
Alias /static "C:Apache24htdocsapp2assets"
<Directory "C:Apache24htdocsapp2assets">
Require all granted
</Directory>
</VirtualHost>
When I restart apache
When app1 is working, I got error on app2 that ModuleNotFoundError: No module named 'app1'r
and When app2 is working I got error on app1 that ModuleNotFoundError: No module named 'app2'r