<p><strong>Update:</strong> This has been updated for the newer default Craft project structure, which includes a <a href="https://github.com/craftcms/craft/blob/main/bootstrap.php" rel="nofollow noreferrer"><code>bootstrap.php</code> file</a> that’s shared between the <code>craft</code> executable and <code>web/index.php</code>.</p>
<hr />
<p>There are various ways to go about this. Here’s a few:</p>
<h2>Option 1: Keep each site completely contained</h2>
<p>If you are able to keep each installation in its own directory, each with its own web root, that would be ideal, since you could develop and deploy each site individually:</p>
<pre><code>site-a/
  .env
  bootstrap.php
  composer.json
  composer.lock
  craft
  config/...
  modules/...
  templates/...
  vendor/...
  web/...
site-b/
  .env
  bootstrap.php
  composer.json
  composer.lock
  craft
  config/...
  modules/...
  templates/...
  vendor/...
  web/...
</code></pre>
<h2>Option 2: Share the web root</h2>
<p>If the sites must share the same web root, but you still want to generally think of them as separate installations, then you can at least keep each of the project’s non-web files together:</p>
<pre><code>site-a/
  .env
  bootstrap.php
  composer.json
  composer.lock
  craft
  config/...
  modules/...
  templates/...
  vendor/...
site-b/
  .env
  bootstrap.php
  composer.json
  composer.lock
  craft
  config/...
  modules/...
  templates/...
  vendor/...
web/
  index.php &lt;-- for site-a
  ...
  b/
    index.php &lt;-- for site-b
    ...
</code></pre>
<p>Then the only constant you’ll need to worry about is loading the right <code>bootstrap.php</code> file within each <code>index.php</code> file:</p>
<pre class="lang-php prettyprint-override"><code>// web/index.php

// Load shared bootstrap
require dirname(__DIR__) . '/site-a/bootstrap.php';
</code></pre>
<pre class="lang-php prettyprint-override"><code>// web/b/index.php

// Load shared bootstrap
require dirname(__DIR__, 2) . '/site-b/bootstrap.php';
</code></pre>
<h2>Option 3: Share the Composer and module files, too</h2>
<p>If it makes sense to just have one shared set of Composer files (<code>composer.json</code>, <code>composer.lock</code>, and <code>vendor/</code>) and <code>modules/</code> folder (they are inseparable since the module files get autoloaded by composer.json), you can use this structure:</p>
<pre><code>composer.json
composer.lock
modules/
vendor/
site-a/
  .env
  bootstrap.php
  craft
  config/...
  templates/...
site-b/
  .env
  bootstrap.php
  craft
  config/...
  templates/...
web/
  index.php &lt;-- for site-a
  ...
  b/
    index.php &lt;-- for site-b
    ...
</code></pre>
<p>You’ll need to make the same changes to your <code>index.php</code> files as in option 2, as well as modify the <code>CRAFT_VENDOR_PATH</code> constant in your <code>bootstrap.php</code> files (since <code>vendor/</code> no longer lives alongside the site-specific files).</p>
<pre class="lang-php prettyprint-override"><code>// web/index.php

// Load shared bootstrap
require dirname(__DIR__) . '/site-a/bootstrap.php';
</code></pre>
<pre class="lang-php prettyprint-override"><code>// web/b/index.php

// Load shared bootstrap
require dirname(__DIR__, 2) . '/site-b/bootstrap.php';
</code></pre>
<pre class="lang-php prettyprint-override"><code>// site-a/bootstrap.php

define('CRAFT_VENDOR_PATH', dirname(__DIR__) . '/vendor');
</code></pre>
<pre class="lang-php prettyprint-override"><code>// web/b/index.php

define('CRAFT_VENDOR_PATH', dirname(__DIR__, 2) . '/vendor');
</code></pre>

CC BY-SA 4.0
2021-03-01T09:03:38.827Z
Thanks Brandon. Very helpful. It’s helped me understand that Option 1, which I was already doing, is probably the best way to keep going.
Jonathan Schofield
CC BY-SA 4.0
2021-02-28T14:40:06.027Z
2023-05-31T13:56:41.173Z
2023-05-31T13:56:41.173Z
Brandon Kelly
<p>You could have multiple independent Craft CMS installs in separate directories, or have a single Craft instance but use mulit-site to have different domains pointed to a single Craft install.</p>
<p><a href="https://craftcms.com/docs/3.x/sites.html" rel="nofollow noreferrer">https://craftcms.com/docs/3.x/sites.html</a></p>

CC BY-SA 4.0
2021-03-01T09:02:09.497Z
Thanks James. The multi-site option is not appropriate for my context. I’m going to get my head round Brandon’s reply.
Jonathan Schofield
CC BY-SA 4.0
2021-02-27T20:07:09.040Z
2021-02-27T20:07:09.040Z
James White
<p>I want to have multiple instances of Craft, ideally running inside the same cPanel account root.</p>
<p>I note from the doc on <a href="https://craftcms.com/docs/3.x/directory-structure.html" rel="nofollow noreferrer">Directory structure</a> that there are separate config path variables that can be set for:</p>
<ul>
<li>CRAFT_CONFIG_PATH</li>
<li>CRAFT_STORAGE_PATH</li>
<li>CRAFT_TEMPLATES_PATH</li>
<li>CRAFT_VENDOR_PATH</li>
</ul>
<p>If these system assets for a given Craft instance are in a per instance child folder above web root, what are the implications for the location and variants of:</p>
<ul>
<li>modules</li>
<li>.env</li>
<li>composer.json</li>
<li>composer.lock</li>
<li>craft</li>
</ul>
<p>Should these all be duplicated per instance into the same child folder as well?</p>

<installation><configuration>
Multiple instances of Craft in same hosting account root
# Multiple instances of Craft in same hosting account root

(Asked by: username_0 on 2021-02-27)

I want to have multiple instances of Craft, ideally running inside the same cPanel account root.

I note from the doc on [Directory structure](https://craftcms.com/docs/3.x/directory-structure.html) that there are separate config path variables that can be set for:

* CRAFT\_CONFIG\_PATH
* CRAFT\_STORAGE\_PATH
* CRAFT\_TEMPLATES\_PATH
* CRAFT\_VENDOR\_PATH

If these system assets for a given Craft instance are in a per instance child folder above web root, what are the implications for the location and variants of:

* modules
* .env
* composer.json
* composer.lock
* craft

Should these all be duplicated per instance into the same child folder as well?

**Tags:** installation, configuration

---

## 2 answers

### Answer by username_1 on 2021-02-28. Score: 3 | Accepted answer

Update: This has been updated for the newer default Craft project structure, which includes a bootstrap.php file that’s shared between the craft executable and web/index.php.

There are various ways to go about this. Here’s a few:
Option 1: Keep each site completely contained
If you are able to keep each installation in its own directory, each with its own web root, that would be ideal, since you could develop and deploy each site individually:
site-a/
  .env
  bootstrap.php
  composer.json
  composer.lock
  craft
  config/...
  modules/...
  templates/...
  vendor/...
  web/...
site-b/
  .env
  bootstrap.php
  composer.json
  composer.lock
  craft
  config/...
  modules/...
  templates/...
  vendor/...
  web/...

Option 2: Share the web root
If the sites must share the same web root, but you still want to generally think of them as separate installations, then you can at least keep each of the project’s non-web files together:
site-a/
  .env
  bootstrap.php
  composer.json
  composer.lock
  craft
  config/...
  modules/...
  templates/...
  vendor/...
site-b/
  .env
  bootstrap.php
  composer.json
  composer.lock
  craft
  config/...
  modules/...
  templates/...
  vendor/...
web/
  index.php <-- for site-a
  ...
  b/
    index.php <-- for site-b
    ...

Then the only constant you’ll need to worry about is loading the right bootstrap.php file within each index.php file:
// web/index.php

// Load shared bootstrap
require dirname(__DIR__) . '/site-a/bootstrap.php';

// web/b/index.php

// Load shared bootstrap
require dirname(__DIR__, 2) . '/site-b/bootstrap.php';

Option 3: Share the Composer and module files, too
If it makes sense to just have one shared set of Composer files (composer.json, composer.lock, and vendor/) and modules/ folder (they are inseparable since the module files get autoloaded by composer.json), you can use this structure:
composer.json
composer.lock
modules/
vendor/
site-a/
  .env
  bootstrap.php
  craft
  config/...
  templates/...
site-b/
  .env
  bootstrap.php
  craft
  config/...
  templates/...
web/
  index.php <-- for site-a
  ...
  b/
    index.php <-- for site-b
    ...

You’ll need to make the same changes to your index.php files as in option 2, as well as modify the CRAFT_VENDOR_PATH constant in your bootstrap.php files (since vendor/ no longer lives alongside the site-specific files).
// web/index.php

// Load shared bootstrap
require dirname(__DIR__) . '/site-a/bootstrap.php';

// web/b/index.php

// Load shared bootstrap
require dirname(__DIR__, 2) . '/site-b/bootstrap.php';

// site-a/bootstrap.php

define('CRAFT_VENDOR_PATH', dirname(__DIR__) . '/vendor');

// web/b/index.php

define('CRAFT_VENDOR_PATH', dirname(__DIR__, 2) . '/vendor');

> **Comments:**
> **username_0**: Thanks Brandon. Very helpful. It’s helped me understand that Option 1, which I was already doing, is probably the best way to keep going.  

---

### Answer by username_2 on 2021-02-27. Score: 1

You could have multiple independent Craft CMS installs in separate directories, or have a single Craft instance but use mulit-site to have different domains pointed to a single Craft install.

<https://craftcms.com/docs/3.x/sites.html>

> **Comments:**
> **username_0**: Thanks James. The multi-site option is not appropriate for my context. I’m going to get my head round Brandon’s reply.  

---

