Multiple Apps on DreamHost with Passenger

N* = Fun^2

A couple weeks ago I had a few hours of fun trying to deploy two applications on DreamHost with Passenger. I got it running and here I’ll tell you how.

This post is complete, but before we proceed, please have a look at the Passenger users guide and keep it handy for reference. Also, it’s a good idea to skim through, and to get acquainted to the subject of this post.

This article can also be useful if you need to run a or any other Python web application — such as Django o Flask — in a sub directory of your domain.

Let’s go by parts.

1) Passenger

If you haven’t yet, enable Passenger for your domain. Log into your DreamHost Control Panel, go to Manage Domains. Whether you are creating a new or changing an existing domain, all you have to do is click a checkbox like the following. Beware that your web directory must end in /public to enable Passenger.

Check the checkbox

Check everything and hit either “Fully host this domain” or “Change settings”. That was easy.

2) Python 2.7

For this and the next parts we’ll need shell access, so go to your DreamHost Control Panel and enable shell access.

If you check, DreamHost’s Python is a bit old and we want to use a newer one as current libraries need it to be new. So let’s install Python 2.7.3 on our shared DreamHost account under the ~/Python27 directory.

SSH into you account and download Python’s source code:

Configure it to install under ~/Python27 — you can change this — build and install it. This will take a few minutes and output lots of lines, of which only errors, if any, will matter:

That’s it! Check your new Python:

If you wish to put it on your PATH, add the following line to your ~/.bash_profile:

Log out and back in and check it’s in the PATH:

Now we’re getting warmed up!

3) Virtualenv

Virtualenv will come handy when installing Python packages, it’s more convenient and IMO easier. We’ll benefit from the newest version of Virtualenv, just grab the single file and run it:

Let’s use it to create an isolated Python environment:

Activate our virtalenv with:

And install the packages we’ll need, such as:

This makes the virtualenv ready to run some cool apps!

4) Apps

For this example, we will set up two simple applications and the directory structure will be like the following:

We’ll talk about each of these files.


The files public/app1/ and public/app2/ are the the applications’ bootstraps, and they has to called like that ( in order to work. Their content is as follows:

4.2) ~/

The file ~/ is where we disable Passenger for the entire domain, among other things. Don’t worry, we’ll enable Passenger where necessary. The content of ~/ is:

4.3) ~/*/.htaccess

The files public/app1/.htaccess and public/app2/.htaccess are where we enable Passenger and set the root for each application. Such as in case of app2:

Just a note: the application root does not have to reside in the public tree, it may as well be located at ~/ or anywhere, just don’t forget to set accordingly:

4.4) ~/*/tmp/restart.txt

Passenger’s documentation says “By [you] creating or modifying the file tmp/restart.txt in the Rails application’s root folder, Phusion Passenger will automatically restart the application during the next request.” So let us bear in mind we should update this file in case we change our application.

5) Time to see it running!

Go ahead and point your browser to and/or to to see the two applications working independently. Now relax and enjoy!

6) Conclusion

I have had good experiences with Passenger so far. It’s pretty fast and, in my opinion, quite easy to use. Kudos and BIG thanks to the Ruby community!

So, that’s all there is to it! Drop a message in the comment box below, I’d love to read your thoughts.