Skip to content
This repository has been archived by the owner on Feb 13, 2023. It is now read-only.

Does drupal-vm actively support multiple domains/virtual-hosts in one vm? #168

Closed
osopolar opened this issue Jul 11, 2015 · 12 comments
Closed
Labels

Comments

@osopolar
Copy link

For small projects or tests I need different domains (different codebase and different database) but I do not want to set up a vm for each domain, and neither I want to use drupal multi-sites for that.

Currently I am still using the code from drupalpro (https://bitbucket.org/mediadoneright/drupalpro, originally from the quickstart vm) in my vm to create virtual hosts like drush quickstart-create --domain=example.dev. It works well, one thing I do not like is that I need to manually sett the hosts /etc/hosts entry.

What I'd like is to have a vagrant command to just set up a new (virtual) host with database and all that stuff I need to run a new site. Is this possible with drupal-vm? If so, it would be nice to have some instruction in the wiki.

@geerlingguy
Copy link
Owner

@osopolar - Yes, you can run as many separate docroots, or combinations of single site docroots and multisite docroots, etc., as you'd like.

The configuration for this is basically split two ways (all inside config.yml):

  1. You can sync as many folders as you want via vagrant_synced_folders. And these folders can be synced into any location inside the VM (I generally prefer /var/www/[site-name]).
  2. You can set up as many virtualhosts as you want (with whatever Apache vhost options you want) in the apache_vhosts variable; point multiple virtualhosts at one docroot for multisite, or multiple virtualhosts at multiple docroots for a site-per-codebase approach.

Whenever you make changes to vagrant_synced_folders, you need to run vagrant reload to reboot the VM and pick up the new synced folders.

Whenever you make changes to apache_vhosts, you need to run vagrant provision to update the Apache configuration (this will automatically restart Apache as well).

@osopolar
Copy link
Author

Thanks, great.

@ragavendra
Copy link

ohh, I needed to add a new vhost and did the provision, I assume it re-installs all the packages and takes quite a bit of time .......

@geerlingguy
Copy link
Owner

@ragavendra - Once it does the initial provision, it just confirms all the config is correct; it doesn't need to reinstall anything. If first provision takes maybe 10 min, future provisions should only take 1-2 tops. You can really speed it up if you use a local Vagrantfile to also disable the galaxy role installation (make sure to re-enable it whenever updating Drupal VM though!): http://docs.drupalvm.com/en/latest/other/overriding-configurations/#extending-the-vagrantfile-with-vagrantfilelocal

@ragavendra
Copy link

ohh I ran into '* The following settings shouldn't exist: galaxy_role_file' , never mind I added the new host within the box .......

@webkenny
Copy link

webkenny commented Sep 9, 2016

So this seems like it should work, @geerlingguy. But my question is how do we address this in the documentation?

Set drupal_core_path to the same value as the destination of the synced folder you configured earlier:

If you can have multiple sites, wouldn't the core path change from site to site?

(Sorry to necro an old issue!)

@webkenny
Copy link

webkenny commented Sep 9, 2016

I think one of our resident geniuses has answered this. Seems that value is ignored unless you are using one of the site install routines or a build workflow (i.e. composer or make)

@hansfn
Copy link

hansfn commented Aug 22, 2018

Hm, I think the docs lacks some of the details in geerlingguy answer in this thread. And the "drupal_core_path" info is still confusing ... If this thread still is correct, the docs should be updated. (I found several issues related to this.)

@geerlingguy
Copy link
Owner

@hansfn - So, there's a bit of a tradeoff either way. The vast majority of users have only one Drupal site in a given Drupal VM instance, so there are some conveniences and documentation bits that assume one site from the beginner's perspective. Also, most of the drupal_* variables will only apply to one site, not to many.

However, it is easy enough to add two, four, or hundreds of sites to a VM instance using the apache virtualhosts var (or nginx if using NGINX), the mysql databases var, etc. If doing so, the drupal_* vars will still only apply to the first/default site of the bunch, so if you wanted to do something like have 5 docroots with 50 virtualhosts pointing at them (using multisite or something like Domain Access), then you'd either have to manage the databases/installation manually after the VM is running, or add a post-provision script that does all of that setup post-setup.

@joestewart
Copy link
Contributor

The docs do describe multisite usage http://docs.drupalvm.com/en/latest/deployment/multisite/

@hansfn
Copy link

hansfn commented Aug 23, 2018

@geerlingguy Thx for the quick reply. So maybe the best solution is to just have one Drupal site in each instance and stop thinking more about this. I have a habit of being (too) concerned about performance - which is the reason I have waited so long before I started playing with VMs.

@joestewart I'm not interested in using multisite. (I'm very familiar with it - used it a lot.) I did read the multisite docs before posting here. Actually, the rather well documented multisite setup made me expect some more info about using multiple separate Drupal installations ;-)

@joestewart
Copy link
Contributor

Sure, the reason I pointed there is the vhost and db portion is similar. Just need to ensure a mount point for the code.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants