我想使用Vagrant在本地开发WordPress网站(主机:Windows 8 64位;访客:Ubuntu 12.04 LTS)。我正在使用Chris Wiegman的Primary Vagrant(VVV的Apache版本)
我得到了它的工作,但是一旦我添加了所有文件,网站运行得非常慢。经过研究,我猜这是由于共享文件夹很慢。在this blog post on the Vagrant website中提到的工作是使用rsync。
尽管他们没有关于如何在Windows上运行rsync的说明,但我遇到了this article,它推荐了免费版的cwrsync。我还必须添加路径环境变量,以便rsync在Windows上的所有文件夹中工作(this answer帮助了这个)
我编辑了vagrant文件,以便通过将,"rsync", rsync__exclude: ".git/"
附加到主要流氓vagrant file来使用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]
答案 0 :(得分:0)
尝试使用MinGW。它在/bin
中带来了自己的ssh.exe
和/msys/<version_number>/bin
中的rsync.exe。
将这些目录添加到我的PATH使它可以在我的机器上运行。
答案 1 :(得分:0)
添加到Sebastian Kliem的答案:对我来说,有必要将MinGW / bin目录添加到PATH的 start 。我在使用git的ssh和MinGW的rsync时遇到了你提到的错误。将MinGW放在一起就确保两者合作得很好。
答案 2 :(得分:0)
这不是rsync解决方案,但它适用于以比常规虚拟机共享更好的性能共享文件到Windows主机。
我成功使用了这个在windows上启动nfs守护进程的插件:https://github.com/winnfsd/vagrant-winnfsd
我还没有对它进行彻底的测试,因为它是一项正在进行的工作,并且第一次在我的项目中支持窗口。它似乎做了这个技巧并且到目前为止表现得体面。 Haven没有尝试将MySQL数据共享到主机上,这是服务器堆栈中最慢的资源。
另外,我沿着vagrant-bindfs插件使用它来路由用户uid / gid。这可能是混合广告的开销,但可以使整个过程自动化。
答案 3 :(得分:0)
我知道这个问题比问题旧,但如果这可能会对某人有所帮助:有一个known issue与Vagrant&gt; = 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 " +