Git Product home page Git Product logo

wp-multitenancy-add-site's Introduction

WordPress Multitenancy Add Site

Adds WordPress sites to WP Multitenancy Boilerplate.

Features

  • Improved directory structure
  • Easy WordPress configuration with environment and constants files
  • Environment variables with PHP dotenv
  • Enhanced security (separated web root and secure passwords with roots/wp-password-bcrypt)
  • WordPress multitenancy (a single instance of WordPress core, themes and plugins serving multiple sites)

Requirements

  • PHP 5.6+
  • Composer

Prerequisites

A WordPress instance installed with WP Multitenancy Boilerplate.

Installation

$ composer create-project handpressed/wp-multitenancy-add-site {directory}

$ cd {directory}

Replace {directory} with the name of your new WordPress project, e.g. its domain name.

Composer will symlink the existing WordPress instance added with WP Multitenancy Boilerplate in /var/opt/wp to web/wp (see Directory Structure).

Composer will also symlink /var/opt/wp/wp-content/themes to web/app/themes, /var/opt/wp/wp-content/plugins to web/app/plugins and /var/opt/wp/wp-content/mu-plugins to web/app/mu-plugins.

Configuration

Open the conf/.env file and add the new site's home URL (WP_HOME) and database credentials (DB_NAME, DB_USER, DB_PASSWORD). You can also define the database $table_prefix (default is wp_) if required.

Set the site's vhost document root to /path/to/{directory}/web.

Themes

Add themes in web/app/themes as you would for a normal WordPress install. You can use the WordPress admin to update them.

Plugins

WordPress Packagist is already registered in the composer.json file so any plugins from the WordPress Plugin Directory can easily be required.

To add a plugin, use composer require <namespace>/<packagename> from the command-line. If it's from WordPress Packagist then the namespace is always wpackagist-plugin, e.g.:

$ composer require wpackagist-plugin/jetpack:*

Whenever you add a new plugin or update WordPress core, run composer update to install your new packages.

Themes and plugins are installed in the symlinked themes and plugins directories in /var/opt/wp/wp-content and will be available to all multitenancy sites.

Note: Some plugins may make modifications to the core wp-config.php file. Any modifications to wp-config.php that are needed by an individual site should be moved to the site's conf/wp-constants.php file.

Constants

Put custom core, theme and plugin constants in conf/wp-constants.php.

Directory Structure

├── composer.json             → Manage versions of WordPress, plugins and dependencies
├── conf                      → WordPress configuration files
│   ├── .env       	      → WordPress environment variables (WP_HOME, DB_NAME, DB_USER, DB_PASSWORD required)
│   ├── wp-constants.php      → Custom core, theme and plugin constants
│   ├── wp-env-config.php     → Primary WordPress config file (wp-config.php equivalent)
│   └── wp-salts.php          → Authentication unique keys and salts (auto generated)
├── vendor                    → Composer packages (never edit)
└── web                       → Web root (vhost document root)
    ├── app                   → wp-content equivalent
    │   ├── mu-plugins        ↔ Must-use plugins symlinked to /var/opt/wp/wp-content/mu-plugins
    │   ├── plugins           ↔ Plugins symlinked to /var/opt/wp/wp-content/plugins
    │   ├── themes            ↔ Themes symlinked to /var/opt/wp/wp-content/themes
    │   └── uploads           → Uploads
    ├── index.php             → Loads the WordPress environment and template (never edit)
    └── wp                    ↔ WordPress core symlinked to /var/opt/wp (never edit)
    	└── wp-config.php     → Required by WordPress - loads conf/wp-env-config.php (never edit)

denotes a symlink.

See Also

WordPress Substratum

Credit

Inspired by roots/bedrock and wpscholar/wp-skeleton.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.