Magento 2.0.18 is the final 2.0.x release. After March 2018, Magento 2.0.x will no longer receive security patches, quality fixes, or documentation updates.
To maintain your site's performance, security, and PCI compliance, upgrade to the latest version of Magento.

Customize base directory paths (MAGE_DIRS)

Introduction to Magento base directory paths

The MAGE_DIRS environment variable enables you to specify custom base directory paths and fragments of base URLs that are used by the Magento application to build absolute paths to various files or for generating URLs.


Specify an associative array where keys are constants from \Magento\App\Filesystem\DirectoryList and values are absolute paths of directories or their URL paths, respectively.

You can set MAGE_DIRS in any of the following ways:

	use Magento\Framework\App\Filesystem\DirectoryList;
	use Magento\Framework\App\Bootstrap;
	require __DIR__ . '/app/bootstrap.php';
	$params = $_SERVER;
	$params[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS] = [
       DirectoryList::CACHE => [DirectoryList::PATH => '/mnt/nfs/cache'],
       DirectoryList::MEDIA => [DirectoryList::PATH => '/mnt/nfs/media', DirectoryList::URL_PATH => ''],

	$params[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS] = [
	DirectoryList::PUB => [DirectoryList::URL_PATH => ''],	
	DirectoryList::MEDIA => [DirectoryList::URL_PATH => 'media'],
	DirectoryList::STATIC_VIEW => [DirectoryList::URL_PATH => 'static'],
	DirectoryList::UPLOAD => [DirectoryList::URL_PATH => 'media/upload'],
	$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
	/** @var \Magento\Framework\App\Http $app */
	$app = $bootstrap->createApplication('Magento\Framework\App\Http');

The preceding example sets paths for [cache] and [media] directories to /mnt/nfs/cache and /mnt/nfs/media, respectively.