質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Laravel

LaravelとはTaylor Otwellによって開発された、オープンソースなPHPフレームワークです。Laravelはシンプルで表現的なシンタックスを持ち合わせており、ウェブアプリケーション開発の手助けをしてくれます。

VirtualBox

VirtualBoxは、現在米オラクル社が開発している、 x86仮想化ソフトウェア・パッケージの一つです。

Q&A

0回答

662閲覧

virtualboxのローカル環境を別名で接続するには?(A VirtualBox machine with the name 'homestead' already exists)

Ms.yy

総合スコア83

Laravel

LaravelとはTaylor Otwellによって開発された、オープンソースなPHPフレームワークです。Laravelはシンプルで表現的なシンタックスを持ち合わせており、ウェブアプリケーション開発の手助けをしてくれます。

VirtualBox

VirtualBoxは、現在米オラクル社が開発している、 x86仮想化ソフトウェア・パッケージの一つです。

0グッド

1クリップ

投稿2019/08/13 21:56

編集2022/01/12 10:55

現在virtualboxの中のhomesteadという名前で接続をしているのですが、画像にあるhomestead以外の名前でも接続するには何をしたらいいでしょうか?

目的としては新規laravelプロジェクトを作成し接続するローカル環境をプロジェクト毎に変えたいです。
イメージ説明

#homestead.yaml
virtualbox接続のhomestead.yamlです。

--- ip: "192.168.10.10" memory: 2048 cpus: 2 provider: virtualbox authorize: ~/.ssh/id_rsa.pub keys: - ~/.ssh/id_rsa folders: - map: ~/planb to: /home/vagrant/code sites: - map: homestead.test to: /home/vagrant/code/plan-b/public databases: - homestead features: "Homestead.yaml" 33L, 466C

#homestead->vagrantfile

# -*- mode: ruby -*- # vi: set ft=ruby : require 'json' require 'yaml' VAGRANTFILE_API_VERSION ||= "2" confDir = $confDir ||= File.expand_path(File.dirname(__FILE__)) homesteadYamlPath = confDir + "/Homestead.yaml" homesteadJsonPath = confDir + "/Homestead.json" afterScriptPath = confDir + "/after.sh" customizationScriptPath = confDir + "/user-customizations.sh" aliasesPath = confDir + "/aliases" require File.expand_path(File.dirname(__FILE__) + '/scripts/homestead.rb') Vagrant.require_version '>= 2.2.4' Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| if File.exist? aliasesPath then config.vm.provision "file", source: aliasesPath, destination: "/tmp/bash_aliases" config.vm.provision "shell" do |s| s.inline = "awk '{ sub(\"\r$\", \"\"); print }' /tmp/bash_aliases > /home/vagrant/.bash_aliases && chown vagrant:vagrant /home/vagrant/.bash_aliases" end end if File.exist? homesteadYamlPath then settings = YAML::load(File.read(homesteadYamlPath)) elsif File.exist? homesteadJsonPath then settings = JSON::parse(File.read(homesteadJsonPath)) else abort "Homestead settings file not found in #{confDir}" end Homestead.configure(config, settings) if File.exist? afterScriptPath then config.vm.provision "shell", path: afterScriptPath, privileged: false, keep_color: true end if File.exist? customizationScriptPath then config.vm.provision "shell", path: customizationScriptPath, privileged: false, keep_color: true end if Vagrant.has_plugin?('vagrant-hostsupdater') config.hostsupdater.aliases = settings['sites'].map { |site| site['map'] } elsif Vagrant.has_plugin?('vagrant-hostmanager') config.hostmanager.enabled = true config.hostmanager.manage_host = true config.hostmanager.aliases = settings['sites'].map { |site| site['map'] } end if Vagrant.has_plugin?('vagrant-notify-forwarder') config.notify_forwarder.enable = true end end

homestead->resources->localized->vagrantfile

# -*- mode: ruby -*- # vi: set ft=ruby : require 'json' require 'yaml' VAGRANTFILE_API_VERSION ||= "2" confDir = $confDir ||= File.expand_path("vendor/laravel/homestead", File.dirname(__FILE__)) homesteadYamlPath = File.expand_path("Homestead.yaml", File.dirname(__FILE__)) homesteadJsonPath = File.expand_path("Homestead.json", File.dirname(__FILE__)) afterScriptPath = "after.sh" customizationScriptPath = "user-customizations.sh" aliasesPath = "aliases" require File.expand_path(confDir + '/scripts/homestead.rb') Vagrant.require_version '>= 2.2.4' Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| if File.exist? aliasesPath then config.vm.provision "file", source: aliasesPath, destination: "/tmp/bash_aliases" config.vm.provision "shell" do |s| s.inline = "awk '{ sub(\"\r$\", \"\"); print }' /tmp/bash_aliases > /home/vagrant/.bash_aliases" end end if File.exist? homesteadYamlPath then settings = YAML::load(File.read(homesteadYamlPath)) elsif File.exist? homesteadJsonPath then settings = JSON::parse(File.read(homesteadJsonPath)) else abort "Homestead settings file not found in " + File.dirname(__FILE__) end Homestead.configure(config, settings) if File.exist? afterScriptPath then config.vm.provision "shell", path: afterScriptPath, privileged: false, keep_color: true end if File.exist? customizationScriptPath then config.vm.provision "shell", path: customizationScriptPath, privileged: false, keep_color: true end if Vagrant.has_plugin?('vagrant-hostsupdater') config.hostsupdater.aliases = settings['sites'].map { |site| site['map'] } elsif Vagrant.has_plugin?('vagrant-hostmanager') config.hostmanager.enabled = true config.hostmanager.manage_host = true config.hostmanager.aliases = settings['sites'].map { |site| site['map'] } end end

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2019/08/13 23:24

vagrantfileはどうなっていますか?
Ms.yy

2019/08/13 23:30

vagrant.file追加させて頂きましたが、同じプロジェクト内に2つあったので両方記載いたしました。
退会済みユーザー

退会済みユーザー

2019/08/13 23:54

あれ、本当にvagrant.fileって名前でした?ドットない気がするんですが
Ms.yy

2019/08/14 00:12

確認してみます
Ms.yy

2019/08/14 03:24

すみません、vagrantfileで合ってました 訂正いたしました!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問