<p>Finally figured out how to edit this index.php file if you're not able to point your document root to the web folder, or if you are forced to put craft in the folder private_html that shared hosters tend to use (or any other given structure above root)</p>

<p>In the index.php file you only need to edit this line:</p>

<pre><code>define('CRAFT_BASE_PATH', dirname(__DIR__));
</code></pre>

<p>If your index.php file resides in public_html, <code>__DIR__</code> will be something like:</p>

<pre><code>/home/hostname.com
</code></pre>

<p>To point the index.php to the hidden craft folder, above root, in my case I had to add the folders after the CRAFT_BASE_PATH:</p>

<pre><code>define('CRAFT_BASE_PATH', dirname(__DIR__).'/private_html/craft');
</code></pre>

CC BY-SA 4.0
2019-08-30T02:20:50.137Z
One hopefully useful tip: when moving files around, make sure that the hidden files (esp. .env) are getting copied/moved other.  500 error would be thrown if the .env file is missing.
biko
CC BY-SA 3.0
2018-04-09T12:25:24.077Z
2018-04-09T12:25:24.077Z
noregt
<p>I'm trying to setup Craft 3 on a shared host. It succeeds when I place all files in the public directory and then go to /web. </p>

<p>But if I move the craft files to the folder /private_html/craft and the web files in /public_html it won't work (error 500). Do I need to edit the index.php file after all (not mentioned in the installation docs)?</p>

<p>Tried setting the index.php lines to ../private_html/craft/vendor and ../private_html/craft/.env, but no luck. I get the feeling the index.php needs a pointer where the craft folder resides?</p>

<pre><code>&lt;?php

// Set path constants
define('CRAFT_BASE_PATH', dirname(__DIR__));
define('CRAFT_VENDOR_PATH', CRAFT_BASE_PATH.'../private_html/craft/vendor');

// Load Composer's autoloader
require_once CRAFT_VENDOR_PATH.'../private_html/craft/vendor/autoload.php';

// Load dotenv?
if (file_exists(CRAFT_BASE_PATH.'../private_html/craft/.env')) {
    (new Dotenv\Dotenv(CRAFT_BASE_PATH))-&gt;load();
}

// Load and run Craft
define('CRAFT_ENVIRONMENT', getenv('ENVIRONMENT') ?: 'production');
$app = require CRAFT_VENDOR_PATH.'../private_html/craft/vendor/craftcms/cms/bootstrap/web.php';
$app-&gt;run();
</code></pre>

CC BY-SA 3.0
2018-04-07T09:37:58.387Z
Have you tried ../../ instead of ../ ?
tom
CC BY-SA 3.0
2018-04-09T07:33:43.420Z
No difference I'm afraid...
noregt
<craft3><installation>
Set up Craft 3 when the craft folder is above public_html on shared hosting
# Set up Craft 3 when the craft folder is above public_html on shared hosting

(Asked by: username_0 on 2018-04-06)

I'm trying to setup Craft 3 on a shared host. It succeeds when I place all files in the public directory and then go to /web. 
But if I move the craft files to the folder /private_html/craft and the web files in /public_html it won't work (error 500). Do I need to edit the index.php file after all (not mentioned in the installation docs)?
Tried setting the index.php lines to ../private_html/craft/vendor and ../private_html/craft/.env, but no luck. I get the feeling the index.php needs a pointer where the craft folder resides?
load();
}

// Load and run Craft
define('CRAFT_ENVIRONMENT', getenv('ENVIRONMENT') ?: 'production');
$app = require CRAFT_VENDOR_PATH.'../private_html/craft/vendor/craftcms/cms/bootstrap/web.php';
$app->run();

**Tags:** craft3, installation
> **Comments:**
> **username_1**: Have you tried ../../ instead of ../ ?  
> **username_0**: No difference I'm afraid...  

---

## 1 answers

### Answer by username_0 on 2018-04-09. Score: 5 | Accepted answer

Finally figured out how to edit this index.php file if you're not able to point your document root to the web folder, or if you are forced to put craft in the folder private_html that shared hosters tend to use (or any other given structure above root)
In the index.php file you only need to edit this line:
define('CRAFT_BASE_PATH', dirname(__DIR__));

If your index.php file resides in public_html, __DIR__ will be something like:
/home/hostname.com

To point the index.php to the hidden craft folder, above root, in my case I had to add the folders after the CRAFT_BASE_PATH:
define('CRAFT_BASE_PATH', dirname(__DIR__).'/private_html/craft');

> **Comments:**
> **username_2**: One hopefully useful tip: when moving files around, make sure that the hidden files (esp. .env) are getting copied/moved other.  500 error would be thrown if the .env file is missing.  

---

