vagrant问题汇总

精选文章 2017年9月1日 6.38K

最近电脑系统重新安装,然后环境也重新搭建了,这不各种奇葩的vagrant问题一个接一个,现在PHP学习网把遇到的问题记录在下,只要碰到的问题,便会断断续续记录在下。

所用版本

1、VirtualBox-5.1.26-117224-Win.exe

2、vagrant_1.9.8_x86_64.msi

3、ubuntu-14.04-amd64-vbox.box

4、系统window10

问题一:window数据无法同步到虚拟机

报错信息:

mount -t vboxsf -o uid=1000,gid=1000 vagrant /vagrant

The error output from the command was:

/sbin/mount.vboxsf: mounting failed with the error: No such device

解决办法:安装vagrant-winnfsd插件。

vagrant plugin install vagrant-winnfsd

完成后重启,看看效果。

问题二:open_basedir问题(已不属于vagrant的问题)

open_basedir:将 PHP 所能打开的文件限制在指定的目录树,包括文件本身。本指令不受安全模式打开或者关闭的影响。

根据我的理解说一下,大体目录如下目录树,我们将网站的运行目录指定到web目录下面,在index.php中若是用require引用Model,便会出现报错。

├── Common
├── Domain
├── Model
└── Public
├── Web
│ └── index.php
└── init.php

报错信息

Warning: require(): open_basedir restriction in effect. File(/home/wwwroot/www.viphper.com/vendor/autoload.php) is not within the allowed path(s): (/home/wwwroot/www.viphper.com/frontend/web/:/tmp/:/proc/) in /home/wwwroot/www.viphper.com/frontend/web/index.php on line 8

Warning: require(/home/wwwroot/www.viphper.com/vendor/autoload.php): failed to open stream: Operation not permitted in /home/wwwroot/www.viphper.com/frontend/web/index.php on line 8

Fatal error: require(): Failed opening required '/home/wwwroot/www.viphper.com/frontend/web/../../vendor/autoload.php' (include_path='.:/usr/local/php/lib/php') in /home/wwwroot/www.viphper.com/frontend/web/index.php on line 8

此错误在使用Yii2框架时,是比较容易出现的。

解决方法,打开/usr/local/nginx/conf/fastcgi.conf 文件,在文件的最后一行我们可以看到

fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";

修改为:

fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/home/wwwroot/:/tmp/:/proc/";

注意:/home/wwwroot/ 为你网站的执行目录,根据自己的配置修改。

问题二:vagrant本地目录和虚拟机目录同步问题

vagrant总是给人惊喜,用着用着就坏了,坏了就得解决问题,出现的错误信息如下

Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:

mount -t vboxsf -o uid=1000,gid=1000 vagrant /vagrant

The error output from the command was:

/sbin/mount.vboxsf: mounting failed with the error: No such device

仔细阅读以下,说是没办法同步目录。各种查找后找到解决方法,安装增强工具

sudo apt-get install virtualbox-guest-utils  #虚拟机上执行

然后重启 vagrant reoad,问题解决。


关注微信公众号『PHP学习网

第一时间了解最新网络动态
关注博主不迷路~

PHP学习网:站内收集的部分资源来源于网络,若侵犯了您的合法权益,请联系我们删除!
分享到:
赞(0)

文章评论

您需要之后才可以评论
0点赞 0评论 收藏 QQ分享 微博分享

PHP学习网

PHP学习网