美文网首页
总结之二 Vagrant搭建本地环境

总结之二 Vagrant搭建本地环境

作者: 海里的沙丁鱼 | 来源:发表于2018-01-15 18:55 被阅读0次

因为工作需要 在本地搭建一个开发环境 但是在搭建中发现不是一帆风顺 所以记录下来

详细的搭建过程 可以看这篇github上的文章 介绍的很详细,我也不做多余的重复工作了。

下面我就讲一下遇到的问题:
经过了成功执行vagrant init,生成了Vagrantfile文件,也修改了你们的ip地址,可是执行vagrant up却如下错误:

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set network interfaces...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["hostonlyif", "create"]

Stderr: 0%...
Progress state: E_FAIL
VBoxManage.exe: error: Failed to create the host-only adapter
VBoxManage.exe: error: Could not find Host Interface Networking driver! Please reinstall
VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component HostNetworkInterfaceWrap, interface IHostNetworkInterface
VBoxManage.exe: error: Context: "enum RTEXITCODE __cdecl handleCreate(struct HandlerArg *)" at line 94 of file VBoxManageHostonly.cpp

因为这里用的VirtualBox版本是5.1.22-115126-Win,这似乎是VirtualBox本身的一个bug 。换了一版本就可以了。我重新选择了
VirtualBox的4.3.40-110317-Win,不过这个版本现在官方已经不支持了,看自己的选择吧

二 项目迁入

成功配置好了环境后,当我把项目迁入当前环境,执行composer update或者访问我的项目时,出现了下面这个报错:

mmap() failed: [12] Cannot allocate memory

mmap() failed: [12] Cannot allocate memory
PHP Fatal error:  Out of memory (allocated 516435968) (tried to allocate 4096 bytes) in /vagrant/0623/vendor/fukuball/jieba-php/src/vendor/multi-array/MultiArray.php on line 64

mmap() failed: [12] Cannot allocate memory
PHP Fatal error:  Out of memory (allocated 516435968) (tried to 

一看就知道是环境的内存大小超出了,所以我就修改了环境中的php.ini文件,但是还是不行。不论我给开多大的内容。

之后有了另一个思路:

我的这个vagrant搭建时的虚拟机内存大小是否不够,因此,找到了Vagrantfile配置文件,

  # config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
     #vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
    # vb.memory = "1024"
  # end

修改为

   config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
     #vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
     vb.memory = "4096"
   end

重新访问我的项目,成了!。

三 vagrant权限问题

在vagrant初始化后,会发现/vagrant的权限是777,甚至之后该目录下的文件权限也是777,进行修改权限会发现修改不了。

相关文章

网友评论

      本文标题:总结之二 Vagrant搭建本地环境

      本文链接:https://www.haomeiwen.com/subject/ktbdoxtx.html