LoginSignup
8
13

More than 3 years have passed since last update.

Vagrantでローカルファイルと仮想環境の同期

Last updated at Posted at 2019-02-02

前提: VirtualBoxとVagrantを導入済み

ローカルと仮想環境のファイルと同期させたい

設定はVagrantfileのconfig.vm.synced_folderにパスを設定するだけ!

※typeの設定はvirtualboxにしておかないと一方通行編集になっちゃう。

Vagrantfile
# これを追記or編集
config.vm.synced_folder "ローカル(ホスト)のパス", "仮想環境の絶対パス" , type: "virtualbox"

# 例1
config.vm.synced_folder "/Users/testuser/projects/app", "/home/vagrant/app" , type: "virtualbox"

# 例2
# (vagrantfileのあるローカルディレクトリの1つ上の階層以下を仮想環境の/var/www/current以下共有)
config.vm.synced_folder "../", "/var/www/current" , type: "virtualbox"

再起動

vagrant reloadなどで再起動して新規ファイル作ったりしてテストしてみる!

参考

windowsユーザがVagrantの共用フォルダを設定しようとした話
http://tech.respect-pal.jp/vagrant-synced_folder-type/

8
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
13