Home

Awesome

Virtual Machine for Magento2

vagrant install-git install-composer mount release license

Supported system:<br> windows apple linux

Supported release:<br> v2.1.* v2.2.* v2.3.* v2.4.*

technical-stack<br>

associate-developer

Requirements

Virtualbox

VirtualBox is an open source virtualizer, an application that can run an entire operating system within its own virtual machine.<br> Stable version >= 5.2.0

  1. Download the installer for your laptop operating system using the links below.
  2. Run the installer, choosing all the default options.
    • Windows: Grant the installer access every time you receive a security prompt.
    • Mac: Enter your admin password.
    • Linux: Enter your user password if prompted.
  3. Reboot your laptop if prompted to do so when installation completes.
  4. Close the VirtualBox window if it pops up at the end of the install.

Vagrant

Vagrant is an open source command line utility for managing reproducible developer environments.<br> Stable version >= 2.2.0

  1. Download the installer for your laptop operating system using the links below.
  2. Reboot your laptop if prompted to do so when installation completes.

Configurations

Related guide

Pre-installation

⚠ This vagrant installation is non-interactive: DO NOT USE SSH KEY WITH PASSPHRASE.<br> If your ssh key has been created with a passphrase, please create another one.

SystemSteps
Windows1. Open UEFI BIOS and make sure virtualization is turned 'on'<br>2. Open powershell as administrator and run: Add-MpPreference -ExclusionProcess winnfsd.exe<br>3. Open C:\Windows\System32\drivers\etc\hosts as administrator then add network_ip and magento_url<br>Default values would be: 192.168.60.0 dev.magento.com
MacOs1. To avoid issue with guest additions, run:<br> sudo apt install linux-headers-$(uname -r)
Linux1. To install NFS properly, run:<br> sudo apt install nfs-kernel-server
Linux/MacOS2. Open /etc/hosts as sudo then add network_ip and magento_url<br>Default values would be: 192.168.60.0 dev.magento.com

Installation

  1. Clone this project: git clone git@github.com:zepgram/magento2-fast-vm.git
  2. Copy/past: ssh.example rename it ssh then put your id_rsa and id_rsa.pub keys
  3. Copy/past: config.yaml.example rename it config.yaml<br>Then customize configurations according to Yaml config overview
  4. If you want to import an existing database: create a compressed sql dump and name it db-dump.sql.gz.<br>You must also fill crypt_key in config.yaml
  5. To start install run: vagrant up (duration: ~20 minutes)
  6. Finally, run: vagrant ssh to access guest machine

Yaml config overview

Parent NodeNameDefault ValueAllowed ValueIs optionalDescription
vmconfmachine_nameVagrant Magento 2stringnoVagrant machine name
network_ip192.168.60.0IP addressnoAccessible IP address /etc/hosts
host_namezepgramstringnoVirtual host name
memory4096numbernoRAM allocated
cpus1numbernoCPU allocated
mountnfsnfs / rsync / defaultnoMount strategy
pathrootapp / rootnoMount whole directory or app/ only
provisionallall / system / magentonoDefine script provision
composerusernamemagentoUsernameKeystringno<a href="https://marketplace.magento.com/customer/accessKeys/" target="_blank">Composer auth user</a>
passwordmagentoPasswordKeystringno<a href="https://marketplace.magento.com/customer/accessKeys/" target="_blank">Composer auth password</a>
gitnameJohn DoestringyesGit user name
emailjohn@doe.comemailyesGit user email
hostgithub.comurlyesGit host server name
repositoryssh://git@github.com:%.gitgit repositoryyesDefine repository to clone
magentourldev.magento.comurlnoMagento site host name
sourcecomposercomposer / (master/develop..)noDefine source installation. On git install set the branch name to clone.
editioncommunitycommunity / enterprisenoMagento project edition
version2.4.5>=2.2noMagento version release
php_versiondefaultdefault / 7.x / 8.xnoPHP version
sampletruetrue / falsenoInstall sample data
modedeveloperdeveloper / productionnoMagento execution mode
currencyUSD<a href="https://en.wikipedia.org/wiki/ISO_4217#Active_codes" target="_blank">ISO 4217</a>noDefault currency
languageen_US<a href="https://www.iso.org/iso-639-language-codes.html" target="_blank">ISO 639-1</a> + <a href="https://www.iso.org/iso-3166-country-codes.html" target="_blank">ISO 3166</a>noDefault language
time_zoneAmerica/New_York<a href="https://www.php.net/manual/en/timezones.php" target="_blank">timezone</a>noDefault timezone
crypt_key-stringyesCrypt key form app/etc/env.php for db-dump.sql.gz (db import)
search_engineopensearchopensearch / elasticsearchfalseSearch engine for catalog search
disable_two_factor_authtruetrue / falsefalseDisable 2 factor authentication for admin access

Path

Mount options

RSYNC

Only useful on path set to root.<br>

NFS

Recommended for root and app path.<br> The most stable option, config has been made to ensure compliance with all OS. Less performant than rsync but files are perfectly shared between guest and host machine.

See NFS option

DEFAULT

It can be used with app path if you encountered any issue with NFS and rsync mount.

See basic usage

Extra provisions

You can add extra shell provisions.<br> Those provisions will be executed on pre-defined sequences:

  1. extra/001-env.sh his purpose is to provide extra environment variables or extra package, executed after script 001-system-env.sh
  2. extra/100-pre-build.sh define your specific system configuration before installation, executed after script 100-magento-pre.sh
  3. extra/120-post-build.sh you can execute magento command in this sequence, executed after script 120-magento-post.sh

System usage

Permission

Magento file system owner is configured for vagrant user, it means all commands in magento project must be executed by this user.<br> By default command line vagrant ssh will log you as vagrant user.<br>

Command line

Cron

Enable cron:

./bin/magento cron:install

Disable cron:

./bin/magento cron:remove

Configuration

Package & Software

Access

Mysql

Percona server 8.0 is now installed for Magento >=2.4.0<br> Lower versions are handled foreach existing Magento versions.

PHP

PHP 8.2 is now installed by default for Magento >=2.4.6<br> Lower versions are handled foreach existing Magento versions.

Composer

Composer v2 is now installed by default for Magento >=2.4.2<br> Lower versions are handled foreach existing Magento versions.

Elasticsearch

Version 8.4.x of Elasticsearch is now available for Magento 2.4.6<br> Version 7.6.x of Elasticsearch is available for version between 2.4.0 and 2.4.5<br> Lower versions are handled foreach existing Magento versions<br> Otherwise, you can also completely disable elasticsearch by installing this module: https://github.com/zepgram/module-disable-search-engine

Opensearch

Version 2.5.x is now available for Magento 2.4.6<br> Elasticsearch will be installed by default on lower Magento versions.

Issues

Windows 10

There is a known issue with composer installation on windows 10.<br> This issue could not be solved yet, and has already been reported 2 times.<br>

To solve this, I recommend to set mount option to "rsync", then after full installation you should be able to fall back to NFS.

Others

If you have trouble during installation please open a new issue on this GitHub repository.