Skip to main content

Trellis / Bedrock Multisite & SSL Setup Guidance

Allure Web Solutions Code Snippet

I’ve recently setup a Digital Ocean server with deployment from Ansible. It’s great because it allows for a consistent development/staging/production workflow. During the setup of multisite and letsencrypt SSL, I ran into a few interesting points that wanted to record for myself…and maybe others will find it useful.

Trellis is not made for deployment multisite and it fails to provision if you don’t already have a DB setup. You will see that the provision craps out at the step: TASK [wordpress-setup : Create database of sites]

The steps to get past this is to provision, let the provision fail, then SSH into the server as the {admin_user} and run the WP-CLI command for setting up multisite. Note, you have to use the admin user because root access is optionally disabled (recommended).

Before you can SSH into the server as the admin user, you have to setup SSH Agent Forwarding.

Mac OS X SSH Agent Forwarding

ssh-add -K ~/.ssh/id_rsa

Then you can run the below command to check if forwarding is on. It should return the key that you added in the previous command:

ssh-add -L

WP-CLI Command To Setup Multisite

wp core multisite-install --allow-root --title="SITENAME" --admin_user="USERNAME" --admin_password="PASSWORD" --admin_email="EMAIL"

Example Of A Multisite WordPress_sites.yml

  ############################
  ## Allure Web Solutions
  ############################
  allurewebsolutions.com:
    site_hosts:

      ## allurewebsolutions.com
      - canonical: allurewebsolutions.com
        redirects:
          - www.allurewebsolutions.com
      - canonical: bedrock-sage-starter.allurewebsolutions.com

    local_path: ../allurewebsolutions # path targeting local Bedrock site directory (relative to Ansible root)
    repo: git@gitlab.com:allure-web-solutions/do-allurewebsolutions-1.git # replace with your Git repo URL
    repo_subtree_path: allurewebsolutions # relative path to your Bedrock/WP directory in your repo
    branch: master
    multisite:
      enabled: true
      subdomains: true
    ssl:
      enabled: true
      provider: letsencrypt
    cache:
      enabled: true
      duration: 30s
      skip_cache_uri: /wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml
      skip_cache_cookie: comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in
    env:
      domain_current_site: allurewebsolutions.com

Don’t forget to add multisite config to Bedrock/config/application.php:

/**
 * Multi site
 */
define('WP_ALLOW_MULTISITE', true);
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true); // Set to false if using subdirectories
define('DOMAIN_CURRENT_SITE', env('DOMAIN_CURRENT_SITE'));
define('PATH_CURRENT_SITE', env('PATH_CURRENT_SITE') ?: '/');
define('SITE_ID_CURRENT_SITE', env('SITE_ID_CURRENT_SITE') ?: 1);
define('BLOG_ID_CURRENT_SITE', env('BLOG_ID_CURRENT_SITE') ?: 1);

define('ADMIN_COOKIE_PATH', '/');
define('COOKIE_DOMAIN', '');
define('COOKIEPATH', '');
define('SITECOOKIEPATH', '');

 

allure

Author allure

More posts by allure

Leave a Reply

Designed by

best down free | web phu nu so | toc dep 2017