Before making any changes, ensure you have a full backup of your WordPress files and database.
Install and activate the Tenancy plugin, this will create the required database tables and admin area on the main site ( referred to as the Landlord site ).
To activate the multi-tenant functionality within your setup, follow these steps:
config
directory within your application’s installation.tenancy.php
file located in this directory to adjust your tenancy settings.ALLOW_MULTITENANT
to true
:
define('ALLOW_MULTITENANT', true);
define('LANDLORD_UUID', 'your-landlord-uuid-here');
Replace 'your-landlord-uuid-here'
with your actual landlord UUID.
To properly set up the Landlord environment for your multi-tenant application installation, follow these steps to ensure a proper database connection:
Backup Your Existing Environment File: Before making any changes, it’s crucial to back up your current .env
file.
Create a New .env
File: In the root directory of application installation, create a new .env
file. This file will store the environment-specific configurations for the Landlord database (settings in this env file are discarded after initial setup of the Landlord).
Configure Landlord Database Settings: Inside the newly created .env
file, input the following configuration settings. These settings should match those of the main site (also referred to as the Landlord site) where the Tenancy plugin is installed. Adjust the values to reflect your specific Landlord database credentials:
# Landlord Database Configuration
LANDLORD_DB_NAME= # The name of your Landlord database
LANDLORD_DB_USER= # The username for your Landlord database access
LANDLORD_DB_PASSWORD= # The password for your Landlord database access
LANDLORD_DB_HOST=localhost # The hostname for your Landlord database server, typically 'localhost'
LANDLORD_DB_PREFIX=wp_lo6j2n6v_ # The prefix for your Landlord database tables, adjust as needed
This document provides a comprehensive guide to the architecture and operational flow of our Multi-Tenant Application, introduced in version 0.8.0. The platform is designed to support multiple tenants (websites), each with its unique configuration and customization capabilities, on a shared infrastructure.
Note: The uploads directory will be set to
/public/app/tenant/a345ea9515c/uploads
. Make sure to transfer or replicate your site files to this new directory. This setup uses thetenant_id
for isolated file storage per tenant.
.env
: "path/site/a345ea9515c/.env"
config.php
: "path/site/a345ea9515c/config.php"
The framework supports distinct configurations for each tenant, enabling customized settings per site within a multi-tenant environment:
path/site/{tenant_id}/.env
, it stores environment-specific variables.path/site/{tenant_id}/config.php
, this file contains PHP configuration file overrides.config.php
.This approach ensures a balance between customization for individual tenants and consistency across the framework.
.env
file can contain specific environment variables, such as:
APP_TENANT_ID=a345ea9515c
APP_TENANT_SECRET
for additional security.env('APP_TENANT_ID')
within the application to access and modify configurations dynamically for each tenant. It is also set as APP_TENANT_ID
constant during initialization steps.wp-content/tenant/{tenant_id}/uploads
. Depending on the framework’s setup, the default path might vary, but it generally follows the format app/tenant/{tenant_id}/uploads
.app.php
file and the framework’s composer.json
.IS_MULTITENANT
constant aids in configuring resource availability and is particularly useful during tenant migrations or when converting a tenant to a standalone installation.While the Multi-Tenant Application offers efficient resource sharing and management, it’s crucial to assess its suitability based on your specific needs:
[!CAUTION]
Thoroughly evaluate your use case before adopting a multi-tenant architecture. For certain scenarios, a single-tenant or dedicated solution might be more appropriate.
The Multi-Tenant Application excels in scenarios prioritizing efficient management and shared infrastructure. It’s an ideal choice if these factors align with your project goals.
Every project is unique, so it’s important to choose an architecture that fits your specific requirements and constraints.
Note: This documentation is continually evolving, and we welcome community contributions and feedback. If you have suggestions or notice areas needing improvement, please contribute via pull requests or contact our development team. Your input is invaluable in refining this guide.