- https://www.virtualbox.org/wiki/Linux_Downloads
- https://obel.hatenablog.jp/entry/20170423/1492915051
- https://news.mynavi.jp/article/20190227-777688/
- https://www.vagrantup.com/downloads.html
- https://qiita.com/manabuishiirb/items/3a97851d7e90286f6002
- http://vboxmania.net/content/vboxmanage-modifyvm%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89
- https://teratail.com/questions/100887
1.VirtualBoxのインストール
$ wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add - $ wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add - $ sudo add-apt-repository "deb [arch=amd64] https://download.virtualbox.org/virtualbox/debian disco contrib" $ sudo apt-get update $ sudo apt-get install virtualbox-6.0 $ virtualbox --help Oracle VM VirtualBox VM Selector v6.0.8
2.Vagrantのインストールと初期設定
$ wget https://releases.hashicorp.com/vagrant/2.2.4/vagrant_2.2.4_x86_64.deb $ sudo dpkg --install vagrant_2.2.4_x86_64.deb $ vagrant -v Vagrant 2.2.4 $ vi ~/.bash_profile ---- export VAGRANT_HOME=/(boxを置きたいディレクトリ)/.vagrant.d # 追記 ---- $ source .bash_profile $ echo $VAGRANT_HOME /(boxを置きたいディレクトリ)/.vagrant.d # 変わっているのを確認
試しに、以前にMBPに Virtual Box + Vagrant 環境を構築して、Laravel 環境作ってみた手順をなぞって確認してみる。
$ vagrant box add laravel/homestead --box-version 7.2.1 $ cd /path/to/homestead $ git clone https://github.com/laravel/homestead.git Homestead_v721 $ cd Homestead $ bash init.sh # Homestead を初期化。Homestead.yaml が作成される。 $ cd ~ $ ssh-keygen -t rsa -f id_rsa_homestead7 $ cd /path/to/homestead $ vi Homestead.yaml ---- (略) # LAN内のホストとは別のデバイスからアクセスできるようにするには以下のようにネットワークの設定を「ブリッジ」にする。 networks: - type: "public_network" ip: "192.168.3.110" bridge: "enp3s0" ---- $ VBoxManage modifyvm homestead-7 --nic2 bridged $ vagrant up $ vagrant ssh #### vagrant@homestead $ mkdir code vagrant@homestead $ cd code vagrant@homestead $ laravel new vagrant@homestead $ php artisan migrate
box add のところではバージョン指定しないと、最新版を落とすが、6/1時点では8.0.0-alpha2が最新版になっているので、バージョンを指定した。
デフォルトでアルファ版落ちるようにすんじゃねーよ。
どうにも、Laravel/Homestead は第一印象が悪かったせいか、こういうところも印象が悪い。Github見ても、そのalpha版のBoxに、どのバージョンの Laravel が入ってるとか一切書いてないし。
ともあれ、ホストの二号機と同じネットワーク内にあるMBPから、ブラウザで「192.168.3.110」にアクセスすると、Laravelの初期画面が無事に表示された。
が、ここまでの手順通りにやると、弐号機に SSH で接続した際に、キーワードのハイライトやら、ll あたりのコマンドエイリアスが効かなくなった。
https://teratail.com/questions/169916
Vagrant インストールしたあとに、.bash_profile に環境変数を記載したんだが、その際に .bash_profile 自体が無くて、あれ?と思いながら設定をしていた。
どうも Ubuntu ではデフォルトでは .bash_profile は使っていないらしく、.profile というファイルがあるらしい。
で、.bash_profile があるとそちらは読まれなくなってしまうので、それまで使っていたコマンドエイリアスも効かなくなったし、キーワードのハイライトも効かなくなった、というオチらしい。
上記 teratail の回答にあるように、 .bash_profile から、.profile を読みに行くようにして解決。