Apache and nginx are called "web servers". Windows and FreeBSD are called
"operating systems". What is the term for Gunicorn, uWSGI and mod_wsgi? I
believe there's no good term, which is one reason for the confusion.
Gunicorn, uWSGI and mod_wsgi are specialized web servers that run Python
WSGI-compliant applications. For lack of a better name, I'll call them Python
application servers, but don't forget that they are nothing more (and nothing
less) than specialized web servers that run Python WSGI-compliant applications.
What the Python application server does is
from djpro.wsgi import application
and then, in each HTTP request, it calls application() in a standard way that is
specified by the WSGI specification. The fact that the interface of this
function is standardized is what permits you to choose between many different
Python application servers such as Gunicorn, uWSGI, or mod_wsgi, and why each of
these can interact with many Python application frameworks like Django or Flask.
The Python application server does not *communicate* with the Django project, it
*imports* the Django project. From the point of view of the operating system, it
is the same process. You don't have a separate server which "runs" or
"communicates with" Django, which would mean that the Python application server
and Django could run in separate virtualenvs. You have a single Python program
and there is only one virtualenv. What we do for Gunicorn, for example, is
install it in the same virtualenv where we have Django (pip install gunicorn),
and then run it from there.
I am not familiar with mod_wsgi, but the thing is, by the time it's ready to
import the Django project, Python is already running, and you can't select or
change a virtualenv any more. So selecting a virtualenv (which I assume is
possible) must be in the mod_wsgi configuration. I hope these principles help
you understand mod_wsgi's documentation.
I find Gunicorn an easier and better way to deploy, regardless the web server.
More information:
* How to setup Apache with Gunicorn
<https://djangodeployment.com/2016/11/30/how-to-setup-apache-with-gunicorn/>
* Detailed instructions on setting up Gunicorn
<https://djangodeployment.readthedocs.io/en/latest/06-gunicorn.html>
Antonis Christofides
+30-6979924665 (mobile)
On 30/05/2021 09.29, Moose Smith wrote:
App written in ubuntu virtual environment python 3.8.5. Works well on Visual
Studio Code development server. Am trying to make it run on Apache2
development server. I have been able to install WSGI module on Apache Server
and ran a test Hello World in Python and it worked. However, the django app
when ported over does not work.
The error log confirms that the mod_wsgi has been created using by Python 3.8
[mpm_event:notice] [pid 607786:tid 140700034231360] AH00489: Apache/2.4.41
(Ubuntu) mod_wsgi/4.6.8 Python/3.8 configured -- resuming normal operations
The error I am getting indicates that the Apache / WSGI is reading the files
in the virtual environment I copied over.
mod_wsgi (pid=609049): Exception occurred processing WSGI script '/ File
"/usr/public/apache/MCE/learn/djpro/wsgi.py", line 12, in <module>
from django.core.wsgi import get_wsgi_application
ModuleNotFoundError: No module named 'django'
My research indicates that this error occurs when the mod--wsgi in being
interpreted by a different version than what was used to create my virtual
environment. It also might be permissions/ownership issues with the file and
directories copied over to the server, or improperly configured module.
My question is this: Does the mod_WSGI module have to be the same as the one
that created my virtual environment? My understanding is that WSGI has two
components, the server side, and the application side. It would not make sense
that the Server side MUST match the application side because it would not be
possible to service various apps with different versions of Python/Django. I
assumed the server side was python version independent and that the
requirement for Python similarity was only on the application side in that the
Python used to create the virtual environment and my app must match the
version used to create the WSGI interface on the application side (this side
not the server). That said, I have discovered there is a Python 2.7 version of
the mod_WSGI for the server side which differs from the 3.7 version.
Can someone clear up the Python version requirement and if it does require a
match between the server and the app side, how will I be able to run future
versions of Python/Django apps without having to go back and "recomplie"?
Also if someone has any clues on solving my error that would be very much
appreciated.
Thanks
Moose
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to django-users+unsubscr...@googlegroups.com
<mailto:django-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/d3041741-1604-473f-8810-263bb3b16c59n%40googlegroups.com
<https://groups.google.com/d/msgid/django-users/d3041741-1604-473f-8810-263bb3b16c59n%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/4fa5acf0-ef5b-43d6-ba46-7b696eda5ccb%40antonischristofides.com.