Skip to content

Linux® for Djangonauts

About the author

My name is Pat, aka The Epic Dev on various places around the web. I'm a life-long computer fan, having started my tech journey as a child using MS-DOS. I deployed my first LAMP stack on Red Hat Linux in 2001, and have been using Linux as my primary OS since 2006.

I now use Arch Linux as my primary OS, btw.

I have always worn many hats, including sysadmin, software engineer, and have worked with technologies like Linux, Apache, Nginx, PHP, MySQL, PostgreSQL, Python, Docker, Ansible, Git, C#, Perl, and many more.

I have been using Django since 2017, and am an official helper and moderator on the Django Discord Server.

What is Linux?

Linux is a free and open source operating system based on the Linux kernel, commonly packaged with the GNU utilities. While you can build and install Linux from scratch, it is more common to install a Linux Distribution, aka a distro.

Some of the more popular distros include:

There are also distros targeted at specific audiences, such as:

  • Alpine Linux, a Linux distribution for embedded devices and containers.
  • Ubuntu Studio, an Ubuntu derivative for editing audio, graphics, pictures, and video.
  • Kali Linux, a Linux distribution for penetration testing, security research, and computer forensics.
  • BlackArch, another distro for penetration testing based on Arch Linux.
  • Hannah Montana Linux, a now deprecated distro based on the Hannah Montana sitcom.
  • Red Star OS, a North Korean distro.

Note

I do not recommend using the last two.

Linux can be used on a wide variety of devices, including servers, desktops, laptops, and embedded systems. It is designed to be used by multiple users, and can be run with little to no user interaction, which makes it a great choice for running web and other server software.

Why Linux?

Linux is one of, if not the most popular operating system for web servers. According to W3Tech, more than 82.5% of all web servers use Unix-like operating systems, including Linux. While it is less popular on the desktop with a market share of only around 3%, it is used by 45% of software developers.

The Django web framework, a popular web framework written in Python, is primarily built with the expectation that it will run on Linux or another Unix-like OS. If you are a Django developer, knowing how to use and manage a Linux server will give you solid foundation to deploy your applications on the internet.

Linux also offers a premier development environment. Using tools like Docker will greatly improve your developer experience (DX), and make running and debugging applications much easier.

What is Django?

Django is a web framework written in Python. As you may guess from the fact that I am writing a book dedicated to it, it happens to be my favorite framework for web development.

It's fast, secure, quick to develop with, and used by many large companies including Meta (Instagram and Threads), Sentry, Disqus, Mozilla, Eventbrite, Octopus Energy, and many more.

It can be used with the Django Template Language to render HTML pages, or used to serve APIs via REST or GraphQL.

What this book covers

Seeing as this book is primarily aimed at Djangonauts and Django mostly runs in two environments, i.e. development and production, we will look at the following topics:

  • Linux basics (user management, package management, packages, services, etc.)
  • Getting and installing Linux in the development environment (Ubuntu and Arch Linux), and setting up an Epic DX.
  • Getting a Linux VPS, and configuring it to run Django on Ubuntu.
  • Automating configuration with Ansible.
  • Running applications, including Django, in Docker containers.
  • Automating deployment with Gitlab-CI.

In the long run, this book may also cover:

  • Kubernetes.
  • A cloud provider (GCE or AWS).
  • Running Linux under WSL.
  • Virtualization.

I will not be going into details regarding Django development, but will link to relevant sources when necessary.

Seeing as brevity is the soul of wit, I will try to briefly cover what I believe to be the most important topics to help you develop and run Django applications on Linux, but a lot of this information will apply to other technologies as well. I will also leave as many links as possible so you can explore topics further. Finally, one big advantage of this being an e-book is that this book will evolve based on the feedback I receive.

Info

This book is highly opinionated, based on my years of experience. I will mostly focus on one way of doing things. This is by no means the only way, and I may list alternatives for you to explore further, but if you're just getting started, doing things the way I recommend will quickly help improve the quality of your code, deployments, dependency management, etc.

How this book is organized

Poorly, most likely. I start with a lot of theory before getting to practical uses, so you may want to read sections like Running Linux and Introduction to the Terminal before reading about file systems and permissions if you want to follow along with my examples. Don't blame me, it's all because of circular dependencies.

Status

Please note that this book is currently a work in progress. The sections that are provisionally complete may not have been revised or edited yet, and others may not be complete.

If you have any comments, feedback, found some mistakes or something is unclear, please reach out to me on Discord (theepic.dev).

Support

This book is, and always will be, free to read. However, if you find this book useful and want to support the author, you can help finance the book's development on ko-fi. This may encourage me to keep this up-to-date, explore other technologies, and may lead to more books in the future.

Terms of use

The information in this book is strictly for educational purposes, and does not amount to professional or financial advice. While the information is accurate to the best of the author's knowledge at the time of writing, it may be outdated by the time you read it, offerings by third parties may have changed, and this books offers no guarantee of any kind. By reading this book and following the information presented therein, you agree to absolve the author of any mistakes, omissions, etc. The author may not be held liable for any misinformation or misinterpretation, loss of business, data loss, service fees, or anything else. You are solely responsible for using this information in a responsible manner and in accordance with the terms and conditions of any service you contract.

Affiliate link information

Note that certain external links may be affiliate links. This means I may be rewarded if you click on them, e.g. with free credits from a service provider, at no extra cost to you.

Trademark information

Django is a registered trademark of the Django Software Foundation.

Linux® is the registered trademark of Linus Torvalds in the U.S. and other countries.

The use of these terms throughout the book, as well as references to other distros and packages, is nominative and falls under the fair use doctrine. Usage of these and other trademarks does not indicate endorsement.