Vagrant usage Summary

Source: Internet
Author: User

Laravel was installed several months ago, but it has never been used up, because there is no difference between a vagrant without configuration and a common Virtual Machine. If you open virtual box, you will find that there is actually a virtual machine running in it.

The power of vagrant is like an image. After configuration, the image can be placed anywhere, and it is truly done once and for all.

Summarize your notes on using vagrant to avoid having to go through the official documents in the future.

Vagrant Official Website: http://www.vagrantup.com/now revised, very beautiful.

Some images of vagrant: http://www.vagrantbox.es/various Linux.

 

After installation, You need to configure the environment variables in windows and put the bin directory of vagrant into the environment variables.

Then, according to the official statement, execute these three parts, and then a virtual machine starts up.

$ Vagrant box add base http://files.vagrantup.com/lucid32.box Add a box, lucid32 is a Ubuntu virtualbox image $ vagrant init # initialization $ vagrant up # This is the real startup
After the virtual machine starts up, it can connect to ssh. port 22 of the Virtual Machine maps to port 2222 of the Local Machine by default. The default user name and password are both vagrant. After SSH is used, the initialization phase is complete.
 
Remember some common commands of vagrant.
Vagrant up # Start vagrant halt # Shut Down vagrant reload # restart, mainly used to re-load the configuration file
The configuration file vagrantfile of vagrant is in the vagrant directory. Configuring the basic development environment involves two main aspects: config. VM. the forward_port option is mainly used for port ing. It initially maps port 22 to port 2222 of the local machine. We can map port 80 of the virtual machine to port 4470 of the local machine, then, access 127.0.0.1: 4470 after the environment (such as lnmp) is configured in the VM is 80, which is very convenient.
config.vm.forward_port 8080, 4470config.vm.forward_port 80, 4471config.vm.forward_port 3306, 3307

Another is to configure the shared directory for local development and virtual machine testing.

# Share an additional folder to the guest VM. the first argument is # an identifier, the second is the path on the guest to mount the # folder, and the third is the path on the host to the actual folder. config. VM. pai_folder "V-Data", "/Data", "data" # Remove the comment of this line. As mentioned above, the first line is a flag, the second is the directory mounted to your virtual machine, and the third is the directory of the physical machine. The directory is 777 and can be modified and deleted at will. All operations are synchronized between the virtual machine and the local machine.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.