Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time
92 lines (75 sloc) 2.79 KB


Dreamhost Shared Hosting Flask Project Template


This is the base setup I use specifically to launch new apps on Dreamhost's shared hosting plan (there are probably some optimizations that could be made to this). While this should work with other configurations as well, I have not tested in other environments.


  1. Setup your project domain in Dreamhost's web panel:
  • PHP 5.6.x FastCGI
  • Passenger Enabled (required!)
  • Note: Dreamhost will default to using your domain as your app path, but you can change it to whatever you want. This value is referenced as <DOMAIN PATH> in these instructions as well as in your, and should be updated to the value you chose.
  1. Install newer version Python (optional - I used 3.4.2, but this works with 2.x as well)
    cd ~
    mkdir python
    cd python
    tar xf Python-3.4.2.tar.xz
    cd Python-3.4.2
    ./configure --prefix=$HOME/python
    make install
    echo 'export PATH=$HOME/python/bin:$PATH' >> ~/.bash_profile
  • log out and back in again - Python should default to the new installation
  • Note: if you install python 3.x, use "python3" to start python
  1. Install a virtual environment
    cd ~
    tar xf virtualenv-12.0.2.tar.gz
    cd virtualenv-12.0.2
    python install
    *(or "python3 install" if you installed python 3.x)*
    cd ~
    mkdir env
    virtualenv env/wsgi
  2. Install python libraries
source ~/env/wsgi/bin/activate
pip install Flask
  1. customize .bash_profile (Optional):

    # Restarts the Flask app
    alias restart='touch ~/<DOMAIN PATH>/tmp/restart.txt'
    alias main='cd ~/<DOMAIN PATH>/'
    # Activates virtualenv
    alias activate='source ~/env/wsgi/bin/activate'
    # Watch logs
    alias access='tail -500f ~/logs/<DOMAIN PATH>/http/access.log'
    alias error='tail -500f ~/logs/<DOMAIN PATH>/http/error.log'
    alias ls='ls --color=auto'
    # git
    alias gs='git status'
    alias gl='git log'
    # Shows what git branch i am currently on
    parse_git_branch() {
     git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
    export PS1="\[\033[00m\]\u@\h\[\033[01;34m\] \W \[\033[31m\]\$(parse_git_branch)
    \[\033[00m\]$\[\033[00m\] "
  2. If the app doesn't start up automatically:

    touch ~/<DOMAIN PATH>/tmp/restart.txt


Jonathan Prusik @jprusik


Dreamhost Shared Hosting Flask Project Template is released under the MIT License.