在Vagrant中装载共享文件夹之前,我可以强制进行资源调配吗?
我有以下在Vagrant中装载共享文件夹之前,我可以强制进行资源调配吗?,vagrant,provisioning,vagrantfile,vagrant-provision,Vagrant,Provisioning,Vagrantfile,Vagrant Provision,我有以下vagrant文件: # -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| config.vm.box = "centos/6" config.vm.provision :shell, :path => "bootstrap.sh" config.vm.network :forwarded_port, host: 8080, guest: 80 config.vm.n
vagrant文件
:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "centos/6"
config.vm.provision :shell, :path => "bootstrap.sh"
config.vm.network :forwarded_port, host: 8080, guest: 80
config.vm.network :forwarded_port, host: 3306, guest: 3306
config.vm.synced_folder "../../applications", "/var/www/html", :owner=>"apache", :group=>"apache"
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", 2048]
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
vb.name = "appserver"
end
end
每次运行vagrant up
(第一次运行vagrant destroy-f
)时,我都会出现以下错误:
==> default: Mounting shared folders...
default: /vagrant => E:/Development/vagrant/centos6
default: /var/www/html => E:/Development/applications/arx
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:
id -u apache
The error output from the command was:
id: apache: No such user
错误很明显“apache用户不存在”。正如我所看到的,有两种或“三种”方法可以解决这个问题:
- 通过从
synced_文件夹中删除
部分。这是一个很大的问题,至少对我来说是这样,因为如果我删除它们,那么文件夹将属于:owner=>“apache”,:group=>“apache”
,当apache试图从vagrant
读取内容时,这将/可能会导致问题/var/www/html
- 通过注释行
,打开盒子以便安装和设置所有内容,然后关闭盒子并重新站起来,不注释行:它可以工作,但仍然是一个丑陋的解决方案config.vm.synced_文件夹
- 通过强制在装载任何东西之前进行资源调配:理想的解决方案
我已经找到了,但是没有帮助。一个可能的解决方案是以流浪用户的身份运行apache 在
/etc/httpd/conf
中,可以将用户和组值替换为
User vagrant
Group vagrant
因此,您可以继续与vagrant用户共享您的文件夹,httpd将作为vagrant用户运行