Complete guide on django installation
3 min read
Setting up Django with all required softwares can be a pain in the ass if you read offical documents. You could easily get lost by seemly endless documents related to software like apache, wsgi, etc.
Based on experiences by Ayman Farhat and PDX pixel , this article will pave a clear road for you at the marching journey to django.
I'm using ubuntu 12.04 with python 2.7.
1. Updating the repository
2. Personally, I prefer to use vim to write codes, so:
3. Then, you need to install pip, a tool for installing and managing python packages, (please read the quickstart if you'd like to, https://pypi.python.org/pypi/pip/)
update pip for better performance:
4. Install database
Install virtualenv to bypass conflicts among different version
5. Create a virtual environment to work with:
6. Install Django:
7. Create a django project in virtual enviroment
8. The next big step is set up database
Edit setting.py file so that database are linked
9. Run the belowing command (order is highly important)
10. synchronise what you created earlier:
Now, let's install and configure Apache and mod_wsgi:
This should automatically restart Apache but just to be sure, issue this command:
We need to now create a virtual host and set up WSGI. First, let's create the site in the Apache configuration:
There are many different ways to set up the WSGI part, but personally I highly recommend Django docs on this part.
In it, add these lines (Django sets some deefault values, so consider this carefully):
Let's then set where static files go for Django:
Make sure these lines are set:
Next, we need to tell Django to collect the static files for use on the site:
Restart Apache again and you should be good to go: