Set up Craft 3 when the craft folder is above public_html on shared hosting
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');