Hi, I’ve been looking into using Vagrant for my test system recently and was wandering if anyone had replicated the Dreamhost shared hosting environment with it. Or if there was any similar tool that someone had already used.


Hi there. I was just browsing around for a quick (well, quicker) solution to replicating a Dreamhost Shared Hosting environment. Recently, I have created a Vagrant Instance that has the same linux flavor, versions of Apache and PHP as well as installing the same Perl and Apache modules (as many as I could). That got me close but Dreamhost uses a very customized Apache/PHP setup. (Most of their config is located in /dh).

Did you find anything?

– Josh

Would be nice to see someone post and had done this already in the past. I haven’t seen anyone being able to set this up yet.

I agree, it would be nice to see a Vagrant box with DH’s Shared Hosting parameters.

This weekend I have it on my side-Task list to look into what it would take to create such a box. I know that DH has their ‘customized Apache setup’ but we could re-create it essentially. At least the Apache modules, Perl modules and PHP mods setup on the same linux distro.

If I get anywhere with it I will post here and probably do a Github repo. I was thinking of using Puphpet to generate the Vagrantfile-- would make it easy to include all of the correct modules.

Would you be interested?

Josh Canfield

pretty much late to the party, but if anyone is home…

Yes: I’d be interested in a vagrant box. Apparenly my server is running Debian 6.06, fwiw.

Here’s one more vote in favor of a DreamHost shared hosting environment Vagrant box (officially-sanctioned or provided by DH staff would be awesome, too).

I was recently developing a Wordpress site locally on my machine – new versions of WP now encode the database in utf8mb4 if running a new enough version of MySQL. DreamHost is still running an older version of MySQL that doesn’t support uft8mb4, so it was failing when I tied to migrate the database over. Luckily I was able to easily converse the database back to utf8 without loosing any data, but it would be great to just mimic DH’s environment and not have to worry about issues like this at all.

I’ve got a DreamHost Vagrant box started here:

Complete with a script to set up a user and link the web root to the user directory.

Ubuntu 12.04, PHP 5.6.10, Apache 2.2.22 (with CGI/FastCGI and ModSecurity), and MySQL 5.5.40.

Perl, Ruby and Python aren’t set up, since I don’t really have any experience with either.

It works great for me so far. I hope it works for you, too.

This looks exciting! I’m relatively new to Vagrant; I think I understand how most of it works (at least concept-wise) — but I’m a little confused about how to configure this environment. What I’ve done successfully is init goodguyry/dreambox and vagrant up, then run the user_setup script from within the vm. But then, won’t I need to redo that user_setup if I ever vagrant destroy? (Shouldn’t I be able to automate this?) And do I need to wire up my own networking from within my local Vagrantfile? I am confused because the Vagrantfile in your github repo seems to do some networking setup between the guest and the host, but I could be misinterpreting this.

The other thing I’m confused about is the difference between the Vagrantfile in your github repo and what I end up with if I do a vagrant init goodguyry/dreambox. Is that github vagrantfile embedded in the box somehow? Is it supposed to be embedded to the point of being inaccessible to the end user (me)? Or should I not use the goodguyry/dreambox vagrant box at all and instead download your github repo to use that vagrantfile directly in my project?

Gradually becoming less confused! I reread your documentation and figured out how to automate user setup from my local Vagrantfile. But now I’m not sure how exactly I’m supposed to access the “shared hosting” user DocumentRoot in a browser. I wired up a entry in my Vagrantfile, and I can hit apache on the dreambox, but it appears to just be the generic host and not (what I’m assuming is) the vhost for my user.

I can’t actually find what files it’s serving… apachectl doesn’t want to do much because it says there are configuration errors (actually files referenced in the configuration that do not have permission granted for whatever apache is running as), and “sudo apachectl” says it can’t find the binary… so my hands are a bit tied as far as my typical troubleshooting would be concerned.

Thanks so much for the feedback! It can be very difficult to put something like this together in a vacuum, so having someone respond with issues is awesome. I actually found a few issues last week while working on a project that I need to address, so as I work on those I’ll work on also clearing up the documentation, etc. Anyway, glad you found the note about automating user_setup.

The vhost’s document root should be in /home/[dreamhost_username]/[site_root_directory]/, and linked to the directory in the project root specified during user_setup (by default, ‘web’). So if you didn’t specify anything for the project root directory during user_setup, create a folder called ‘web’ in your project’s root and put your site’s files there. You can verify the paths are correct in /usr/local/apache2/conf/extra/httpd-vhosts.conf to be sure.

Also note that when you ssh in, you’re logged in as the vagrant user, so you won’t see anything in that home directory. I did look into setting it up to log in as the user created with user_setup, but it looked like more trouble than it was worth; I’ll revisit this idea, because I know it would make things way more intuitive.

Use sudo /etc/init.d/apache2 <option> to run configtest, restart, etc. I’m getting the same errors as you from apachectl and sudo apachectl, which is confusing because /etc/init.d/apache2 is linked directly to apachectl… I’ll look into it, and also aliasing /etc/init.d/apache2 so it’s not such a pain to type out.

I hope that helps.

Hey, glad to hear from you. Some more comments and findings:

Here’s what my Vagrantfile looks like now:

[code]Vagrant.configure(2) do |config| = "goodguyry/dreambox"
config.vm.define :dreambox :private_network, ip: ""
config.vm.hostname = “”

user_vars = {

config.vm.provision “shell”,
inline: “/bin/bash /usr/local/bin/user_setup”,
:env => user_vars
(I am also using vagrant-hostsupdater plugin).

I did a vagrant destroy and vagrant up from there to make sure this was clean, and then demonstrated the following:

[]In a local browser, access I get an HTML file that says “It works!”
]In a local browser, access I get a 403 Forbidden error. I think this is expected with no “default” vhost?
[*]In a vagrant ssh session, do wget -qO- localhost: I get HTML from index.html in web/

The last example is the only one that makes sense given the sudo apache2 -S output from dreambox, and obviously I want the same thing to happen for the first example. (Not sure where that “It works!” HTML is coming from… that’s like an Apache default, isn’t it?) So I’ve got to continue trying to figure that out.

A couple other notes — I think the user_setup process of symlinking /home/username/ to /vagrant/web/ within the VM might be less than ideal. After a few vagrant up/downs there was a point at which the symlink wasn’t resolving, and so apache2 configtest thought the documentroot wasn’t a directory. Might it be a better idea to let vagrant create the vhost documentroot as a synced directory instead of doing the symlink thing? Maybe the problem I had was a different issue, but it still might be more “authentic” to have the VM think those files exist right in the documentroot.

Also, for the purposes of documentation, I’d suggest including an example Vagrantfile or two of a fully ready-to-go (but simple) setup so that the user just has to make edits as desired instead of composing it themselves. Would help out the newbies like me!

You don’t sound like a newbie :wink:

The note about using a sync folder rather than symlinking is spot on; it’s on my to-do list. I ran into that issue with another vagrant environment I set up and wished I’d thought of it sooner.

I just moved and unfortunately won’t have WiFi at my new place until Friday (ugh…). I’ll try to find time before then to get online and reproduce these issues and see what I can find out. In the meantime, if you have a GitHub account, feel free to open an issue there.

I appreciate your interest and willingness to dive in to help me get this all sorted out. With the move, another project I just finished up and now with not having internet at home, I haven’t had time to jump back into this. Thanks for your patience!