Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Installation of virtualbox+vagrant under mac

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Installation of virtualbox+vagrant under mac

1. Install VirtualBox

The free and compact download address of VirtualBox is very suitable. Choose the download package according to your own machine system.

Figure 1

two。 Install and use Vagrant

1) Select the download package for Vagrant download address

Figure 2

After the installation is complete, enter in the terminal

Vagrant-v

The prompt shows that the vagrant version is successfully installed and ready for use, as follows:

Bogon:~ amtbhk$ vagrant-v

Vagrant 2.0.4

2) download box system image download address to download the system image officially packaged by Vagrant

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 GNU/Linux

Figure 3

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

3) add the downloaded box system image to Vagrant

Find the storage path of the box downloaded in 2) and enter it in the terminal

Vagrant box add centos7 ~ / Downloads/devsoft/mac+vagrant/centos-7.0-x86_64.box

Centos7 is to get the name for this box system image, and you can call it whatever you want, 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 need to use your own yo!

So the addition is complete.

(note here: if your box is packaged to you by a colleague after configuring the environment, it is also OK.)

3. Configure the development environment

1) create a development directory

/ Users/huangzhuolin/data/Web

You build this according to your own.

2) initialize the development environment

Enter in the terminal

Vagrant init centos7 # initialization

Bogon:Web amtbhk$ vagrant init centos7

A Vagrantfile has been placed in this directory. You are now

Ready to vagrant up your first virtual environment! Please read

The comments in the Vagrantfile as well as documentation on

Vagrantup.com for more information on using Vagrant.

3) start the development environment

Enter in the terminal

Vagrant up # Startup Environment

And then wait.

It is mentioned here that you need to take a look at the Vagrantfile file before starting.

Config.vm.box = "centos7" # get the name when adding box image to vagrant

Config.vm.network "private_network", ip: "192.168.33.10" # ip of the system in the virtual machine

Vb.memory = "1024" # the amount of memory allocated to the system in the virtual machine

Here I define the shared directory as follows:

Config.vm.synced_folder ". / phpprojects", "/ web", create: true, owner: "www", group: "www"

That is, my mac, ~ / data/Web/phpprojects, ready to put each project code.

For the / web directory in the virtual machine.

And I am under data/Web, vagrant init.

4. Detect the network environment

Access centos7:ping 192.168.33.10 locally

Success.

Access the native machine from 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" has been 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 php environment and extension

In the virtual machine

Cd /

Mkdir build

Cd build

Download oneinstack and install it.

Www.oneinstack.com has detailed instructions.

After the installation is complete, the successful interface of oneinstack can be seen on native 192.168.33.10.

Then, install phalcon, mongodb, rabbitmq, etc.

It takes a lot of time to configure the environment.

When it's all right.

6) packing. Distribute.

Cd ~ / data/Web

Vagrant package-base centos7-output centos7.box

Or vagrant package has no 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

two。 Execute vagrant box add newbox_names newbox_name.box on the machine to add the box to the machine's box list

3. Execute vagrant init newbox_names under the directory where you need to build the development environment, so that you initialize a virtual machine environment, then execute vagrant up, and your colleagues can get exactly the same development environment as you.

One thing to note when initializing the environment is that if this directory has been initialized before, execute the vagrant destroy command to destroy the environment and delete the Vagrantfile file, or delete the .vagrant directory and the Vagrantfile file manually in the windows environment has the same effect. Otherwise, the vagrant init command is invalid and you get exactly the same environment as before when you vagant up.

Suppose it's on your colleague's machine.

The copied centos7.box is placed under ~ / Downloads/devsoft/centos7.box.

Prepare to put the environment in the ~ / vg directory and the project code in ~ / vg/phpprojects.

You can create your own directory.

Of course, my colleague's machine has also been installed, vagrant, vitualbox

Cd ~ / vg

Vagrant box add centos7 ~ / devsoft/centos7.box

Vagrant init

Vagrant up

I'm almost done.

If you encounter this problem:

If you report: default: Warning: Remote connection disconnect. Retrying...

Generally, when you see this message, the virtual machine has started successfully. You can try to log in to vagrant ssh after interrupting the command.

If you fail

Modify the Vagrantfile file under the vagrant working directory

In config.vm.box = "XXX." Lower

Add config.ssh.password = "vagrant"

Then log in to vagrant ssh again.

When you log in with vagrant ssh, you will be asked to enter a password, that is, vagrant

After logging in successfully, sudo su

Cd / web

You can see the project under ~ / vg/phpprojects.

--

Because of this environment installed with oneinstack.

At this point, type 192.168.33.10 on the machine to see the interface where oneinstack is installed successfully.

You can also follow up to the contents of phpinfo ().

Then install the extension. Phalcom,mongodb,rabbitmq

If you don't install it, you can ignore it below.

Create some links first:

Bogon:Web amtbhk$ vagrant ssh

Sudo su

[root@bogon build] # ln-s / usr/local/php/bin/phpize / usr/bin/phpize

[root@bogon build] # ln-s / usr/local/php/bin/php-config / usr/bin/php-config

[root@bogon build] # ln-s / usr/local/php/bin/pecl / usr/bin/pecl

1. Install phalcon

[root@bogon build] # wget-c https://github.com/phalcon/cphalcon/archive/master.zip

[root@bogon build] # unzip master.zip

Cd cphalcon-master/

Cd build

Cd php7

Cd 64bit

Phpize

. / configure

Make

Make install

Cd / usr/local/php/lib/php/extensions/no-debug-zts-20170718/

Cd / usr/local/php/etc/php.d

Service nginx restart

= =

In the virtual machine

The phalcon.php command should be normal, if it cannot be found. That is, there are no shortcuts.

Sudo su

Cd ~

Vi .bash _ profile

There needs to be a sentence in the middle: export PATH=$PATH:/web/phalcon-devtools-3.2.12

Again:

Source .bash _ profile

two。 Install swoole

Wget-c http://pecl.php.net/get/swoole-2.1.3.tgz

Tar xzvf swoole-2.1.3.tgz

Cd swoole-2.1.3

Phpize

. / configure

Make

Make install

Install rabbitmq

Rabbitmq

To install Erlang first

Reinstall rabbitmq

Note that the version corresponds.

This follow-up installation will be added successfully.

Reference link:

Https://laravel-china.org/topics/9832/php72s-redis-extension-installation-problem

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report