Vagrant is convenient and simple.
VagrantVagrant is a tool that helps you to work with a virtual machine. Installing Vagrant - you can get the OS in a virtual machine with Ubuntu, Apache / Nginx, MySql, php, etc. Also, Vagrant synchronizes folders on your OS with folders in a virtual machine (ie you work with your project in your favorite directory on your favorite OS). In general, Vagrant gives a sea of benefits, namely:
- It is easy to transfer your virtual PC from the home computer to the working without problems with the settings of the software
- You can learn, if you have not encountered before, the methods of distributed load by creating several virtual machines and trying to work with technologies such as RabbitMQ, sharding, etc.
- Test performance by setting the necessary parameters for the virtual machine
- Install the software as on the customer's server
- Make different settings for PHP
- Do not install on your OS PHP, MySql and other software
Vagrant has many configurations of the system (they are called boxes), and also you can assemble the necessary configuration on the site https://puphpet.com/
For Vagrant to work, you need a VirtualBox or some other virtualization software. After that, go to the site and download https://www.vagrantup.com/downloads.html Vagrant for your OS and start the installation of the program.
Install the plugins for Vagrant. In the console, execute the following commands:
vagrant plugin install vagrant-vbguest vagrant plugin install vagrant-hostmanager
Installing the box for PHP is one of the most popular Scotch Box (https://box.scotch.io/).
In the directory of your project, execute the command:
git clone https://github.com/scotch-io/scotch-box.git
Now, go to the scotch-box and start the command:
Loading data may take about 10-15 minutes.
After the download is finished, you can go to the address http://192.168.33.10 (this is Standard address for scotch-box) and see the start page.
In the folder scotch-box you will have a folder public in which you can install your site.
You can run the following command in the console:
to enter your virtual host by ssh.
To turn off the virtual box, execute the command:
A more detailed list of commands can be obtained by running the following command:
Vagrant and Yii2 advanced
We assume that you have the Yii2 advanced project installed. At the root of your project there must be a vagrant folder. Open and edit the file vagrant/config/vagrant-local.yml (if you do not have this file - you need to have the file vagrant-local.example.yml - save this file with the name vagrant-local.yml ). In this file, you will need to specify your account's token on github in the github_token parameter and run the command:
Now, you can run your project at:
More details on the site Github.