我想使用 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]