I have been trying forever to get my django api to deploy correctly via
apache on my new ec2 instance running amazon linux 2. I have installed
python3-mod_wsgi.x86_64 and my venv is using python 3.7.15. Trying to go to
my django app url I am getting a 500 error. The server runs fine locally.
I have imported python3-mod_wsgi.x86_64 in my httpd.conf file via:
LoadModule wsgi_module /etc/httpd/modules/python3-mod_wsgi.x86_64.so
I am pretty new to this set up, happy to provide any additional info needed.
Error log shows:
[Tue Dec 20 21:31:30.690951 2022] [:error] [pid 19216] /usr
[Tue Dec 20 21:31:30.691287 2022] [:error] [pid 19216] mod_wsgi
(pid=19216): Target WSGI script '.../project/project/wsgi.py' cannot be
loaded as Python module.
[Tue Dec 20 21:31:30.691323 2022] [:error] [pid 19216] mod_wsgi
(pid=19216): Exception occurred processing WSGI script
'.../project/project/wsgi.py'.
[Tue Dec 20 21:31:30.691393 2022] [:error] [pid 19216] Traceback (most
recent call last):
[Tue Dec 20 21:31:30.691423 2022] [:error] [pid 19216] File
".../project/project/wsgi.py", line 19, in <module>
[Tue Dec 20 21:31:30.691428 2022] [:error] [pid 19216] from
django.core.wsgi import get_wsgi_application
[Tue Dec 20 21:31:30.691444 2022] [:error] [pid 19216] ModuleNotFoundError:
No module named 'django'
[Tue Dec 20 21:31:51.190670 2022] [:error] [pid 19217] 3.7.15 (default, Oct
31 2022, 22:44:31) [Tue Dec 20 21:31:51.190707 2022] [:error] [pid 19217]
[GCC 7.3.1 20180712 (Red Hat 7.3.1-15)]
My apache conf file:
<VirtualHost *:80>
ServerName api.project.com
DocumentRoot path/to/project/root
WSGIScriptAlias / /path/to/wsgi.py WSGIDaemonProcess project-name
processes=4 threads=1 display-name=%{GROUP}
python-path=path/to/lib/python3.7/site-packages:/path/to/project/root
WSGIProcessGroup project-group
<Directory "/path/to/project/root">
Require all granted
</Directory>
#SSL stuff...
</VirtualHost>
my wsgi.py file:
[image: Screenshot 2022-12-29 at 11.20.06 AM.png]
I think I originally had the wrong mod_wsgi installed (built for python2).
I removed that and installed python3-mod_wsgi.x86_64.
I then realized that my mod_wsgi was for python version 3.7, but my
application venv was running python 3.6.8. I then wiped the venv and
created a new one with python 3.7.15. Changed the conf path to the correct
3.7 site-packages (my venv). Still same error
Would appreciate any help with this, and again, happy to provide more info
if needed.
--
You received this message because you are subscribed to the Google Groups
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/modwsgi/d6358f22-e749-4f55-a9e6-6bf5310076d7n%40googlegroups.com.