Install Django Development Environment on CentOS/RedHat/Fedora

Exported on 11-Oct-2021 12:23:23

Install Django Development Environment On RHEL Based Server With AttuneOps

This Blueprint Installs Django Development Environment On RHEL Based Server

Django is a Python-based open-source and free web framework that follows the model–template–views architectural pattern. It is maintained by an American independent, Django Software Foundation.

Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of web development, so you can focus on writing your app without needing to reinvent the wheel.

Pre-Blueprint Attune setup
  1. On the Inputs tab, create a Linux node for the host you wish to install the stack on.
  2. On the Inputs tab, create Linux credentials to connect to the host you wish to install the stack on.
Steps Involved
  • Install yum repository.
  • Install Python version 3 and pip 3.
  • Setup Virtual Environment.
  • Install SQLite Database.
  • Install dependencies and launch development server.
Supported Operating Systems
  • CentOS
  • Fedora
  • Red Hat

Parameters

Name Type Script Reference Default Value Comment
Linux Node Linux / Unix Server linuxNode
Linux User Linux OS Credential linuxUser
s1 Linux / Unix Server s1
s1c Linux OS Credential s1c

1 - Update Yum Repositories

Update yum repositories.

The connection details have changed from the last step.

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
# Install yum
sudo yum -y update

2 - Install Python version 3 and Pip3

Installs Python3 and Pip3.

The connection details have changed from the last step.

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
# Install python3
sudo yum install -y python3 python3-pip

3 - Setup VirtualEnv

Installs and configures virtualenv.

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
# Install virtualenv
sudo pip3 install virtualenv

4 - Create Virtual Environment

Creates a virtual environment for the Django application.

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
# Create django applications
mkdir django-apps
cd django-apps
virtualenv env

5 - Install Django Package

Install Django pip package.

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
# Install Django
sudo pip3 install django

6 - Install SQLite3

Install SQLite database version 3.

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
# Download SQLite latest version
curl https://www.sqlite.org/2019/sqlite-autoconf-3280000.tar.gz -o sqlite-autoconf-3280000.tar.gz


# Unzip SQLite
tar -xzf sqlite-autoconf-3280000.tar.gz

# Install GCC
sudo yum -y install gcc

# Change directory to sqlite
cd sqlite-autoconf-3280000


# Install sqlite
./configure
make
sudo make install

7 - Start Django Development Server

Creates Django project and starts up a Django development server.

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
#Update Python's SQLite version
echo 'export LD_LIBRARY_PATH="/usr/local/lib"' >> ~/.bashrc
source  ~/.bashrc

# Create Django project
django-admin startproject mysite

# Start development server
cd mysite
python3 manage.py migrate
python3 manage.py runserver