How to Run Django on DreamHost Without Trusting the Download Button

Django on shared hosting is a three-part handshake: an app server that can run Python, a Python it's allowed to use, and one file that tells them how to find each other. DreamHost gives you the first part — Passenger, the app server built into its shared boxes. You bring the other two, and nearly every failure I've seen on this setup is just those three not lining up.

This guide walks the whole handshake: building a Python interpreter from source under your own home directory, isolating your project in a virtualenv, and writing the passenger_wsgi.py entry point that ties them together. Each step says what it does, why it exists, and what breaks if you skip it.

What You're Actually Building

Know the shape of the thing before the first command, because the commands make no sense without it:

  • Your app root. DreamHost gives each domain a folder under your home directory — on current shared plans that's ~/websites/techgeek.biz, and older setups used ~/techgeek.biz. Everything below assumes you've cd'd into the parent of that folder first.
  • Your interpreter. A full Python build at ~/opt/python-3.8.1, compiled from source, owned by you, invisible to the rest of the box.
  • Your venv. A virtualenv at ~/prodvenv built from that interpreter, holding only your project's packages.
  • The entry point. passenger_wsgi.py in your app root — the one file Passenger executes for every request.

If you can picture those four locations, the rest is just filling them in.

Before You Touch the Server: Enable Passenger

SSH access and an uploaded project are not enough. In the DreamHost panel, go to Manage Domains, click Edit on your domain, and under Web Options check Passenger (Ruby/NodeJS/Python apps only). Skip this and every later step succeeds while the site still does nothing — Passenger isn't watching your folder at all, so there's no app server on the other end of passenger_wsgi.py. Enable it first; it's the switch that makes everything below mean something.

A photorealistic wide shot of a dim server room aisle, one rack lit by rows of small blue and green status LEDs, cool overhead light pooling on the raised floor, quiet industrial mood, no visible text or letters.

Step 1 — Build Python From Source, Under Your Own Home

Shared hosting means no root: you can't install Python into the system tree, and you shouldn't want to — other people's apps share that tree, so a system-level change is a shared-impact change. You build your own, in a prefix only you control.

The version below is 3.8.1, which is what this guide was written against. The procedure is identical for any release, so check python.org for the current one before you start and swap the version string wherever it appears in a path.

# install python
cd ~
mkdir tmp
cd tmp
wget https://www.python.org/ftp/python/3.8.1/Python-3.8.1.tgz
tar zxvf Python-3.8.1.tgz
cd Python-3.8.1
./configure --prefix=$HOME/opt/python-3.8.1
make
make install
cd ~

Two things in that block deserve skepticism.

Verify before you build. A tarball you compile becomes a binary you trust for as long as it's installed, so treat the download like what it is — untrusted input. After the wget:

sha256sum Python-3.8.1.tgz

I pulled that exact file from the URL above and got c7cfa39a43b994621b245e029769e9126caa2a93571cee2e743b213cceac35fb. If yours differs, stop — your copy isn't the file you think it is, and nothing built from it is trustworthy.

The --prefix flag is the whole security model. It tells the build to install into $HOME/opt/python-3.8.1 instead of a system directory. Every binary and library lands in your own tree, so a broken or compromised build affects only you, and a rebuild is a delete-and-rerun rather than a support ticket.

Then make your shell find it:

# add to bash profile
export PATH=$HOME/opt/python-3.8.1/bin:$PATH
. ~/.bash_profile
# should show where it is installed
which python3
python3 --version
pip3 --version

which python3 is the check that matters: it must point inside your ~/opt tree, not at a system path. If it doesn't, every later command silently runs against the wrong interpreter and you'll spend hours debugging a Python that isn't yours.

# upgrade pip
python3 -m pip install --upgrade pip
# install virtualenv
pip3 install wheel
pip3 install virtualenv

One naming trap: the tmp folder from the build block is just throwaway scratch space in your home directory. It has nothing to do with the tmp/restart.txt file you'll create inside your app root later. Same name, different job.

Step 2 — One Virtualenv Per App

# makevirtual env
virtualenv -p ~/opt/python-3.8.1/bin/python3 ~/prodvenv
source ~/prodvenv/bin/activate
python -V
python3 -m pip install --upgrade pip
pip install wheel
# if you have a requirements file
pip install -r requirements.txt

The -p flag is doing quiet, important work: it pins the venv to your source-built interpreter instead of whatever virtualenv finds first on PATH. Skip it and the venv may silently inherit the system Python — at which point you built a private interpreter, pointed nothing at it, and shipped your app on shared code.

The venv is a boundary. Your project's packages live only in ~/prodvenv, so upgrading one dependency can't break another project on the box, and a bad install is fixed by deleting the folder and rebuilding from requirements.txt. That last part is why the requirements file matters: it's the difference between "rebuild takes a short while" and "rebuild means remembering what you installed."

A photorealistic close-up of a pair of hands plugging a cable into a small network switch on a cluttered workbench, warm desk-lamp light from the left, shallow depth of field with tools and coiled cables out of focus, hands-on maker mood, no visible text or letters.

Step 3 — The WSGI File Passenger Actually Runs

Now the file that ties all of it together. Create passenger_wsgi.py in your app root, next to your project folder:

import sys, os
INTERP = "/home/USERNAME/prodvenv/bin/python"
#INTERP is present twice so that the new python interpreter
#knows the actual executable path
if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv)

cwd = os.getcwd()
sys.path.append(cwd)
sys.path.append(cwd + '/django_project')  #You must add your project here

sys.path.insert(0,cwd+'/prodvenv/bin')
sys.path.insert(0,cwd+'/prodvenv/lib/python3.8/site-packages')

os.environ['DJANGO_SETTINGS_MODULE'] = "django_project.settings"
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

Read it top to bottom, because each block has a job:

  • The re-exec trick. Passenger spawns this file with whatever Python it happens to have. The INTERP line and the os.execl check say: if I'm not already running under your venv's interpreter, throw this process away and restart myself under the right one. That's why INTERP appears twice — the second occurrence is how the new process learns its own real path. Without it, your app runs on the wrong Python and dies on missing packages.
  • The sys.path lines. They tell that interpreter where to look: the current directory, your project folder, and your venv's site-packages. Miss the project line and Django can't import your settings; miss the site-packages line and it can't import Django itself.
  • The settings module and get_wsgi_application(). This is the actual handoff to Django — everything above just gets the interpreter into a state where this last line can succeed.

Replace USERNAME with your real account name, and note that the Python minor version is baked into the python3.8/site-packages path — if you built a different release, that string changes with it.

The restart.txt Trick: Recycle Without a Panel Reboot

Passenger caches aggressively, so editing code or settings won't take effect on its own. It watches one file for a changed modification time, and touching that file is the polite way to say "reinitialize":

# folder
techgeek.biz/tmp
# file
touch techgeek.biz/tmp/restart.txt

If tmp/ doesn't exist in your app root yet, create it first — the folder is part of the contract. From now on, every deploy ends with that one touch, and your changes are live without rebooting anything you don't own.

When It Doesn't Work: Run the WSGI File Yourself

The fastest way I know to stop guessing is to run the entry point yourself, from the parent of your domain folder:

# head to directory
cd techgeek.biz/
python passenger_wsgi.py

Passenger usually hides the real error behind a generic 500 page, but this command prints it straight to your terminal — the exact line that failed and why. A wrong site-packages path shows up as an import error; a wrong settings module name shows up as a ModuleNotFoundError. Either way you go from "the site is broken" to a specific, fixable sentence.

A photorealistic shot of an open laptop on a dark desk, the screen casting cool blue light across a keyboard and a half-empty coffee mug, window blinds cutting the glow into stripes, focused late-night debugging mood, no visible text or letters.

The Bottom Line

Django on DreamHost isn't hard; it's three things that have to agree — your interpreter, your venv, your entry point — plus one switch in the panel that turns the app server on. Build Python where you own it, verify what you download, keep the app inside its venv, and when something breaks, run passenger_wsgi.py by hand and let the real error talk.

Don't trust the download button; trust the hash — and trust the traceback over the 500 page.

If this was useful, More hands-on tech guides at TechGeek. No pressure — read it whenever it's useful.


Luke Keam
Spot a bug or want a custom utility built? I'd love to hear from you. Get in touch
Luke Keam | techgeek.biz