VirtualBox is an open source virtualizer, an application that can run an entire operating system within its own virtual machine.
Stable version >= 5.1.10
- Download the installer for your laptop operating system using the links below.
- Run the installer, choosing all of the default options.
- Windows: Grant the installer access every time you receive a security prompt.
- Mac: Enter your admin password.
- Linux: Enter your root password if prompted.
- Reboot your laptop if prompted to do so when installation completes.
- Close the VirtualBox window if it pops up at the end of the install.
Vagrant is an open source command line utility for managing reproducible developer environments.
Stable version >= 1.9.5
- Download the installer for your laptop operating system using the links below.
- Reboot your laptop if prompted to do so when installation completes.
⚠ DO NOT USE SSH KEY WITH PASSPHRASE, this vagrant installation is non-interactive.
If your ssh key has been created with a passphrase, please create an other one and add it to your git account.
- Clone this project:
git clone [email protected]:zepgram/magento2-fast-vm.git magento2
- On linux only, run:
sudo apt install nfs-kernel-server
- Copy and past
ssh.example
, rename itssh
and put your id_rsa and id_rsa.pub keys. - Copy and past
config.yaml.example
, rename itconfig.yaml
and change user variables as explained in Yaml options overview. - Add vm_conf[network_ip] and magento[url] in your hosts file. Add 127.0.0.1 localhost if it's not already the case
C:\Windows\System32\drivers\etc\hosts
on Windows,/etc/hosts
on Linux/macOS.
For default values:192.168.200.50 dev.magento.com
- On windows 10 start your terminal as administrator and uncomment option
# v.gui=true
in vagrant file, you can disable it after first installation - Run:
vagrant up
in your terminal, installation start! (duration: ~20 minutes) - Once installation is finished run:
vagrant ssh
to access to shell machine
You can add your custom shell provisioners which will be executed on pre-defined sequences:
extra/001-env.sh
his purpose is to provide extra environment variables or extra package, executed onsystem-env.sh
provisionextra/100-pre-build.sh
define your specific system configuration before installation, hook on magentopre-build.sh
provisionextra/120-post-build.sh
you can execute magento command in this sequence, executed on magentopost-build.sh
provision
- Vmconf
- machine_name: oracle virtual machine name (Vagrant Magento 2)
- network_ip: virtual machine ip (192.168.200.50)
- host_name: virtual machine host name (zepgram)
- memory: RAM of virtual machine (4096)
- cpus: CPU usage (2)
- nfs: enable NFS mount (true)
- mount:
- 'app' mount app directory /var/www/magento/app (drastically improve performance, making nfs option not necessary)
- 'root' mount whole directory /var/www/magento (require nfs option to keep good performance)
- provision: define shell provisionning sequence (all)
- 'all' run all provisionner files
- 'system' run only machine provisionner
- 'magento' run magento installation
- Composer
- username: magento access set your magento credentials (magentoUsernameKey)
- password: magento access set your magento credentials (magentoPasswordKey)
- Git (optional)
- name: git account username (John Doe)
- email: git account email ([email protected])
- host: set your git host server to add ssh key to "known hosts" (github.com)
- repository: clone your existing magento project (ssh://[email protected]:project-name.git)
- Magento
- url: magento site host name (dev.magento.com)
FI do not use .dev or .localhost as extension - source: define installation source (composer)
- 'composer' install magento source code from official composer repository
- 'git-branch-name' install magento project from your git repository based on defined branch (ex: master)
- edition: magento project edition, used only on composer source installation (community)
- 'community' install magento community edition
- 'enterprise' install magento enterprise edition
- version: set magento version and also define PHP version (2.3.0)
- sample: install sample data, used only on composer source installation (true)
- mode: magento mode (developer)
- currency: set currency (USD)
- language: set language (en_US)
- time_zone: set time zone (Europe/London)
- url: magento site host name (dev.magento.com)
- app directory: magento2 development must be provided in app directory, so mounting the entire project is not necessary according to documentation and best practice provided by magento. Furthermore, by mounting only this directory the virtual machine grants great performance: generated files and static content are not shared between guest and host machine.
- root directory: if you wish to mount the entire project you can, but I highly recommend you to enable NFS option to improve performance between guest and host machine.
Magento file system owner is configured for magento
user, it means all commands in magento project must be executed by this user.
Command line vagrant ssh
will log you as magento user by default.
- To logout and get back to vagrant user you can run
exit
- To login as magento user you can run
sudo su magento
orbash
- To re-apply magento permission you can run
permission
in command line Password for magento user ismagento
- magento (Magento CLI for your project)
- magento-cloud (Cloud-specific version of the Magento CLI)
- pestle (A collection of command line scripts for Magento 2 code generation)
- magerun (The swiss army knife for Magento developers)
- permission (Apply magento2 permissions on project)
After installation you can change magento statement.
Default mode is an installation statement, you can't switch to default mode if you choose a statement before.
Set magento to developer mode:
./bin/magento deploy:mode:set developer
Set magento to production mode:
./bin/magento deploy:mode:set production
Enable cron:
./bin/magento cron:install
Disable cron:
./bin/magento cron:remove
- php + requiered extensions
- curl
- git
- gitflow
- vim
- mariadb
- apache2
- redis-server
- composer
- magento-cloud CLI
- magento bash completion
- pestle
- magereun
- adminer
- grunt
- postfix
- mailcatcher
- Back-office
- url: magento[url]/admin
- user: admin
- pass: admin123
- Database
- user: vagrant
- pass: vagrant
- name: magento
- Mailcatcher
- url: [network_ip]:1080
- Adminer
- url: [network_ip]/adminer
- Phpinfo
- url: [network_ip]/php
To setup phpStorm configuration you can follow magento2 official documentation.
- In case of error with NFS mount downgrade to version 1.9.5. Problem is known and reported by vagrant community: hashicorp/vagrant#5424
- If you encountered an unexpected error during vagrant provisionning : set NFS option to false and run
vagrant provision
There is a major issue with windows 7 host machine:
When running vagrant up machine hangs, this problem is encountered with newest version of VirtualBox and Vagrant.
- First solution is to upgrade powershell to version 4.0 by downloading WFM 4.0.
The file setup is Windows6.1-KB2819745 - Second solution is to downgrade to 1.9.5 for vagrant and 5.1.10 for VirtualBox
You can found more about this issue on github.
- If you have trouble during installation please open a new issue on this git repository.