I am in the process of deploying a Django site and from my understanding and research, I needed to get a web server, a WSGI protocol interface to actually run said python code and 'communicate' with it, and lastly a reverse proxy server to tie the two together and pass HTTP requests through the pipeline to Django. (By virtue of my install method, mod_wsgi
is not an option thanks to EasyApache4 and cPanel so I cannot use the mod_wsgi
sockets method)
I have organized an apache 2 hosting server and managed to install mod_proxy
and mod_proxy_uWSGI
using the EasyApache4 auto installer. From what I understand, now I need to set up the proxy system to relay HTTP requests through mod_proxy_uWSGI
which doubles up and also runs my Django site, however, I cannot access or configure mod_proxy_uWSGI
. When I try using the following style command (sorry, I don't want my server URLs floating around the internet):
uwsgi --http :8000 --wsgi-file test.py
I get an error message:
bash: uwsgi: command not found
Am I missing something?
The uwsgi binary is placed in /usr/bin/uwsgi when installing uwsgi this way. Alternatively: edit the uwsgi init script and edit the DAEMON="/usr/bin/uwsgi" appropriately.
Can I then ditch NGINX? uWSGI could be used as a standalone web server in production, but that is not it's intentional use. It may sound odd, but uWSGI was always supposed to be a go-between a full-featured web server like NGINX and your Python files.
uWSGI is an application server that aims to provide a full stack for developing and deploying web applications and services. Like most application servers, it is language-agnostic but its most popular use is for serving Python applications.
Thanks to a comment by [@dirkgroten]. To install UWSGI :
pip install uwsgi
After running pip install uwsgi
, it's possible that uwsgi
was installed someplace not on your PATH
. IE, in my case, it got installed to:
/usr/local/opt/python-3.8.6/bin/uwsgi
I was able to fix this by adding a symlink:
sudo ln -s /usr/local/opt/python-3.8.6/bin/uwsgi /usr/bin/uwsgi
(This may be a terrible idea. It may be a much better idea to use a venv
, but I'm following a tutorial that specifically told me to avoid using a venv
.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With