Virtualbox+vagrant installation under mac

virtualbox + vagrant
installation  under mac

2. Install and use Vagrant
1) Vagrant download address  select the download package

figure 2

After the installation is complete, enter
vagrant -v in the terminal to
prompt that the vagrant version is installed successfully and can be used, as follows:
bogon:~ amtbhk$ vagrant -v
Vagrant 2.0.4

2) box system image download address Download the Vagrant official packaged system image
to check whether the mac is 32-bit or 64-bit.
[vagrant@bogon vagrant]$ uname -a
Linux bogon 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Figure 3
Copy the address, put it in the browser bar, that is, download.

3) Add the downloaded box system image to Vagrant
to find the storage path of the box downloaded in 2), enter
vagrant box add centos7 ~/Downloads/devsoft/mac+vagrant/centos-7.0-x86_64.box 
centos7 in the terminal is for This box system image gets a name, whatever you want to call it, it's so free! ! !
~/Downloads/devsoft/mac+vagrant/centos-7.0-x86_64.box is the storage path of the box system image, this is my own path, you should use your own! ! !
This completes the addition

(Note here: If your box is packaged for you by a colleague after configuring the environment, you can also do it)

3. Configure the development environment
1) Create the development directory
/Users/huangzhuolin/data/Web
, which you build according to your own.

2) Initialize the development environment
Enter
vagrant init centos7 in the terminal
#initialize bogon:Web amtbhk$ vagrant init centos7
A Vagrantfilehas been placed in this directory. You are now
ready to vagrant upyour first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
vagrantup.comfor more information on using Vagrant.

3) Start the development environment and enter vagrant up
in the terminal # Start the environment and wait...

It is mentioned here: Before starting, you need to take a look at the Vagrantfile file.

config.vm.box = "centos7" #Get the name when adding the box image to vagrant
config.vm.network "private_network", ip: "192.168.33.10" #The ip of the system in the virtual machine
vb.memory = "1024" #It is The amount of memory allocated by the system in the virtual machine

Here I define the shared directory like this:
config.vm.synced_folder "./phpprojects", "/web",create: true, owner:"www", group:"www"

That is, in my mac, ~/data/Web/phpprojects, ready to put the code of each project.
For the /web directory in the virtual machine.
And I am under ~/data/Web, vagrant init.

4. Detect the network environment
Access centos7 from this machine: ping 192.168.33.10 is
successful.

从centos7访问本机:
bogon:Web amtbhk$ vagrant ssh
Last login: Thu Jul 16 08:48:31 2015 from 10.0.2.2
Welcome to your Vagrant-built virtual machine.
[vagrant@bogon ~]$ pwd
/home/vagrant
[vagrant@bogon ~]$ cd /vagrant

System Preferences -> Network ->
"Wi-Fi" is connected to "ciguang-ap", and its IP address is 192.168.1.147.

[vagrant@bogon vagrant]$ ping 192.168.1.147
PING 192.168.1.147 (192.168.1.147) 56(84) bytes of data.
64 bytes from 192.168.1.147: icmp_seq=1 ttl=63 time=0.058 ms

success.

5) Install the php environment and extensions
in the virtual machine,
cd /
mkdir build
cd build
to download oneinstack and install it.
www.oneinstack.com has detailed instructions.
After the installation is complete, you can see the successful oneinstack interface on the local 192.168.33.10.
Then, install phalcon, mongodb, rabbitmq, etc...

Configuring the environment takes a lot of time.
After everything is fine.

6) Packing. distribution.

cd ~/data/Web
vagrant package --base centos7 --output centos7.box
or vagrant package without parameters

演示:vagrant package –base virtualbox_vm_name –output newbox_name.box

1. Copy this newbox_name.box file to your colleague to the machine;
2. Execute vagrant box add newbox_names newbox_name.box on the machine to add this box to the box list of this machine;
3. When you need to build Execute vagrant init newbox_names under the directory of the development environment, which initializes a virtual machine environment, and then executes vagrant up, your colleagues can get a development environment exactly the same as yours.
One thing to pay attention to when initializing the environment is: if this directory has been initialized before, please execute the vagrant destroy command to destroy the environment and delete the Vagrantfile file, or manually delete the .vagrant directory and Vagrantfile file directly in the windows environment have the same effect. Otherwise, the vagrant init command will be invalid, and you will get the same environment as before when you vagrant up.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324624579&siteId=291194637