1 頁 (共 1 頁)

Ubuntu x Laravel Homestead

發表於 : 2021-03-08, 10:17
Lexaul
參考資料
建置vagrant
https://linuxize.com/post/how-to-instal ... ntu-20-04/
laravel homestead官方文件
https://laravel.tw/docs/5.3/homestead
建置laravel homestead環境
https://blog.wu-boy.com/2014/09/get-hom ... m-running/


更新系統

代碼: 選擇全部

sudo apt-get upgrade
安裝VirtualBox

代碼: 選擇全部

sudo apt install virtualbox
安裝Vagrant (2021/03/08官網最新版本)

代碼: 選擇全部

curl -O https://releases.hashicorp.com/vagrant/2.2.14/vagrant_2.2.14_x86_64.deb
sudo apt install ./vagrant_2.2.14_x86_64.deb
驗證安裝是否成功

代碼: 選擇全部

vagrant --version
安裝 Homestead Vagrant Box

代碼: 選擇全部

vagrant box add laravel/homestead

代碼: 選擇全部

This box can work with multiple providers! The providers that it
can work with are listed below. Please review the list and choose
the provider you will be working with.

1) parallels
2) virtualbox

Enter your choice:
選2

安裝 Homestead

代碼: 選擇全部

cd ~
git clone https://github.com/laravel/homestead.git Homestead
在 Homestead 目錄中執行 bash init.sh 指令來建立 Homestead.yaml 設定檔

代碼: 選擇全部

cd Homestead
bash init.sh
設定 Homestead

代碼: 選擇全部

vim Homestead.yaml

代碼: 選擇全部

---
ip: "192.168.10.10"
memory: 2048
cpus: 2
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/code
      to: /home/vagrant/code

sites:
    - map: homestead.test
      to: /home/vagrant/code/public

databases:
    - homestead

features:
    - mysql: false
    - mariadb: false
    - postgresql: false
    - ohmyzsh: false
    - webdriver: false

#services:
#    - enabled:
#        - "postgresql@12-main"
#    - disabled:
#        - "postgresql@11-main"

# ports:
#     - send: 50000
#       to: 5000
#     - send: 7777
#       to: 777
#       protocol: udp
~                                       
啟動 Vagrant

代碼: 選擇全部

vagrant up
疑難排解
Check your Homestead.yaml (or Homestead.json) file, the path to your private key does not exist.
參考資料:https://stackoverflow.com/questions/444 ... stallation
The file simply needs to exist. – Jake Wilson Feb 27 '18 at 6:24
原因:~/.ssh/id_rsa不存在

代碼: 選擇全部

touch ~/.ssh/id_rsa
vagrant up