Django deployment error on xampp apache server in windows

I am trying to host a django application on Apache server using XAMPP and after going through all the settings necessary for the app to run, the webpage in ‘localhost’ is loading endlessly, enter image description here

Here’s my setup:

Running on venv, doing a pip freeze gives:

`asgiref==3.7.2
Django==3.2.20
mod-wsgi==4.9.4
mysqlclient==2.2.0
numpy==1.25.2
pandas==1.5.1
python-dateutil==2.8.2
pytz==2023.3
six==1.16.0
sqlparse==0.4.4
typing_extensions==4.7.1`

Django App is in C:\xampp\htdocs\virtual_dealer\virtual_dealer

Directory Structure:

`C:\xampp\htdocs\virtual_dealer
|--base      -> app
|--venv     -> virtual environment
|--virtual_dealer    -> python project
|--static     -> static folder for the app
|--templates  -> templates folder for the app`

Also placed MOD_WSGI_APACHE_ROOTDIR in the environment variables to be able to do a successful pip install mod_wsgi

As for the httpd.conf, here’s my setting for WSGI:

`LoadFile "C:/Users/Jaya Rathina/anaconda3/python39.dll"
LoadModule wsgi_module "C:/xampp/htdocs/virtual_dealer/venv/lib/site-packages/mod_wsgi/server/mod_wsgi.cp39-win_amd64.pyd"

WSGIScriptAlias / "C:/xampp/htdocs/virtual_dealer/virtual_dealer/wsgi.py"
WSGIPythonHome "C:/xampp/htdocs/virtual_dealer/venv"
WSGIPythonPath "C:/xampp/htdocs/virtual_dealer"

Alias /static/ C:/xampp/htdocs/virtual_dealer/static/


<Directory C:/xampp/htdocs/virtual_dealer/static/>
    Require all granted
</Directory>

<Directory "C:/xampp/htdocs/virtual_dealer/virtual_dealer">
    <Files wsgi.py>
    Require all granted
    </Files>
</Directory>`

And settings in httpd-vhosts.conf,

`<VirtualHost *:80>
    ServerName localhost
    DocumentRoot "C:/xampp/htdocs/virtual_dealer"
</VirtualHost>`

with this,I dont see any errors in apache error logs:

`[Fri Aug 04 10:15:07.734233 2023] [mpm_winnt:crit] [pid 11560:tid 420] AH02538: Child: Parent process exited abruptly. Child process is ending
[Fri Aug 04 10:15:10.969205 2023] [core:warn] [pid 5692:tid 412] AH00098: pid file C:/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Fri Aug 04 10:15:11.042668 2023] [mpm_winnt:notice] [pid 5692:tid 412] AH00455: Apache/2.4.56 (Win64) OpenSSL/1.1.1t PHP/8.2.4 mod_wsgi/4.9.4 Python/3.9 configured -- resuming normal operations
[Fri Aug 04 10:15:11.042668 2023] [mpm_winnt:notice] [pid 5692:tid 412] AH00456: Apache Lounge VS16 Server built: Mar  7 2023 13:21:03
[Fri Aug 04 10:15:11.042668 2023] [core:notice] [pid 5692:tid 412] AH00094: Command line: 'c:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache'
[Fri Aug 04 10:15:11.042668 2023] [mpm_winnt:notice] [pid 5692:tid 412] AH00418: Parent: Created child process 17688
[Fri Aug 04 10:15:12.179471 2023] [mpm_winnt:notice] [pid 17688:tid 448] AH00354: Child: Starting 150 worker threads.
`

That screen is saying that your browser can’t even connect to the apache server.

Verify that apache is up and running, listening on port 80, and that you don’t have something like Windows firewall blocking it.

Check your system event log for any indication of errors there.

There was no issue with windows firewall. When i checked line by line, i noticed that the error was with this line "WSGIScriptAlias / “C:/xampp/htdocs/virtual_dealer/virtual_dealer/wsgi.py”. When the httpd.conf was, LoadFile “C:/Users/Jaya Rathina/anaconda3/python39.dll”
LoadModule wsgi_module “C:/xampp/htdocs/virtual_dealer/venv/lib/site-packages/mod_wsgi/server/mod_wsgi.cp39-win_amd64.pyd”
I am able to connect to apache server.

And when i check the apache error logs, it says,
mod_wsgi (pid=17452): Failed to exec Python script file ‘C:/xampp/htdocs/virtual_dealer/virtual_dealer/wsgi.py’.
[Wed Aug 09 10:45:45.714318 2023] [wsgi:error] [pid 17452:tid 1932] [client ::1:58179] mod_wsgi (pid=17452): Exception occurred processing WSGI script ‘C:/xampp/htdocs/virtual_dealer/virtual_dealer/wsgi.py’.
[Wed Aug 09 10:45:45.715318 2023] [wsgi:error] [pid 17452:tid 1932] [client ::1:58179] Traceback (most recent call last):\r
[Wed Aug 09 10:45:45.716327 2023] [wsgi:error] [pid 17452:tid 1932] [client ::1:58179] File “C:/xampp/htdocs/virtual_dealer/virtual_dealer/wsgi.py”, line 15, in \r
[Wed Aug 09 10:45:45.716327 2023] [wsgi:error] [pid 17452:tid 1932] [client ::1:58179] application = get_wsgi_application()\r
[Wed Aug 09 10:45:45.717313 2023] [wsgi:error] [pid 17452:tid 1932] [client ::1:58179] File “C:\Users\Jaya Rathina\anaconda3\lib\site-packages\django\core\wsgi.py”, line 12, in get_wsgi_application\r
[Wed Aug 09 10:45:45.717313 2023] [wsgi:error] [pid 17452:tid 1932] [client ::1:58179] django.setup(set_prefix=False)\r
[Wed Aug 09 10:45:45.717313 2023] [wsgi:error] [pid 17452:tid 1932] [client ::1:58179] File “C:\Users\Jaya Rathina\anaconda3\lib\site-packages\django\init.py”, line 19, in setup\r
[Wed Aug 09 10:45:45.717313 2023] [wsgi:error] [pid 17452:tid 1932] [client ::1:58179] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)\r
[Wed Aug 09 10:45:45.717313 2023] [wsgi:error] [pid 17452:tid 1932] [client ::1:58179] File “C:\Users\Jaya Rathina\anaconda3\lib\site-packages\django\conf\init.py”, line 92, in getattr\r
[Wed Aug 09 10:45:45.717313 2023] [wsgi:error] [pid 17452:tid 1932] [client ::1:58179] self._setup(name)\r
[Wed Aug 09 10:45:45.717313 2023] [wsgi:error] [pid 17452:tid 1932] [client ::1:58179] File “C:\Users\Jaya Rathina\anaconda3\lib\site-packages\django\conf\init.py”, line 79, in _setup\r
[Wed Aug 09 10:45:45.717313 2023] [wsgi:error] [pid 17452:tid 1932] [client ::1:58179] self._wrapped = Settings(settings_module)\r
[Wed Aug 09 10:45:45.717313 2023] [wsgi:error] [pid 17452:tid 1932] [client ::1:58179] File “C:\Users\Jaya Rathina\anaconda3\lib\site-packages\django\conf\init.py”, line 190, in init\r
[Wed Aug 09 10:45:45.717313 2023] [wsgi:error] [pid 17452:tid 1932] [client ::1:58179] mod = importlib.import_module(self.SETTINGS_MODULE)\r
[Wed Aug 09 10:45:45.718315 2023] [wsgi:error] [pid 17452:tid 1932] [client ::1:58179] File “C:\Users\Jaya Rathina\anaconda3\Lib\importlib\init.py”, line 127, in import_module\r
[Wed Aug 09 10:45:45.718315 2023] [wsgi:error] [pid 17452:tid 1932] [client ::1:58179] return _bootstrap._gcd_import(name[level:], package, level)\r
[Wed Aug 09 10:45:45.718315 2023] [wsgi:error] [pid 17452:tid 1932] [client ::1:58179] File “”, line 1030, in _gcd_import\r
[Wed Aug 09 10:45:45.718315 2023] [wsgi:error] [pid 17452:tid 1932] [client ::1:58179] File “”, line 1007, in _find_and_load\r
[Wed Aug 09 10:45:45.718315 2023] [wsgi:error] [pid 17452:tid 1932] [client ::1:58179] File “”, line 972, in _find_and_load_unlocked\r
[Wed Aug 09 10:45:45.718315 2023] [wsgi:error] [pid 17452:tid 1932] [client ::1:58179] File “”, line 228, in _call_with_frames_removed\r
[Wed Aug 09 10:45:45.718315 2023] [wsgi:error] [pid 17452:tid 1932] [client ::1:58179] File “”, line 1030, in _gcd_import\r
[Wed Aug 09 10:45:45.718315 2023] [wsgi:error] [pid 17452:tid 1932] [client ::1:58179] File “”, line 1007, in _find_and_load\r
[Wed Aug 09 10:45:45.718315 2023] [wsgi:error] [pid 17452:tid 1932] [client ::1:58179] File “”, line 984, in _find_and_load_unlocked\r
[Wed Aug 09 10:45:45.718315 2023] [wsgi:error] [pid 17452:tid 1932] [client ::1:58179] ModuleNotFoundError: No module named ‘virtual_dealer’\r