Here are the steps I took for configuring Django on Freebsd using uWSGI and Nginx.
The data flow is like this:
Web Request ---> Nginx ---> uWSGI ---> Django
I was undecided for a while on whether to choose uWSGI or gunicorn. There are some blog posts discussing the pros and cons of each. I chose uWSGI in the end.
Also, to start uWSGI in freebsd, I found two methods: using supervisord, or using a custom freebsd init script which could use uWSGI ini files. Currently using supervisord.
Install Packages Required
Also install any database package(s) required.
Setup your Django project
Choose a folder for setting up your Django project sources.
/usr/local/www/myapp is suggested. Clone the sources to this folder, then setup the python virtual environment.
If required, also setup the database and run the migrations.
Setup uWSGI using supervisord
Setup the supervisord file at
And start it:
Use the following line in
nginx.conf's http section to include all config files from
And start Nginx:
Accessing http://myapp.example.com/ should work correctly after this. If not, see the supervisord and Nginx logs opened and correct the errors.