Vagrant Usage Summary

Source: Internet
Author: User
Tags sendfile

Vagrant Usage Summary

Recently the company used the Vagrant virtual image service, it feels pretty good. Only the usage methods are recorded here.

Pros: We can package a Linux development environment through Vagrant and distribute it to team members. Members can develop programs on their favorite desktop system (Mac/windows/linux), but the code can be unified in a packaged environment to run, very domineering.

The main focus is that it allows developers to develop in the same development environment, thus avoiding some of the problems that each developer causes the final code to go online because of the development environment.

Cons: You need to configure the good one to meet the development conditions in advance. (This process actually play liunx people, will, for the people who do not, this is the shortcomings.)

The Centos-6.5-x86_64-base.box mentioned later in this article, is the centos-6.5 system, in which I have preinstalled PHP Apache Nginx Nodejs and so on to meet the program running environment.

The following steps are used:

1. Download vagrant and VirtualBox

Vagrant:http://www.vagrantup.com/downloads.html

Virtualbox:https://www.virtualbox.org/wiki/downloads

Box image file, this article example sub-box file (Centos-6.5-x86_64-base.box, because the source file is too large, it will not be transmitted)

2. Installation of Vagrant and VirtualBox

3. Create a directory on your local hard drive to store the vagrant configuration file, and put the centos-6.5-x86_64-base.box image downloaded in 1 into this directory.

For example, if you create a directory address of: E:\testvbox, then put Centos-6.5-x86_64-base.box in this directory.

4. Run the cmd command to the command line, and switch to the directory created in 3 (Testvbox).

Command:

CD E:/testvbox

5. In this directory (Testvbox), execute the following command in turn:

1).

Vagrant box Add Dev Centos-6.5-x86_64-base.box

PS: The above command means: vagrant is the vagrant command, box for the parameter, add for adding a box environment, Dev for the box environment you want to create the name, Centos-6.5-x86_64-base.box for you to download the box environment image.

2).

Vagrant Init Dev

PS: The above command means: vagrant is the command of Vagrant, Init is the parameter, initialize a box environment, Dev is the box environment name you want to initialize.

6, at this time, you will see a vagrantfile file in the current directory, this file is the Vagrant box environment configuration file. To edit this file, you can open the file with Notepad and modify the following:

1). Line 22nd, remove the previous #

# Config.vm.network:forwarded_port, guest:80, host:8080

Into

Config.vm.network:forwarded_port, guest:80, host:8080

2). Line 26th, remove the previous #

# config.vm.network:p rivate_network, IP: "192.168.33.10"

Into

Config.vm.network:p rivate_network, IP: "192.168.33.10"

PS: Here is the private IP, only you can access the virtual machine, if you want to configure the LAN can be accessed, then you do not need to modify the 26 lines, remain the same, this time need to modify the 31st line

# config.vm.network:p ublic_network

Into

Config.vm.network:p ublic_network, IP: "192.168.8.88"

The PS:IP can be configured or not configured, and the virtual machine can be automatically dhcp. I am configured here, because each time the automatic configuration of IP address changes to be inconvenient.

3). Line 41st

# Config.vm.synced_folder ". /data ","/vagrant_data "

Switch

Config.vm.synced_folder "E:/www", "/var/www/html"

Ps:

1). E:/www This is your local project directory, this directory will be automatically linked to the box environment

2)./var/www/html is a mount point in a virtual development environment.

7, finally, modify the local Hosts file, the 6th step in the "2" in the IP address map to the corresponding domain name, the following will be added to your local hosts:

192.168.33.10 www.testvbox.com

PS: You want to map on the map do not want to map on the IP address to access well.

8. Finally, run in CMD under the configuration directory (Testvbox) of your box environment, such as the following command, to open your virtualized environment.

Vagrant up

At this point, when the boot is complete, vagrant's virtualized development environment is configured. Then in the browser you can access the.

PS: Extra:

# vagrant halt off virtualized development environment

# vagrant Reload After modifying the configuration file, restart the virtualized development environment

# vagrant Box List View the currently available virtualized development environment

# vagrant Box Remove Boxname Delete the specified box environment

# vagrant Package is currently running VirtualBox virtual environment packaged into a reusable box

# vagrant up the virtual machine

# vagrant destroy destroying virtual machines

PS: If you find that images and js,css files are not reflected after they have been changed, it is that these are cached,

It is useless to restart the virtual service at this time. The following modifications should be made:

If it is nginx environment, then find nginx.conf, the inside of the "Sendfile on" modified to "sendfile off."

Of course, if you use Apache you may encounter similar problems, then there are similar configurations need to be modified to:

Enablesendfile off

Ps:

Because Liunx is not too familiar, only some of the commands used by individuals are recorded.

Apache Directory configuration file
Vim/etc/httpd/conf.d/vhost.conf
/ETC/INIT.D/HTTPD restart

Nginx Directory configuration file
Vim/etc/nginx/conf.d/virtual.conf
/etc/init.d/nginx restart

Configuring the NIC
Vim/etc/sysconfig/network-scripts/ifcfg-eth1
/etc/init.d/network restart

Vagrant Usage Summary

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.