linux - Vagrant 的鸡和蛋 : Shared folder with uid = ap

我的 Vagrant box 是从基础 linux(科学 linux)构建的,在配置期间(使用 shell 脚本),安装了 Apache。

我最近将 Vagrant 文件 (v2) 更改为:

config.vm.synced_folder "public", "/var/www/sites.d/example.com",
   :owner => "apache", :group => "apache"

如果盒子已经配置好并且刚刚重新启动,这会很有效。

现在,在 vagrant destroy && vagrant up 之后出现错误:

mount -t vboxsf -o uid=`id -u apache`,gid=`id -g apache` 
   /var/www/sites.d/example.com /var/www/sites.d/example.com
id: apache: User does not exist

这很清楚 - 在初始运行期间,尚未安装 apache。

一个丑陋的解决方法当然是使用注释掉的 synced_folder 进行基本配置,将其注释掉,然后重新启动。

有什么干净的技巧可以解决这个问题吗?尤其是 vagrant up 总是不间断地运行,即使盒子是新的。

最佳答案

如果您可以修复 uid/gid 值,则可以在 mount 命令中使用它们 - 它们不必与现有用户/组相关

我对后来由 puppet 使用固定(匹配)uid/gid 值创建的用户执行此操作

config.vm.synced_folder "foo", "/var/www/foo",
   id: "foo", :mount_options => ["uid=510,gid=510"]

关于linux - Vagrant 的鸡和蛋 : Shared folder with uid = apache user,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17966365/

相关文章:

linux - BASEDIR 环境变量未正确定义

mysql - 用于数据库备份的 Linux shell 脚本

linux - 在tmux中绑定(bind)Ctrl+Tab和Ctrl+Shift+Tab

linux - Bash:在文件中的特定位置插入一行

linux - 如何判断文件是否在/bin/sh 中超过 30 分钟?

php - 如何在 Ubuntu 14.04 上更改 php-cli 版本?

ruby-on-rails - 如何在 Linux 上使用 Ruby 2.0 改进 unicorn

linux - 如何在 AWS 上的 Amazon Linux AMI 中自动启动 node.js

linux - 如何使用 sed 通过灵活的键和值更改我的配置文件?

linux - 我需要 -D_REENTRANT 和 -pthreads 吗?