Closed (fixed)
Project:
Vagrant Drupal Development
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
6 Aug 2013 at 15:04 UTC
Updated:
19 May 2014 at 12:19 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
Aleksey Zubko commentedComment #2
Aleksey Zubko commentedAttached patch. It's works for me.
Comment #3
Aleksey Zubko commentedComment #4
danylevskyiComment #5
scottrigbyJust played with this for fun… Without vhosts, how do you recommend supporting Drupal's multisite functionality?
Comment #6
Aleksey Zubko commentedWe can add in to config option, named "Server Aliases" and use it for vhost's config files, for example. What do you think?
Comment #7
scottrigby@Aleksey Zubko: Yes, that and the ability to optionally specify DocumentRoot (we can not assume
/var/www/<%= index %>).It might look something like:
And then the vhost DocumentRoot could check that optional key, like:
Where the vars (like 'index') get defined:
document_root = site["document_root"] ? site["document_root"] : indexIn your patched version of /cookbooks/core/vdd/templates/ubuntu/localhost.conf.erb:
DocumentRoot /var/www/<%= document_root %>Comment #8
scottrigbyBTW is there a way to rebuild based on changes made to config.json, without destroying and rebuilding the VM?
Comment #9
danylevskyi@scottrigby if you want to add something you can just run 'vagrant provision' or 'vagrant reload'.
The problem raises when you need to delete virtualhost. In this case we need to create some file for tracking changes. It can help us to know whether data was removed from config on provision.
vagrant destroy is definitely simpler way.
Comment #10
ericrdb commentedThanks for the patch. Tested and works for me.
Comment #11
jamesrward commentedI would love to review this but I am having no luck applying the patch. Is the patch working for anyone else? Does it need to be re-rolled for the current dev branch? Very interested in setting up a multisite dev machine.
Comment #12
ericrdb commentedPatch updated.
Couple additional pieces added so that the vhost becomes .dev as a url. Also, I put the changes in the default templates instead of the ubuntu ones because I'm thinking this will reduce confusion for future.
EDIT: I just now re-read @scottrigby's comments from #7. This patch doesn't support defining the document path at this time.
Comment #13
scottrigby@ericrdb Configurable aliases would be helpful too. There are projects where the local development URL must follow a certain pattern (whether .local, etc).
Comment #14
danylevskyiGreat idea with configurable virtual host names.
Comment #15
jamesrward commented@ericrdb thanks for the reroll. I copied the changes manually to test for myself but didn't have a chance to roll a patch. It's working well for my purposes.
@scottrigby assuming this is only being used for local development then you are already controlling the servername via the site object name in the config.json. For example:
Would respond to mysite.local. I have this working nicely with .dev domains and dnsmasq. If you wanted .dev you would change the first line to "mysite.dev" and it would respond to that instead. If you need multiple aliases then this wouldn't satisfy your needs. Is that what you are suggesting? Multiple aliases for a single vhost?
Comment #16
ericrdb commented@jamesrward, that server name approach meets my needs. I changed the config.json to illustrate.
@scottrigby, document_root variable is available in the config.json with this latest patch. I created an example multisite in the default config.json.
The latest patch also improves documentation by showing users what to add to their OS's hosts file based on config.json's site index and if the vhost flag is true. Plus minor css tweaks for improved readability.
Feedback? Thanks
Comment #17
scottrigby@jamesrward re alias, I didn't get that from the initial config.json, where the keys were 'drupal7' and 'drupal8' (these seem more like project names than domains). Also I suggested aliases because it seemed if we repeated the config multiple times with a different key, it would install separate instances instead of having more than one URL point to the same directory (which is preferable for multisite). But it's been a while since I played with this so maybe I'm remembering incorrectly? Would the config file in #16 set up a standard Drupal multisite properly?
@ericrdb I haven't been able to test this yet, but thanks for addressing the docroot question. Would this work if, for example, a local site followed Acquia's dev cloud repo structure locally (where DRUPAL_ROOT is in a subdirectory, like /var/www/drupal7/docroot)?
Thanks in advance for clarifying… I'm trying to get questions out there as soon as possible, and will try to look closer at this as soon as I have time.
Comment #18
danylevskyi@scottrigby is right. 'drupal7', 'drupal8' are project names. They are used internally in the cookbooks. Also drush alias is constructed from these names. I'm afraid that's not good idea to use these names as project domains.
My proposal is to use next JSON form:
Comment #19
danylevskyiAlso I think that we should implement directory structure where DRUPAL_ROOT is subdirectory. For example, "/var/www/drupal7/htdocs". It will be convenient to store some scripts inside "/var/www/drupal7".
Comment #20
ericrdb commentedI agree with putting drupal_core wherever people want.
This patch enables users to set the docroot path to whatever depth they prefer:
Also, I changed the config.json to use the server_name and server_alias variables. Updated config.json with examples.
Comment #21
danylevskyi@ericdb great work!
Should we create ability to set multiple aliases?
What do you think about vhost structure? If we make it nested it looks more logical. Also if one doesn't want to use vhosts he simply makes it disabled and do not bother with other variables (see 'drupal7' vhost).
Comment #22
scottrigby@danylevskyi Yes multiple aliases could be helpful. And yes, this nested syntax is much clearer!
Comment #23
scottrigby@ericrdb and nice work in #20 with full path for drupal root, and using the variables.
Comment #24
ericrdb commentedThanks @scottrigby and @danylevskyi! I appreciate the feedback.
I like the multiple alias ability too and the nested syntax is a great idea. I propose a slightly more terse version of the config.json, where the entire vhost section is dropped if unused. This approach would avoid use cases when the user selects "enabled": false but includes all vhost detail and is confused why there's no vhost. Similarly, if a user puts "enabled": true and excludes those other attributes and then provision fails with syntax issues.
I also propose using "url" instead of "name" for user clarity. Thoughts?
The attached patch works with the above config structure. I also updated the html help file (vdd landing page) to use the vhost settings and README docs accordingly. Cheers
Comment #25
rootworkUsing the patch in #24 and it's great!
I agree with using "url" rather than "name" given what's being defined.
I might suggest having one of the three examples (maybe the first one) define just a single alias so users don't think they are required to define something.dev and something.local.
The instructions on the home page on updating hosts is a nice touch. I don't suppose there's any way to script the editing of the hosts file automatically?
Comment #26
scottrigby@rootwork hi :) The help text does say it's the vhost keys are optional. Also, there are ways to automatically write to the host machine's hosts file, but that requires a system admin password.
@ericdb re
IMO server_name and server_alias are most accurate (underscored versions of Apache CamelCase ServerName & ServerAlias. Nginx is server_name and rewrite, but they're reversed anyway). This is a custom config syntax though, so as long as it's explained in the help text, which it is, I wouldn't want to bikeshed it. This is looking good!
I have not been able to test it yet though. Does anyone have time to do that?
Comment #27
danylevskyiIt worked for me! I think it's RTBC.
Comment #28
rootworkI also tested it and it works great.
I don't want to hold up this issue, but maybe it would be worth evaluating whether editing the hosts file, which would require an admin password, would be worth it? Other vagrant setups I've seen have gone this route, and it seems convenient for less technical folks, who are more likely to know their password than know how to edit their hosts file.
But in terms of this issue the patch definitely works.
Comment #30
ericrdb commentedCommitted - Thanks all!
Let's open a new issue to address additional enhancements.