Vagrant Environment Setup and project deployment

Source: Internet
Author: User
Tags ssh vmbox

The advantage of setting up a vagrant environment is that it can ensure consistency with the formal environment, avoid the environment caused by the running of abnormal.

First install vagrant and Oracle VM box, can not go directly to the official website to download the latest to use, because vagrant and vmbox matching is needed for the corresponding version, here I choose the version:

Http://download.virtualbox.org/virtualbox/4.3.40/VirtualBox-4.3.40-110317-Win.exe

Https://releases.hashicorp.com/vagrant/1.9.5/vagrant_1.9.5.msi

Open the link yourself to download the line.

Also download a box:

Http://www.vagrantbox.es/, this is the official website.

Here is my choice of box:

Https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.1.0/centos-7.0-x86_64.box

Configure the Vmbox environment variables after the software installation is complete


Copy it in the path you have installed.

Then install a GIT tool that must be OH.

Next to find a directory as a vagrant working directory, I am looking for the D:\myapache\box_work, after entering the directory, add the downloaded box image.


Then initialize the vagrant:


A vagrantfile file will be generated in the working directory, and the download should be configured with this file:


  Config.vm.box = "Dev"
  config.vm.network "Forwarded_port", guest:80, host:80 config.vm.synced_folder
  "./share ","/vagrant_data "
  config.ssh.username =" vagrant "
  Config.ssh.password =" vagrant "
  Config.vm.provider" VirtualBox "Do |vb|
	#Display the VirtualBox GUI booting the machine
	Vb.gui = True #Customize The amount of memory on the
	VM:
	Vb.memory = "1024"
	Vb.cpus = 2
	vb.name = "MY_VM"
	vb.customize ["MODIFYVM",: ID, "--natdnshostresolver1", ' On ']
	vb.customize [' MODIFYVM ',: ID, '--natdnsproxy1 ', ' on ']
   end
The middle section of the configuration can be written in it. The share folder is the local directory, Vagrant_data is the directory that maps to and share.


Next, start vagrant.


Then SSH link:


OK, the work has been completed, and then is to configure the LNMP operating environment.

Enter the share directory, go to the official website to download Nginx and PHP Linux installation package can be



Enter Vagrant Operation window:


We will find that we put the file, normal installation nginx,php on the line, after the installation of the Nginx to configure the operating environment, no longer elaborated, the installation of the time if there is no permission to use sudo to execute the command. Eg:sudo./configure sudo make sudo make install.

Then we can create our own project under the Share directory, and nginx the configuration to highlight:



Directory to write Vagrant_data, this above we have explained, is mapped with share Linux folder, do not write wrong.

I created a demo folder that wrote a index.php.



Finally run, above my nginx configuration server_name is my.vagrant.com.

Therefore, in the local hosts file to configure a:


And then run:


Complete.


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.