I am using a MS Windows 11 Machine running Python 3.11 with virtualenv
package installed.
I am using Apache24
httpd.exe
web server for my django
app production server.
My app is called mysite
and it is fully functional inside a virtual environment (called venv
) with the folowing packages (requirements.txt):
django
django-extensions
django-iprestrict
mod-wsgi
Pillow
pyOpenSSL
odfpy
werkzeug
whitenoise
pandas
plotly
matplotlib
I can fully run the server in DEBUG mode with the virtual environment activated:
(venv) python.exe manage.py runserver
And, on the other hand, I was able to make the Apache
web server to run a test website without problems.
The issue is when I edit httpd.conf
files to integrate with my django app thorugh mod_wsgi
:
# httpd.conf
(...)
LoadFile "C:/Users/myuser/AppData/Local/Programs/Python/Python311/python311.dll"
LoadModule "C:/Users/myuser/mysite/mysite_venv/venv/Lib/site-packages/mod_wsgi.cp311-win_amd64.pyd"
WSGIScriptAlias / C:\Users\myuser\mysite\mysite\wsgi.py
WSGIPythonHome C:\Users\myuser\mysite\mysite_venv\venv
WSGIPythonPath C:\Users\myuser\mysite
<Directory />
<Files wsgi.py>
Require all granted
</Files>
</Directory>
# media files hosting
Alias /media "C:/Users/myuser/mysite/media/"
<Directory "C:/Users/myuser/mysite/media/">
Require all granted
</Directory>
(...)
My directory tree is:
.
├── mainapp
│ ├── admin.py
│ ├── apps.py
│ ├── forms.py
│ ├── __init__.py
│ ├── migrations
│ ├── models.py
│ ├── static
│ ├── templates
│ ├── tests.py
│ ├── urls.py
│ └── views.py
├── mainapp.sqlite3
├── manage.py
├── media
├── mysite
│ ├── asgi.py
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
├── mysite_venv
│ ├── requirements.txt
│ ├── venv
└── staticfiles
├── admin
├── css
├── django_extensions
├── font
├── icon
├── javascript
├── js
└── uploads
The issue is when I run httpd.exe
the web page loads forever because the server does not respond the client.
I have opened the error.txt
log file from Apache
to find out what is going on, but there was any error message about anything.
I took care about:
PYTHONPATH
environment variable to the DLLs as described heremod_wsgi
.pyd
in the correct path.Can someone help me what is going on? Thanks in advance!
I did just run into a similar issue using Python 11 and Apache 2.4.
The reason why you don't see any error in the log is simply the fact that the Apache httpd.exe does not start at all. If you try to run the httpd.exe from the console you will propably see the error displayed.
In my case the I got:
httpd.exe: Syntax error on line 192 of C:/Apache24/conf/httpd.conf: Cannot load c:/python311/python311.dll into server: %1 is no Win32-application.
The reason at the end was: By chance I did download a 32 bit distribution of Apache but using the 64bit Version of Python 3.11 .
Downloading and installing the 64 bit Apache24 Version did solve my issue.
Make sure that you use the same: 32bit or 64bit for Apache 2.4 and Python 3.11.