Apache always throws 500 internal server error without logs or terminal feedback
Solution 1:
There is a nice serve django with apache tutorial. It is old yet it should still be well applicable to your situation.
From your config file, your problem seems to be in one of these two lines:
LoadModule wsgi_module "/home/server/.local/lib/python3.8/site-packages/mod_wsgi/server/mod_wsgi-py38.cpython-38-x86_64-linux-gnu.so"
WSGIDaemonProcess 127.0.1.1 python-path=/var/www/mysite python-home=/usr
You might be using the wrong module or wrong paths. I don't know about the module, but you can check for paths, specifically for the one to use with python-home
.
First check to see you have django installed globally: python -m django --version
. (use python3 if you have both v2 and v3)
If it is in the global, then check Find where python is installed (if it isn't default dir) to see where your python is installed and use that path.
If you get an error that it is not installed, you are probably using a virtual environment for your project. Then use that path instead. Different virtual environment programs exist, so you need to check their docs to find the path you need. For example, it might be under /var/www/mysite/venv
. then it will be:
WSGIDaemonProcess 127.0.1.1 python-path=/var/www/mysite python-home=/var/www/mysite/venv
Warning:
Some virtual environments cannot be moved. For example, if your project was under "/home/user/webproject", you used "python -m venv venv" in it, and tried copying the folder under apache, this path for the virtual environment won't work. In such a case, you will need pip freeze
procedure.
I could see what was nagging me with your Loadmodule
line.
First, it shows you have your local python installation in /home/server/.local/lib/python3.8/
so you can use this as your python-home
but I don't recommend using a location under the user folder.
Then, use /usr/sbin/httpd -M
to see if apache ever starts and loads the module. It is possible you haven't set it to read user directories or not from that location. It might also simply be a matter of quotes, remove quotes.
In short, you worked on your project in private but apache will serve the public. Make sure you use a separate installation in another folder apache reads/writes freely without compromising users.