Sail Knowledgebase

Using Namespaces and Environments in Sail CLI

Namespaces and environments in Sail CLI allow you to deploy and work with multiple WordPress applications in the same provisioned environment.

If you like Sail, consider sponsoring us via GitHub!

Environments and Namespaces

An environment is a collection of cloud resources, dedicated to running your WordPress applications. Environments are completely isolated from one another.

A namespace allows users to deploy a separate WordPress application into an existing environment, under a different directory.

Note that namespaces in a single environment are not isolated. They typically share a Linux user, the php-fpm pools, Nginx configurations, database servers, etc. If you are looking for isolation, we recommend using a separate environment instead.

Using Namespaces in Sail CLI

By default, when a new project is created with sail init, a brand new environment is provisioned for that application, and the application itself is deployed under the default namespace:

cd path/to/primary
sail init

If you'd like to add a secondary application to the same environment, use the --namespace and --environment flags:

cd path/to/secondary
sail init --namespace=secondary --environment=path/to/primary

This will use the same environment as the primary application, and provision a new WordPress application under the secondary namespace.

Note that most Sail commands will operate under the current namespace, so for example sail backup inside the path/to/secondary Sail project directory, will perform a backup of the secondary namespace only.

Destroying Namespaces and Environments

If you'd like to delete a namespace, from the project directory where the namespace was created, simply run the usual:

sail destroy

If you'd like to destroy the entire environment, you can add the --environment flag. This will destroy all namespaces and shut down the servers.

If you're stuck and need help with namespaces, environments or Sail CLI in general please visit the getting help section.