Deploying django by python manage.py runserver to production on VPS

django, django-deployment, python

Solution

It is easy to learn how to deploy a Django project.

At first, you should know how to install `Apache` and `mod_wsgi`

if you use `Ubuntu`

sudo apt-get install apache2 libapache2-mod-wsgi

or `Fedora` (red hat) (without test)

yum install httpd mod_wsgi

Then, you should know how to associate Apache2 with your Django project

<VirtualHost *:80>
    ServerName example.com
    ServerAdmin example@example.com

    Alias /media/ /home/tu/blog/media/

    <Directory /home/tu/blog/media>
        Require all granted
    </Directory>

    WSGIScriptAlias / /home/tu/blog/blog/wsgi.py

    <Directory /path/to/django/project/wsgifile>
    <Files wsgi.py>
        Require all granted
    </Files>
    </Directory>
</VirtualHost>

The sentence `WSGIScriptAlias` associate Apache2 configuration with your Django project in Django `wsgi.py` file, you will see `project.settings` included, that is how it works

The following may be easy to understand how it works

*.conf --> wsgi.py --> settings.py --> urls.py and apps

just search in Google like `ubuntu django server mod_wsgi` and learn it yourself!

Problem

I've bought a VPS for my django app. I've never ever before deployed django, or any other application. I've read a few tutorials on how to deploy django using apache and wsgi and some other options gunicorn, ngix. To me it all seems very frustrating and hard to understand. I was wondering what would happen if I deployed my application by changing debug to false, creating a database, plugging it in and then simply running python manage.py runserver my-ip. Is this a bad practice ?

Original source