Hello Linux

This tutorial series is all about deploying a Python web application on Ubuntu 18.04 LTS.
Alternatives To Hello Linux
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Fprime9,52918 days ago21August 03, 2023207apache-2.0C++
F' - A flight software and embedded systems framework
Examples5,719
a month ago3February 21, 202110apache-2.0Shell
Kubernetes application example tutorials
React Gh Pages5,472
a month ago27TypeScript
Deploying a React App (created using create-react-app) to GitHub Pages
K8s Tutorials3,313
a month ago1mitGo
k8s tutorials | k8s 教程
Pipeline732
5 years ago7
A step by step guide on creating build and deployment pipelines for Kubernetes.
Phoenix Chat Example696
2 days agoElixir
💬 The Step-by-Step Beginners Tutorial for Building, Testing & Deploying a Chat app in Phoenix 1.7 [Latest] 🚀
Pathfinding Visualizer Tutorial537
7 months ago16JavaScript
Tutorial for my original Pathfinding Visualizer project.
Package493514 years ago5March 25, 201830mitGo
Metaparticle/Package: Language Fluent Containerization and Deployment in Java, .NET and Javascript (and more coming soon)
Aem Guides Wknd247124 days ago8November 15, 202238mitJavaScript
Tutorial Code companion for Getting Started Developing with AEM Sites WKND Tutorial
Kubernetes Java Sample244
6 years ago9apache-2.0Java
Kubernetes Hands-on Workshop
Alternatives To Hello Linux
Select To Compare


Alternative Project Comparisons
Readme

Hello Linux

This series is all about deploying a Python web application on Ubuntu 18.04 LTS.

You can spin up a virtual machine with Ubuntu at a variety of places:

We'll be using Digital Ocean since it's really easy to get started. What you'll learn here can also be applied to deploying Python projects on any Ubuntu server. In some cases, this setup will work with other Linux distributions too albeit different methods of installation (ie not using apt-get).

Here's the plan:

  • Launch a virtual machine (droplet) with Digital Ocean
  • Access our droplet via SSH
  • Install Updates & Dependancies via bash script which is here
  • Configure & Implement:
    • Git (for push, build, & deploy) [docs]
    • Supervisor (process manager) [docs]
    • Nginx (web server / load balancer) [docs]
    • Redis (task queue datastore / message broker) [docs]
    • Celery (worker / task queues) [docs]
    • Gunicorn (WSGI web server for python) [docs]
    • PostgreSQL (database) [docs]
    • Django (Python web framework) [docs]
    • Let's Encrypt for HTTPs Certificates

1. Automatic Virtual Machine Setup

After you run the below command, you'll see an endpoint to add to your local git remote.

wget https://raw.githubusercontent.com/codingforentrepreneurs/Hello-Linux/master/setup.sh
chmod +x setup.sh
./setup.sh

2. Production-Ready Django Project

We'll be using a bare bones Django project that's mostly ready for production. It's just an example but an important one to get this working.

Go to this guide to get started.

3. Create PostgreSQL Database for Django

To create a PostgreSQL database, it's recommended to use setup.sh on Server.

Another option is to run:


# enable current logged in user as a default user for postgres
sudo -u postgres createuser $USER

sudo -u postgres psql --command="CREATE DATABASE ${projectDB};"

sudo -u postgres psql --command="CREATE USER ${projectDBuser} WITH PASSWORD '${newPassword}';"

sudo -u postgres psql --command="ALTER ROLE ${projectDBuser} SET client_encoding TO 'utf8';"

sudo -u postgres psql --command="ALTER ROLE ${projectDBuser} SET default_transaction_isolation TO 'read committed';"

sudo -u postgres psql --command="ALTER ROLE ${projectDBuser} SET timezone TO 'UTC';"

sudo -u postgres psql --command="GRANT ALL PRIVILEGES ON DATABASE ${projectDB} TO ${projectDBuser};"


Be sure to replace ${projectDB}, ${projectDBuser}, and ${newPassword} to the values you want to use. The setup script does this automatically.

Update Django Production Settings (src/cfehome/settings/production.py)

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': '${projectDB}',
        'USER': '${projectDBuser}',
        'PASSWORD': '{newPassword}',
        'HOST': 'localhost',
        'PORT': '',
    }
}

Activate Virtual Environment & Migrate Django

$ cd path/to/django/proj
$ pipenv shell
(venv) $ pipenv install psycopg2-binary # you might need this
(venv) $ python manage.py migrate

Our example

$ cd /var/www/hello_linux/src/
$ pipenv shell
(src) $ python manage.py migrate
Popular Tutorials Projects
Popular Deployment Projects
Popular Learning Resources Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Python
Python3
Shell
Deployment
Django
Tutorial
Nginx
Celery
Digitalocean