Virtualbox+vagrant installation under Mac

Source: Internet
Author: User
Tags install php virtual environment

Virtualbox+vagrant installation under Mac
1. Installing VirtualBox
VirtualBox? Free small very suitable, according to their own machine system select download Package
Figure 1

2. Install and use vagrant
1) Vagrant? Select Download Package

Figure 2

After the installation is complete, the terminal input
Vagrant-v
The prompt shows 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 Vagrant Official Package System image
See if your Mac is 32-bit or 64-bit.
[Email protected] vagrant]$ uname-a
Linux bogon 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC x86_64 x86_64 x86_64 gnu/linux

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

3) Add the downloaded box system image to vagrant
Find yourself 2) in the storage path of the box that is downloaded in the terminal input
Vagrant box Add Centos7 ~/downloads/devsoft/mac+vagrant/centos-7.0-x86_64.box?
Centos7 is to give this box system image to get the name, want to call what is what, is 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 have to use your own YO!!!
This will add the complete

(This explains: If your box is a colleague to configure the environment after the package you can also OH)

3. Configuring the development environment
1) Create a development directory
/users/huangzhuolin/data/web
This you build according to yourself.

2) Initializing the development environment
Enter in the terminal
Vagrant init centos7???? #初始化
Bogon:web amtbhk$ vagrant Init centos7
A has been placed in the this Vagrantfile directory. You is now
Ready to vagrant up your 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
Enter in the terminal
Vagrant up???? # Launch Environment
Then just wait ...

mentioned here: Before you start, you need to look at the Vagrantfile file.

Config.vm.box = "Centos7"???? #添加box镜像到vagrant时取得名字
Config.vm.network "Private_network", IP: "192.168.33.10"????? #虚拟机中系统的ip
Vb.memory = "1024x768"?????? #为虚拟机中系统分配的内存大小

Here I define the shared directory as:
Config.vm.synced_folder "./phpprojects", "/web", Create:true, Owner: "www", Group: "www"

That's my Mac,/data/web/phpprojects, ready to put the code for each project.
For the/web directory in the virtual machine.
And I was under the/data/web, Vagrant Init.

4. Detecting network environment
Access Centos7:ping 192.168.33.10 from the local machine
Success.

Access this machine from CENTOS7:
Bogon:web amtbhk$ vagrant SSH
Last Login:thu Jul 08:48:31 from 10.0.2.2
Welcome to your vagrant-built virtual machine.
[Email protected] ~]$ pwd
/home/vagrant
[Email protected] ~]$ cd/vagrant

Network, System Preferences
The "wi-fi" is connected to the "ciguang-ap" and its IP address is 192.168.1.147.

[[email protected] vagrant]$ Ping 192.168.1.147
PING 192.168.1.147 (192.168.1.147) bytes of data.
Bytes from 192.168.1.147:icmp_seq=1 ttl=63 time=0.058 ms

Success.

5) Install PHP environment and extensions
In a virtual machine,
CD/
mkdir Build
CD Build
Download Oneinstack, install.
The www.oneinstack.com is described in detail.
After the installation is complete, you can see the oneinstack successful interface in the native 192.168.33.10.
Then, install Phalcon, MongoDB, RABBITMQ etc...

It takes a lot of time to configure the environment.
All is well after.

6) packaging. Distribute.

CD ~/data/web
Vagrant Package--base Centos7--output Centos7.box
Or vagrant package does not add parameters

Demo: Vagrant package–base virtualbox_vm_name–output Newbox_name.box

1. Copy this Newbox_name.box file to your colleague on the machine;
2. Execute Vagrant Box Add newbox_names Newbox_name.box on the machine to add the box to the box list on this machine;
3. Execute Vagrant init newbox_names under the directory where the development environment needs to be built, so that a virtual machine environment is initialized, and then vagrant up is executed, and your colleagues get a development environment that is exactly the same as yours.
One thing to be aware of when initializing your environment is that if you have previously initialized the directory, execute the vagrant destroy command to destroy the environment and delete the Vagrantfile file. or manually remove the. Vagrant directory and the Vagrantfile file directly in the Windows environment with the same effect. Otherwise the Vagrant init command is not valid, and when you vagant up you get an environment that is exactly the same as before.

Virtualbox+vagrant installation under Mac

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.