After the Django installation and running smoothly on standalone mode, one of the steps to move it into production is to deploy Django with mod_wsgi on Apache.
As I have described in the previous article of setting up mysqlclient module for use by Django, there were some issues in moving deploying Django with mod_wsgi on Apache. I faced the same issue that the mysqlclient module was not found. My original WSGIDaemonProcess setting is as below:
WSGIDaemonProcess example python-path=/opt/python/example:/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages
Upon further investigation, I found that the mysqlclient packages were installed in lib64 path of the python installation. So i proceeded to add the path “/opt/rh/rh-python36/root/usr/lib64/python3.6/site-packages to the python-path variable as below:
WSGIDaemonProcess example python-path=/opt/python/example:/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages
:/opt/rh/rh-python36/root/usr/lib64/python3.6/site-packages
It works for me, and while I was writing this article, I reviewed the documentation and noticed the “python-home” parameter and another fix is possible:
WSGIDaemonProcess example python-path=/opt/python/example python-home=/opt/rh/rh-python36/root
I think this is a neater fix, and should have read the documentation more thoroughly.