How to use Django on nginx+uwsgi
I'm currently planning to move a company website to django.
My background is primarily in PHP+MySQL although I've also written a couple thousand lines of code in python for offline apps. I'm not new to the linux shell either, but I am new to nginx and django.
I've deployed debian 5 and followed Python using uWSGI and nginx on Debian 5
nginx is up and running (uploaded some static content to test it).
Since I'm new to django, I just started the tutorial
In the django tutorial, one of the first steps is starting the development server. I can do that on the server, but then i can't access the app.
What do i have to do to access the django app I'm creating with nginx instead of the django development server? There's just something I'm really not getting…
7 Replies
Otherwise, you have bind it to the right ip and port. By default it only listens on 127.0.0.1 and uses port 8000. One or more of these may apply: 1) can't access 127.0.0.1 from your webbrowser, 2) you're not trying to access it using port 8000, or 3) firewall is blocking that port.
Oh, and I should repeat: do your dev work locally.
@sirpengi:
The django development server is for local development. I'd suggest you do your dev work locally.
That is correct, and I will do the development of the site locally, but i really wanted to check out how to move something i created locally to the server and be able to access it. Starting the django development server was more of a desperate try than anything else.
Keeping code in sync with your server is now basically tracking your repository.
If you use the right command line arguments with the dev server, you should be able to get access to it from the outside world. But I'd seriously suggest you consider reading about Django deployment (
If you're new to django, follow that tutorial you're using, and read the djangobook. It only took me a couple days to get down and dirty with django when I first started out.
@sirpengi:
By default it only listens on 127.0.0.1 and uses port 8000. One or more of these may apply: 1) can't access 127.0.0.1 from your webbrowser, 2) you're not trying to access it using port 8000, or 3) firewall is blocking that port.
I've used
python manage.py runserver 0.0.0.0:8000
to start the dev server, and tried accessing it using port 8000, but it won't do.
The dev server is really not what i actually want to use, so i need to figure ou how to use nginx to access the app.
@sirpengi: would you recommend just using apache with mod_wsgi?
However, I'm also pretty fluent with my server distro and I can troubleshoot/fix issues/keep up to date with patches when they arise.
If you're not certain about what you're doing, or you're new to the server admin game, apache+modwsgi is probably your best bet because there are more resources out there. Also, the people that work on django recommend apache+modwsgi. It's time-tested and proven. Nginx+uwsgi is cutting edge stuff, so you might bleed a little.
Thanks!