解放雙手 hosts 自動化 (Vagrant-hostsupdater)

iVerywang發表於2018-08-22

通常情況下我們建立一個新專案時還需要在本機 hosts 檔案新增 host,但是如果按下面的方法你可以解放雙手(偷個懶)

  • Homestead 目錄下安裝(安裝外掛)

    $ vagrant plugin install vagrant-hostsupdater

    Installing the 'vagrant-hostsupdater' plugin. This can take a few minutes...
    Installed the plugin 'vagrant-hostsupdater (1.1.1.160)'!
  • 接著:(更改了 Homestead.yaml 檔案 site 後執行)

    $ vagrant reload --provision

    ==> homestead-7: [vagrant-hostsupdater]   192.168.10.10  ddang-lumen.io  # VAGRANT: b2102deda09b4ebc5eefa5a77ad71960 (homestead-7) / 53d249c4-1c8b-44fc-8d54-f9630c927abf
    .
    .
    .
    ==> homestead-7: Machine already provisioned. Run `vagrant provision` or use the `--provision`
    ==> homestead-7: flag to force provisioning. Provisioners marked to run always will still run.
  • 一切正常的話 此時 hosts 檔案應該是:
        192.168.10.10 laravel-2.watts.com # VAGRANT: d399a2b6073dccadc0d7de43f126182e (homestead-7) / f4e325ac-1865-4d28-a5cd-198236f6926d
        192.168.10.10 laravel-5.watts.com # VAGRANT: d399a2b6073dccadc0d7de43f126182e (homestead-7) / f4e325ac-1865-4d28-a5cd-198236f6926d
        192.168.10.10 laravel-6.watts.com # VAGRANT: d399a2b6073dccadc0d7de43f126182e (homestead-7) / f4e325ac-1865-4d28-a5cd-198236f6926d
        192.168.10.10 lumen-5.watts.com # VAGRANT: d399a2b6073dccadc0d7de43f126182e (homestead-7) / f4e325ac-1865-4d28-a5cd-198236f6926d
        192.168.10.10 phpmyadmin.watts.com # VAGRANT: d399a2b6073dccadc0d7de43f126182e (homestead-7) / f4e325ac-1865-4d28-a5cd-198236f6926d

    OK!

善始善終 嗯!

相關文章