I have installed Magento 2 in ubuntu guest / windows host in vagrant, but it is extremely slow. I think a simple change can improve performance, How can I move my Magento's "var" directory to "/tmp/var" of ubuntu?
1 Answer
This is very likely going to change a bit before GA (a part of the reason it is not documented yet), but there is a short term solution if important to you. You can either in the index.php file incorporate:
use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\Bootstrap; require __DIR__ . '/app/bootstrap.php'; $customDirs = [ DirectoryList::CACHE => [DirectoryList::PATH => '/mnt/nfs/cache'], DirectoryList::MEDIA => [DirectoryList::PATH => '/mnt/nfs/media', DirectoryList::URL_PATH => ''] ]; $bootstrap = Bootstrap::create(BP, [Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS => $customDirs] + $_SERVER); /** @var \Magento\Framework\App\Http $app */ $app = $bootstrap->createApplication('Magento\Framework\App\Http'); $bootstrap->run($app); Or you can set it in an Apache environment variable.
<VirtualHost 127.0.0.1:80> DocumentRoot "/var/www/example.com" ServerName example.com SetEnv "MAGE_DIRS[cache][path]" "/home/www/appData/caches/example.com" </VirtualHost> If you look in https://github.com/magento/magento2/tree/develop/lib/internal/Magento/Framework/App/Filesystem you can see a list of the various constants for path settings that can be overridden.
But a reminder that there may be changes in this area before GA. But I believe the above will work in beta1 and beta2.
- 1both solutions only works for webapplication entry point. if you use the bin/console all commands will not have the cache file changesZFNerd– ZFNerd2018-10-22 10:37:57 +00:00Commented Oct 22, 2018 at 10:37