Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@davidcorbin
Created April 6, 2016 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidcorbin/2054eec06959ad0f10117dcfbb23ec3f to your computer and use it in GitHub Desktop.
Save davidcorbin/2054eec06959ad0f10117dcfbb23ec3f to your computer and use it in GitHub Desktop.
Install and test django web server
#!/bin/bash
red='\e[0;31m'
NC='\e[0m'
#Check for root privledges
if [ "$UID" -ne 0 ]
then echo -e "${red}Root privledges required. Type 'su', type enter, then input your password.${NC}"
exit
fi
#Check if screen is installed
if ! type "screen" > /dev/null;
then apt-get update
apt-get install screen
echo "screen Successfully Installed"
else
echo "screen Already Installed"
fi
#Check if pip is already installed
if ! type "pip" > /dev/null;
then wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate
python get-pip.py
echo "pip Successfully Installed"
else
echo "pip Already Installed"
fi
#Install django, virtualenv, ex-setup, setuptools
pip install django virtualenv ez-setup setuptools
echo "Django Installed Along With Other Important Packages"
if [ -d "mysite2" ];
then echo -e "${red}For the django tutorial, you will need to have a folder named 'mysite' which is already taken in this directory.${NC}"
exit
else
#Start a Django project
django-admin.py startproject mysite2
echo "New Django Project Started"
fi
cd mysite
screen -d -S django -m python manage.py runserver
echo "The server is starting in a screen named 'django'. If you want to see the site, open Safari and go to 127.0.0.1:8000."
echo "Thanks for reading my tutorial! "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment