Roots Discourse

Trellis + Bedrock + WP Multisite Network + Domain mapping [setup]

Hey guys,

The last 3 days straight I have been trying to set up a WP Multisite with Domain Mapping, I’m pretty sure I have been trough almost every related topic (most posted around 2016) here but somehow still no luck. It’s very likely that I’m overthinking and confusing the right order of doing things due to the frustration so I would really appreciate some guidance.

I’m using DigitalOcean for hosting and Cloudflare for DNS.

The goal is to have a WP Multisite Network like so:

  • brandname.com (main site)
  • brandname.no (subsite) DNS pointing to main site IP
  • brandname.se (subsite) DNS pointing to main site IP
  • brandname.dk (subsite) DNS pointing to main site IP
  • etc…

Question 1 - Can anyone confirm it is even possible?

So far I’ve been trying to set up Trellis like so, as following this article:

# brandname.com/trellis/group_vars/development/wordpress_sites.ym

wordpress_sites:
  brandname.com:
    site_hosts:
      - canonical: brandname.test
        redirects:
          - www.brandname.test
    local_path: ../site
    admin_user: overseer
    admin_email: admin@brandname.com
    multisite:
      enabled: true
      subdomains: true
    ssl:
      enabled: false
      provider: self-signed
    cache:
      enabled: false
    env:
      db_prefix: wp_xxx_
      domain_current_site: brandname.test

# brandname.com/trellis/group_vars/production/wordpress_sites.yml

wordpress_sites:
  brandname.com:
    site_hosts:
      - canonical: brandname.com
        redirects:
          - www.brandname.com
      - canonical: brandname.no
        redirects:
          - www.brandname.no
    local_path: ../site
    repo: git@github.com:XXX/XXX.git
    repo_subtree_path: site
    branch: master
    admin_user: xxx
    admin_email: admin@brandname.com
    multisite:
      enabled: true
      subdomains: true
    ssl:
      enabled: true
      provider: letsencrypt
    cache:
      enabled: true
    env:
      db_prefix: wp_xxx_
      domain_current_site: brandname.com

# brandname.com/site/config/application.php

...
Config::define('WP_ALLOW_MULTISITE', true);
Config::define('MULTISITE', true);
Config::define('SUBDOMAIN_INSTALL', true);
Config::define('DOMAIN_CURRENT_SITE', env('DOMAIN_CURRENT_SITE'));
Config::define('PATH_CURRENT_SITE', env('PATH_CURRENT_SITE') ?: '/');
Config::define('SITE_ID_CURRENT_SITE', env('SITE_ID_CURRENT_SITE') ?: 1);
Config::define('BLOG_ID_CURRENT_SITE', env('BLOG_ID_CURRENT_SITE') ?: 1);

Config::define('ADMIN_COOKIE_PATH', '/');
Config::define('COOKIE_DOMAIN', '');
Config::define('COOKIEPATH', '');
Config::define('SITECOOKIEPATH', '');
...

Question 2 - Would it be better to have “subdomains: false” of “subdomains: true”?

I’ve read from some topics that it’s better to first set up and deploy a regular site and make it Multisite afterwards.

Question 3 - Is it okay to set up a Multisite first thing or should I do it afterwards?

The way I had it set up, I was able to provision Vagrant with no worries. Provisioning production was also OK but when I tried to deploy to production, I got the following error - just can’t figure out why:

non-zero return code
WordPress database error Table 'brandname_com_production.wp_xxx_blogs' doesn't
exist for query SELECT  wp_xxx_blogs.blog_id FROM wp_xxx_blogs  WHERE domain
= 'brandname.com' AND path = '/'  ORDER BY wp_xxx_blogs.blog_id ASC LIMIT 1
made by include('phar:///usr/bin/wp/php/boot-phar.php'),
include('phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php'),
WP_CLI\bootstrap, WP_CLI\Bootstrap\LaunchRunner->process,
WP_CLI\Runner->start, WP_CLI\Runner->load_wordpress, require('wp-
settings.php'), require('wp-includes/ms-settings.php'),
ms_load_current_site_and_network, get_site_by_path, get_sites,
WP_Site_Query->query, WP_Site_Query->get_sites, WP_Site_Query->get_site_ids
WordPress database error Table 'brandname_com_production.wp_xxx_sitemeta'
doesn't exist for query SELECT meta_value FROM wp_xxx_sitemeta WHERE meta_key
= 'site_name' AND site_id = 1 made by include('phar:///usr/bin/wp/php/boot-
phar.php'), include('phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/wp-
cli.php'), WP_CLI\bootstrap, WP_CLI\Bootstrap\LaunchRunner->process,
WP_CLI\Runner->start, WP_CLI\Runner->load_wordpress, require('wp-
settings.php'), require('wp-includes/ms-settings.php'),
WP_Network->__construct, WP_Network->_set_site_name, get_network_option
fatal: [167.71.42.64]: FAILED! => {"changed": false, "cmd": ["wp", "core", "is-installed", "--skip-plugins", "--skip-themes", "--require=/srv/www/brandname.com/shared/tmp_multisite_constants.php"], "delta": "0:00:00.264139", "end": "2019-08-03 18:03:57.277343", "failed_when_result": true, "rc": 1, "start": "2019-08-03 18:03:57.013204", "stderr_lines": ["WordPress database error Table 'brandname_com_production.wp_xxx_blogs' doesn't exist for query SELECT  wp_xxx_blogs.blog_id FROM wp_xxx_blogs  WHERE domain = 'brandname.com' AND path = '/'  ORDER BY wp_xxx_blogs.blog_id ASC LIMIT 1 made by include('phar:///usr/bin/wp/php/boot-phar.php'), include('phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php'), WP_CLI\\bootstrap, WP_CLI\\Bootstrap\\LaunchRunner->process, WP_CLI\\Runner->start, WP_CLI\\Runner->load_wordpress, require('wp-settings.php'), require('wp-includes/ms-settings.php'), ms_load_current_site_and_network, get_site_by_path, get_sites, WP_Site_Query->query, WP_Site_Query->get_sites, WP_Site_Query->get_site_ids", "WordPress database error Table 'brandname_com_production.wp_xxx_sitemeta' doesn't exist for query SELECT meta_value FROM wp_xxx_sitemeta WHERE meta_key = 'site_name' AND site_id = 1 made by include('phar:///usr/bin/wp/php/boot-phar.php'), include('phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php'), WP_CLI\\bootstrap, WP_CLI\\Bootstrap\\LaunchRunner->process, WP_CLI\\Runner->start, WP_CLI\\Runner->load_wordpress, require('wp-settings.php'), require('wp-includes/ms-settings.php'), WP_Network->__construct, WP_Network->_set_site_name, get_network_option"], "stdout": "", "stdout_lines": []}
	to retry, use: --limit @/home/xyxyxyxy/Sites/brandname.com/trellis/deploy.retry

Tried to Google it but no luck at all.

Any ideas?