2

我想使用 Vagrant 在本地开发 WordPress 网站(主机:Windows 8 64 位;访客:Ubuntu 12.04 LTS)。我正在使用 Chris Wiegman 的Primary Vagrant(VVV 的 Apache 版本)

我得到了它的工作,但是一旦我添加了所有文件,该站点的运行速度就非常慢。经过研究,我猜这是因为共享文件夹速度很慢。Vagrant 网站上的这篇博文中提到的解决方法是使用 rsync。

尽管他们没有关于如何让 rsync 在 Windows 上工作的说明,但我看到了这篇推荐 cwrsync 的免费版本的文章。我还必须添加路径环境变量,以便 rsync 在 Windows 上的所有文件夹中工作(这个答案对此有所帮助)

我编辑了 vagrant 文件,以便通过附加,"rsync", rsync__exclude: ".git/"到 Primary Vagrant vagrant 文件来使用 rsync :

config.vm.synced_folder "sites/stable.wordpress.vagrant", "/var/www/stable.wordpress.vagrant", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ],"rsync", rsync__exclude: ".git/"
config.vm.synced_folder "sites/stable.wordpress.vagrant/uploads", "/var/www/stable.wordpress.vagrant/wordpress/wp-content/uploads", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ],"rsync", rsync__exclude: ".git/"
config.vm.synced_folder "sites/trunk.wordpress.vagrant", "/var/www/trunk.wordpress.vagrant", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ],"rsync", rsync__exclude: ".git/"
config.vm.synced_folder "sites/trunk.wordpress.vagrant/uploads", "/var/www/trunk.wordpress.vagrant/wordpress/wp-content/uploads", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ],"rsync", rsync__exclude: ".git/"
config.vm.synced_folder "sites/Search-Replace-DB", "/var/www/replacedb.vagrant", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ],"rsync", rsync__exclude: ".git/"
config.vm.synced_folder "sites/phpmyadmin", "/var/www/phpmyadmin.vagrant", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ],"rsync", rsync__exclude: ".git/"
config.vm.synced_folder "sites/webgrind", "/var/www/webgrind.vagrant", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ],"rsync", rsync__exclude: ".git/"

然后我做了一个vagrant up --provision。但不幸的是,我收到以下错误消息。尽管试图在网上找到问题,但我不能。

以下是错误消息:

==> default: Rsyncing folder: /cygdrive/c/Users/IanAnderson/Documents/Sites/Vagrants/Primary-Vagrant/vagrant-local/sites
/stable.wordpress.vagrant/ => /var/www/stable.wordpress.vagrant
==> default:   - Exclude: [".vagrant/", ".git/"]
There was an error when attempting to rsync a synced folder.
Please inspect the error message below for more info.
Host path: /cygdrive/c/Users/IanAnderson/Documents/Sites/Vagrants/Primary-Vagrant/vagrant-local/sites/stable.wordpress.v
agrant/
Guest path: /var/www/stable.wordpress.vagrant
Command: rsync --verbose --archive --delete -z --chmod=ugo=rwX --no-perms -e ssh -p 2222 -o StrictHostKeyChecking=no -i
'C:/Users/IanAnderson/.vagrant.d/insecure_private_key' --exclude .vagrant/ --exclude .git/ /cygdrive/c/Users/IanAnderson
/Documents/Sites/Vagrants/Primary-Vagrant/vagrant-local/sites/stable.wordpress.vagrant/ vagrant@127.0.0.1:/var/www/stabl
e.wordpress.vagrant
Error: Warning: Permanently added '[127.0.0.1]:2222' (RSA) to the list of known hosts.
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: error in rsync protocol data stream (code 12) at io.c(605) [Receiver=3.0.9]
rsync: read error: Connection reset by peer (104)
rsync error: error in rsync protocol data stream (code 12) at io.c(759) [sender=3.0.6]
4

4 回答 4

0

尝试使用MinGW。它带来了自己的 ssh.exe/bin 和 rsync.exe /msys/<version_number>/bin。将这些目录添加到我的 PATH 使其可以在我的机器上运行。

于 2015-01-16T16:07:58.520 回答
0

我知道这个问题比问题更早,但万一这可能对某人有帮助:Vagrant >=1.8.0 和 Windows 主机存在一个已知问题,会触发这种错误消息。

为了防止这种情况,请尝试删除 $VAGRANT_HOME\embedded\gems\gems\vagrant-1.8.0\plugins\synced_folders\rsync\helper.rb 中的以下行(77 到 79):

"-o ControlMaster=auto " +
"-o ControlPath=#{controlpath} " +
"-o ControlPersist=10m " +

资源

于 2016-05-26T08:18:25.113 回答
0

这不是 rsync 解决方案,但它适用于将文件共享到具有比常规虚拟盒共享更好的性能的 Windows 主机。

我成功使用了这个在 Windows 上启动 nfs 守护进程的插件:https ://github.com/winnfsd/vagrant-winnfsd

我还没有彻底测试它,因为它是一项正在进行的工作,并且是我第一次在我的项目中支持窗口。到目前为止,它似乎起到了作用并且表现得体面。尚未尝试将 MySQL 数据共享到主机上,这是服务器堆栈中最慢的资源。

另外,我在 vagrant-bindfs 插件中使用它来路由用户 uid/gid。这可能会增加混合的开销,但会使整个过程自动化。

于 2015-08-15T03:02:38.283 回答
0

添加到 Sebastian Kliem 的答案:对我来说,有必要将 MinGW /bin 目录添加到我的 PATH 的开头。我在使用 git 的 ssh 和 MinGW 的 rsync 时遇到了你提到的错误。将 MinGW 放在一开始可以确保两者能够很好地协同工作。

于 2015-08-14T14:56:52.083 回答