Skip to main content

Part 1- Install Django using Virtualenv, Apache and MySQL on Ubuntu Server 14.10


Introduction

I have been using Microsoft Excel to do my Personal Budget. Excel is extremely powerful and has fulfilled my needs. But I always wanted to build a web application which is accessible via a browser and in order to do so we need the following:

  • An admin interface (website) to plug in my expenses
  • A database to store all the entries
  • Code to parse the database and calculate the expenses per month
  • A public interface (website) to display expense charts

After browsing the web I stumbled across Django. Django (as copied from the project page) is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. It focuses on automating as much as possible and adhering to the DRY principle.

In the first part of this tutorial we will walk through the installation of Django using Virtualenv. In the following series we will build our Personal Budget application using Django.

What is virtualenv and why use it?

Virtualenv (as copied from the project page) is a tool to create isolated Python environments. By creating an isolated environment, we can install, develop and test specific versions of software or code. It creates an environment that has its own installation directories, that doesn’t share libraries with other virtualenv environments

Objective

In this tutorial we will

  • Install and configure virtualenv
  • Install Django 1.7.1 on Ubuntu Server 14.10 using virtualenv
  • Test our installation using the built-in Django web server

Assumptions

  • Fresh Install of Ubuntu Server 14.10
  • SSH enabled (sudo apt-get install ssh-server)
  • User has root privileges
  • Basic familiarity with using the Linux command line (terminal)

Installation

Step 1 - Get root access and update repository

sudo su
apt-get update

Step 2 - Install PIP and Virtualenv

apt-get install python-pip python-virtualenv vim -y

STEP 3: Install mysql server - Will be prompted for mysql root password

apt-get install mysql-server libmysqlclient-dev python-dev build-essential -y

STEP 4: Install apache2

apt-get install apache2 libapache2-mod-wsgi -y

STEP 5: Configure database. Will be prompted for password

mysql -u root -p
Enter password:
mysql> create database django;
mysql> GRANT ALL ON django.* TO django@'%' IDENTIFIED BY 'django';
mysql> quit

STEP 6: Create a virtual environment and activate it

cd /var/www/html
virtualenv projects
cd projects/
. bin/activate

STEP 7: Install Django and mysql lib

pip install django
pip install mysql-python

STEP 8: Create a django project

django-admin startproject webapps
cd webapps
python -c "import django; print(django.get_version())"

Your output should say 1.7.1

STEP 9: Start the built-in web server

python manage.py runserver 0.0.0.0:8000

STEP 10: Navigate to the web browser and check your installation

Conclusion

Congratulation!! You have successfully installed Django 1.7.1. In part 2 of this tutorial we will cover how to configure Django with Apache and MySQL

References

Comments

  1. Sands Casino Online - New Vegas Online Casino
    Play 샌즈카지노 for free クイーンカジノ and win real money at Sands Casino Online in New Jersey! The only place to play online casino games for real money in NJ! 1xbet

    ReplyDelete
  2. 1XBet
    Betting in India. It can be great to find the most popular brands, especially ones that offer betting novcasino on sports herzamanindir.com/ such as football, หาเงินออนไลน์ tennis,  Rating: 1/10 https://deccasino.com/review/merit-casino/ · 1xbet korean ‎Review by Riku VihreasaariWhere can I find 1xbet?Where can I find 1xbet betting?

    ReplyDelete

Post a Comment

Popular posts from this blog

Run your Meteor App on a Production Ubuntu 16.04 Server with Nginx

Introduction Meteor enables developers to create apps and quickly test them on a development webserver. Once you have created your app the big question is how to run it on a production server. In this tutorial we will demostrate how to run your Meteor app on Ubuntu 16.04 using Nginx Credits and Acknowledgements This entire post is based off this Digital Ocean article. The article was modified for issues we encountered and adapted for Ubuntu 16.04. The entire credit goes to Daniel Speichert Objective In this tutorial we will: Install and Configure Nginx with HTTPS enabled Install MongoDB Install NodeJS Bundle your Meteor App Create a startup script to automatically start your app on reboot Assumptions We assumue the following: You already have a fresh install of Ubuntu 16.04 Server SSH enabled on your fresh install You have root privelages on your server You have a different server where you can insall meteor and budle your app

Traefik Install and configuration - Part 1

Introduction In this tutorial we are going to install and configure Traefik Proxy . As quoted on their website "Traefik is a leading modern reverse proxy and load balancer that makes deploying microservices easy. Traefik integrates with your existing infrastructure components and configures itself automatically and dynamically." All our applications will be front-ended by traefik. Objective The core objective for this tutorial is to: Configure an A record in our DNS server (pfsesne firewall) to point to our traefik proxy Configure and install Traefik in docker Configure and install two http based applications ( homer and heimdall ) in docker that will be accessed via traefik Topology The above image represents our topology. Our pfsense firewall is connected directly to the Internet and is NAT'ing all traffic from the internal network to the outside world. We have a single LAN segment (192.168.11.0/24) defined on pfsense and we have the following two PC's connected d