Apache WSGI module Fails to Start with net start apache2.4, but Works with httpd.exe
I’m currently facing an issue with my Apache server setup on Windows. I’ve been able to run Apache successfully using httpd.exe, but when I attempt to start it using net start apache2.4
, the service fails to start, and I receive an error in the Event Viewer (no corresponding Apache error log though)
System Details
- Apache Version: Apache 2.4 (64-bit)
- Python Version: Python 3.13
- mod_wsgi Version: 5.0.1 (64-bit)
- Django App Path: C:/webapp
- WSGI Module Path: C:/Users/{me}/AppData/Local/Programs/Python/Python313/Lib/site-packages/mod_wsgi/server/mod_wsgi.cp313-win_amd64.pyd
What I’ve Tried
1. Running httpd.exe Directly:
- Apache starts successfully and serves my Django application as expected.
- No issues with the Django app or the WSGI module when starting manually.
**2. Running httpd -t
**
- Returns
Syntax OK
.
3. Windows Event Viewer Error:
- When starting Apache with net start apache2.4, I see the following error in the Event Viewer:
The Apache service named reported the following error:
>>> httpd.exe: Syntax error on line 194 of C:/Apache24/conf/httpd.conf:
Cannot load C:/Users/{me}/AppData/Local/Programs/Python/Python313/Lib/site-packages/mod_wsgi/server/mod_wsgi.cp313-win_amd64.pyd
into server: The specified module could not be found. .
4. Verified File Paths:
- I have confirmed that the mod_wsgi file exists in the exact location specified in the httpd.conf file:
c:\Apache24\bin>dir "C:\Users\{me}\AppData\Local\Programs\Python\Python313\Lib\site-packages\mod_wsgi\server"
Volume in drive C is Windows
Volume Serial Number is 8205-BA06
Directory of C:\Users\{me}\AppData\Local\Programs\Python\Python313\Lib\site-packages\mod_wsgi\server
10/23/2024 02:49 PM <DIR> .
10/23/2024 02:49 PM <DIR> ..
10/23/2024 02:49 PM 1,097 apxs_config.py
10/23/2024 02:49 PM 3,563 environ.py
10/23/2024 02:49 PM <DIR> management
10/23/2024 02:49 PM 134,656 mod_wsgi.cp313-win_amd64.pyd
10/23/2024 02:49 PM 138,014 __init__.py
10/23/2024 02:49 PM <DIR> __pycache__
4 File(s) 277,330 bytes
4 Dir(s) 56,747,614,208 bytes free
What’s Confusing
- Apache runs fine using
httpd.exe
, but it fails when usingnet start apache2.4
. - No error is being logged in the Apache logs (either the error log or the access log).
- The mod_wsgi module seems to load without issue when running manually, but not as a service.
Configuration
- httpd.conf (mod_wsgi load):
LoadModule wsgi_module "C:/Users/{me}/AppData/Local/Programs/Python/Python313/Lib/site-packages/mod_wsgi/server/mod_wsgi.cp313-win_amd64.pyd"
WSGIPythonHome "C:/Users/{me}/AppData/Local/Programs/Python/Python313"
WSGIPythonPath "C:/{my_webapp}"
- VirtualHost configuration:
<VirtualHost *:80>
ServerName .com
ServerAlias www.{my_webapp}.com
DocumentRoot "C:/{my_webapp}"
WSGIScriptAlias / C:/{my_webapp}/{my_webapp}/wsgi.py
WSGIApplicationGroup %{GLOBAL}
LogLevel info wsgi:debug
<Directory C:/{my_webapp}/{my_webapp}>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /static/ C:/{my_webapp}/static/
<Directory C:/{my_webapp}/static>
Require all granted
</Directory>
ErrorLog "C:/Apache24/logs/{my_webapp}_error.log"
CustomLog "C:/Apache24/logs/{my_webapp}_access.log" common
</VirtualHost>
Steps Taken So Far
- Verified that Apache and mod_wsgi are both 64-bit.
- Confirmed that the paths to Python and mod_wsgi are correct.
- Ran httpd.exe successfully, confirming the setup works manually. Checked Windows Event Viewer for errors but didn’t see any additional details logged in the Apache error log.
My Question
Why is Apache able to run via httpd.exe but fails when using net start apache2.4? How can I troubleshoot this further, especially considering the lack of logs in Apache?
Relevant Posts
- mod_wsgi not found for apache/windows
- https://serverfault.com/questions/1070563/why-is-apache2-not-finding-my-wsgi-app
- https://groups.google.com/g/modwsgi/c/RVD1hIxb2eI
Any help or suggestions would be greatly appreciated! Thanks in advance.
per the last link in the relevant posts.
run mod_wsgi-express module-config
replace what i had in my httpd.conf to load with the output:
LoadFile "C:/Users/{me}/AppData/Local/Programs/Python/Python313/python313.dll"
LoadModule wsgi_module "C:/Users/{me}/AppData/Local/Programs/Python/Python313/Lib/site-packages/mod_wsgi/server/mod_wsgi.cp313-win_amd64.pyd"
WSGIPythonHome "C:/Users/{me}/AppData/Local/Programs/Python/Python313"