The current Vagrant configuration aims to solve performance issues of Magento installed on Virtual Box, when the host is Windows. See explanation of the proposed solution.
With current configuration Vagrant will:
- Run Ubuntu box
- Install and configure all software necessary for Magento 2
- Install all necessary libraries
- Install the Magento 2 application
If you never used Vagrant before, read Vagrant Docs
- Vagrant is installed and available globally in command line
- VirtualBox
- Composer is installed and is available globally in command line
- Make sure you have SSH keys generated and associated with your github account, see manual. :information_source: You can use another way of getting codebase instead of cloning, it does not matter for successful installation.
-
Run in command line from the directory which contains your projects:
git clone git@github.com:paliarush/vagrant-magento.git vagrant-magento git clone git@github.com:magento/magento2.git magento2ce cd magento2ce mkdir -p var/generation composer install --prefer-source cd ../vagrant-magento vagrant up
-
At some point you will be prompted to set up synchronization with PHP Storm and install Magento using:
vagrant provision --provision-with install_magento
###To reinstall Magento To save some time and get clear Magento installation, you can skip installation of software like web server or php. The following command will clear Magento DB, Magento caches and reinstall Magento instance.
Go to 'vagrant-magento' created earlier and run in command line:
vagrant provision --provision-with install_magento
Upon a successful installation, you'll see the location and URL of the newly-installed Magento 2 application:
Magento application was deployed in /var/www/magento2 and installed
Access front store at http://${HOST}/
Access admin panel at http://${HOST}/${backend_frontame}/
/var/www/magento2
is a path to your Magento installation on the VM.
db host: localhost (not accessible remotely)
db user/password: magento/magento
db name: magento
also available db user/password: root/password
Magento admin user/password: admin/123123q
The hostname of the Magento application is derived from hostname of the VM defined in the Vagrantfile
:
config.vm.hostname = "magento2.vagrant"
Change this value in the Vagrantfile
if you want to use different hostname.
If Vagrant can't determine hostname of the VM for some reason, it will use its IP address (also specified in Vagrantfile
).
Also make sure you update your system hosts
file with a record that links the IP address and hostname of the VM.
For the following Vagrantfile
...
config.vm.network :private_network, ip: '192.168.10.11'
config.vm.hostname = "magento2.vagrant"
...
Specify the following in your hosts
file:
192.168.10.11 magento2.vagrant
Be aware that you may encounter GitHub limits on the number of downloads (used by Composer to download Magento dependencies).
These limits may significantly slow down the installation since all of the libraries will be cloned from GitHub repositories instead of downloaded as ZIP archives. In the worst case, these limitations may even terminate the installation.
If you have a GitHub account, you can bypass these limitations by using an OAuth token in the Composer configuration. See API rate limit and OAuth tokens for more information.
For the Vagrant configuration you may specify your token in local.config/github.oauth.token
file after cloning the repository. The file is a basic text file and is ignored by Git, so you'll need to create it yourself. Simply write your OAuth token in this file making sure to avoid any empty spaces, and it will be read during deployment. You should see the following message in the Vagrant log:
Installing GitHub OAuth token from /vagrant/local.config/github.oauth.token