Skip to content

Set up VVV for VIP development

VIP recommends setting up a local development environment with the VIP Local Development Environment feature built into VIP-CLI. The steps outlined here are a separate and alternative method for setting up a local environment with Varying Vagrant Vagrants (VVV).


Prerequisites

VVV is installed and has been successfully tested on the user’s local machine.

Add a new site and site settings

VVV’s documentation provides instructions for adding a new site to a local environment by editing the VVV config found at /config/config.yml.

This config can be edited to not only add a new site, but it can also provision the site with an application’s wpcomvip GitHub repository code and the necessary VIP MU Plugins repository.

To do this, edit /config/config.yml in a file editor application. Add a new site in the sites: section of the file by copying and pasting the example below and replacing {site_name} with the corresponding slug of the application’s wpcomvip GitHub repository.

For example: If provisioning a new site with code from the repository at https://github.com/wpcomvip/vip-go-example, {site_name} would be replaced with the value vip-go-example.

  # Replace {site_name} with your GitHub repo slug
  {site_name}:
    repo: https://github.com/Varying-Vagrant-Vagrants/custom-site-template.git
    hosts:
      - {site_name}.test
    folders:
      # VIP Site repo
      public_html/wp-content/:
        git:
          repo: git@github.com:wpcomvip/{site_name}.git
          overwrite_on_clone: true
      # VIP Go MU Plugins
      public_html/wp-content/mu-plugins:
        git:
          repo: https://github.com/Automattic/vip-go-mu-plugins.git
          overwrite_on_clone: true
          hard_reset: true
          pull: true
    custom:
      wp_type: subdirectory
      wpconfig_constants:
        WP_ALLOW_MULTISITE: true
        MULTISITE: true
        SUBDOMAIN_INSTALL: false
        PATH_CURRENT_SITE: "/"
        SITE_ID_CURRENT_SITE: 1
        BLOG_ID_CURRENT_SITE: 1
        WP_DEBUG: true
        WP_DEBUG_LOG: true
        WP_DEBUG_DISPLAY: true
        SCRIPT_DEBUG: true
        VIP_GO_APP_ENVIRONMENT: local
        DISALLOW_FILE_EDIT: true
        DISALLOW_FILE_MODS: true
        AUTOMATIC_UPDATER_DISABLED: true
        DOMAIN_CURRENT_SITE: "{site_name}.test"
      admin_user: "{admin_username}"
      admin_password: "{admin_password}"
      admin_email: "admin@{site_name}.test"

Replace the values for {admin_username} and {admin_password} with new values chosen by the developer setting up the local environment. This step is a security precaution to prevent default administrator user credentials from possibly being imported from a local development environment to a production environment. As an added security precaution, code in VIP MU plugins will block login attempts made by the admin username and display the notice: Logins are restricted for that user. Please try a different user account.

After edits to the /config/config.yml are complete, VVV will need to be re-provisioned by running the command vagrant provision. If VVV is not already up and running, re-provision with the command vagrant up --provision.

Test the new VVV site

Before working on the final VIP configurations, confirm that the site has been successfully created and the WordPress Admin dashboard can be accessed by logging in to {site_name}.test/wp-admin/ with the user credentials that were added in the /config/config.yml file. To test the install please do the following:

  • Confirm the “VIP” menu is found in the left-hand navigation panel of the admin. This indicates that the VIP MU Plugins successfully provisioned.
  • Check that the expected themes and plugins are listed on the themes and plugins dashboards. This indicates that the application’s repository code was successfully provisioned.

Final VIP configurations

  1. Set up the object cache: In order to use object cache in a local environment, it is necessary to create a symbolic link to the file at /mu-plugins/drop-ins/object-cache/object-cache-stable.php from the root of the /wp-content directory:
    • in the terminal, cd into the /wp-content directory.
    • Run the symlink command: 
      ln -s /mu-plugins/drop-ins/object-cache/object-cache-stable.php object-cache.php
  2. Include the VIP config file: As a final step, add the following code to the wp-config.php file directly above this line:
    /* That's all, stop editing! Happy blogging. */.
// Load the VIP config file
if ( file_exists( __DIR__ . '/wp-content/vip-config/vip-config.php' ) ) {
	require_once( __DIR__ . '/wp-content/vip-config/vip-config.php' );
}

Read more about the VIP config file and the object cache.

Using WP-CLI on VVV

Refer to VVV’s documentation for instructions on using WP-CLI from the virtual machine.

Last updated: December 22, 2023

Relevant to

  • WordPress