Closed brookeheaton closed 6 years ago
Sorry, seems I forgot to actually put up any code when I created this repo. I have now committed it, hopefully that should get you on your way!
@nalipaz I've attempted to create a multisite per your formula, but for some reason I'm not quite clear on how the mysql services are defined and why more than one would be needed. I'd appreciate any advice you might be able to give. My situation is a bit more complicated since I'm using Acquia BLT, but every time go to build one of my multisites, I keep getting this error:
[info] Executing: mysql --defaults-file=/tmp/drush_twCi7N --database=naswa_main --host=naswa_main --port=3306 --silent < /tmp/drush_NV5bd6 > /dev/null
You are about to CREATE the 'naswa_main' database. Do you want to continue? (yes/no) [yes]:
> yes
[info] Executing: mysql --defaults-file=/tmp/drush_bdQ9Jh --database=naswa_main --host=naswa_main --port=3306 --silent < /tmp/drush_jLLFVx > /dev/null
[info] Executing: mysql --defaults-file=/tmp/drush_rJKirL --database=information_schema --host=naswa_main --port=3306 --silent < /tmp/drush_uVHGA1
[error] Failed to create database: ERROR 1045 (28000): Access denied for user 'naswa_main'@'naswa_appserver_1.naswa_default' (using password: YES)
Despite the fact that I have this defined in my local.settings.php
$databases = array(
'default' =>
array(
'default' =>
array(
'database' => 'naswa_main',
'username' => 'naswa_main',
'password' => 'naswa_main',
'host' => 'naswa_main',
'port' => '3306',
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
'driver' => 'mysql',
'prefix' => '',
),
),
);
and this in my lando.yml
name: naswa
recipe: drupal8
config:
webroot: docroot
php: 7.1
database: mysql:5.7
conf:
php: lando/php/php.ini
appserver:
proxy:
appserver:
- naswa.lndo.site
- naswa_main.lndo.site
tooling:
blt:
service: appserver
cmd: /usr/bin/blt
services:
edge:
type: varnish:4.1
backends:
- appserver
ssl: true
naswa_main:
type: mysql:5.7
portforward: true
creds:
user: naswa_main
password: naswa_main
database: naswa_main
config:
confd: lando/mysql/conf.d
My lando info shows:
{
"appserver": {
"type": "php",
"version": "7.1",
"via": "apache",
"webroot": "docroot",
"config": {
"conf": "lando/php/php.ini"
},
"urls": [
"https://localhost:32798",
"http://localhost:32799",
"http://naswa.lndo.site",
"http://naswa_main.lndo.site",
"https://naswa.lndo.site",
"https://naswa_main.lndo.site"
]
},
"database": {
"type": "mysql",
"version": "5.7",
"creds": {
"user": "drupal8",
"password": "drupal8",
"database": "drupal8"
},
"internal_connection": {
"host": "database",
"port": 3306
},
"external_connection": {
"host": "localhost",
"port": "32797"
},
"config": {
"confd": "/Users/brookeheaton/.lando/services/config/drupal8/mysql"
}
},
"edge_ssl": {
"urls": [
"https://localhost:32801"
]
},
"edge": {
"type": "varnish",
"version": "4.1",
"backends": [
"appserver"
],
"urls": [
"http://localhost:32800"
]
},
"naswa_main": {
"type": "mysql",
"version": "5.7",
"creds": {
"user": "naswa_main",
"password": "naswa_main",
"database": "naswa_main"
},
"internal_connection": {
"host": "naswa_main",
"port": 3306
},
"external_connection": {
"host": "localhost",
"port": "32796"
},
"config": {
"confd": "lando/mysql/conf.d"
}
}
}
I'm befuddled by why the database needs to be created or why the user does not have access to it since I've explicitly declared that in my lando.yml - didn't Lando create the mysql server and database when I ran lando rebuild?
Evidently I ran into this issue: https://docs.devwithlando.io/issues/switching-dbs.html
I ran lando destroy then lando start and the db kicked in
@nalipaz while I seem to have established the mysql service for the second multisite, I am still completely unable to get a multisite running. I am unclear on how you would have the sites.php configured and anything special required in the settings/local.settings.php - it seems the code in this repo scratches the surface but there's still a LOT left to figure out.
@nalipaz I'm not clear on how apache is routing to the subsites using vhosts - I don't see that in your my.cnf file https://github.com/nalipaz/lando-acquia-multisite-recipe/blob/master/lando/mysql/conf.d/my.cnf I would assume you'd need to define Virtual hosts to get the site routing working?
most everything is defined in .lando.yml. However I do realized there is some stuff missing and will look into adding it. Namely sites.php examples of settings.php and the like.
So, yea I have the above, but my subsite url is not resolving. I think that has to do with Apache but I'm not sure. I saw very helpful direction for DrupalVM - which outlines how to add the vhosts for any subsite: http://docs.drupalvm.com/en/latest/deployment/multisite/ But Lando does not offer that capability so they have to go in Apache config... somewhere. I'm not sure where yet. Perhaps via:
config:
server: config/httpd.conf
?
So I added some sites files for you to have a look at under docroot
Added some settings.php files.
Additionally I should note that on our acquia sites I added custom drush aliases that allow easily doing sql syncing from upstream to my local. It is something you could add but not really part of the acquia infrastructure normally.
I have just finished up adding the tooling to allow syncing all the sql from your upstream sites to your local lando instance using drush aliases.
There was a bunch other stuff I added too. Mostly surrounding using drush aliases as well as enabling drush to connect to your environments. I hope it all helps. Read the bit in the README and look at all the new files. If you have questions let me know.
Thanks a million @nalipaz - this is immensely helpful!!! I've done my best to fix my D8 multisite configuration and many things appear much clearer now based on your documentation and comparing notes with the Lando docs. The one issue that I've been able to isolate that is still giving me major problems is that I can't seem to get the environment variable for AH_SITEENVIRONMENT set in lando - as a result my lando.settings.php isn't detected, and, well... nothing will work. Replacing my settings.php with the lando.settings.php seems to finally pull up the site, but that's not ideal. I'm adding my .lando.yml for reference- would you know why I am not getting the env variable to get added? Another note: I did try running this but it did not return anything `lando ssh appserver -c env | grep LANDO`
name: naswa
recipe: drupal8
config:
webroot: docroot
php: 7.1
database: mysql:5.7
conf:
php: lando/php/php.ini
appserver:
proxy:
appserver:
- naswa.lndo.site
- naswa_main.lndo.site
tooling:
blt:
service: appserver
cmd: /usr/bin/blt
'sql-sync-all <environment>':
service: appserver
description: Synchronize SQL on all sites, from a specific environment (prod, test, dev, proto)
cmd: /app/lando/tooling/sql-sync-all.sh
services:
naswa_main:
type: mysql:5.7
portforward: true
config:
confd: lando/mysql/conf.d
integrity:
type: mysql:5.7
portforward: true
config:
confd: lando/mysql/conf.d
appserver:
type: php:7.1
ssl: true
scripts:
- scripts/add-blt.sh
overrides:
services:
environment:
AH_SITE_ENVIRONMENT: lando
AH_NON_PRODUCTION: 1
Follow up: Seems I was wrong.
lando ssh -c "env | grep AH_SITE_ENVIRONMENT"
DOES return AH_SITE_ENVIRONMENT=lando
which is fantastic. But something must be wrong yet in my settings.php for each site. I think I am now very close!
be sure your php.ini is being used. Notice how I added a php.ini in this repo. That is because default php in lando doesn't include E in variables_order = EGPCS
You mentioned that you had this working. Would you be able to provide some guidance?