如何获得一个PHP-Laravel宅基地流浪汉盒?

时间:2019-08-22 13:26:29

标签: php laravel vagrant homestead

我已经安装了Virtualbox Ubuntu,并使用

在其上安装了Vagrant
apt-get install vagrant

,没什么。

据此:https://laravel.com/docs/5.8/homestead我已经尝试过:

vagrant box add laravel/homestead

在此操作无效后,我使用了:

git clone https://github.com/laravel/homestead.git ~/Homestead

bash init.sh

这似乎很好用。
所以我进入了我的代码(和Vagrant文​​件)所在的文件夹,并尝试了

vagrant box add

(因为我找不到.box文件或类似的东西...我需要一个吗?)

现在我得到了错误:

  

消息:LoadError:无法加载此类文件-   /media/sf_contractManager/project1/backend/vendor/laravel/homestead/scripts/homestead.rb

我在做什么错了?
据我了解流浪者,我应该从流浪者框中获得完整的环境/虚拟机,还是?无需在Vagrant框内(或在Virtualbox级别上)安装php,mysql等。 它是否正确? 如何调出“无业游民”盒子?

1 个答案:

答案 0 :(得分:2)

  

所以我进入了我的代码所在的文件夹(和   流浪文件),然后尝试

vagrant box add
     

(因为我找不到.box文件或类似的文件...我需要   一个??

您不需要这样做,因为您已经在上一步中添加了一个框。 Box是在Vagrant / VirtualBox级别而不是您的项目级别/ Laravel级别处理的。

层次结构

VirtualBox
|-Vagrant
  |-Vagrant box (environment for your project)
  | |-your project
  | |-another project
  |-another Vagrant box
    |-another project

要显示内容,您必须转到Homestead.yaml所在的文件夹并运行vagrant up

记住要在init.sh之前运行vagrant up

  

无需在无业游民框内(或外部)安装php,mysql等   在virtualbox级别)。这是正确的吗?

You are right。但是,您必须指定在项目中需要使用的所有“工具”。例如,某些PHP / MySQL版本。


例如,全新的安装方式(由我本人在18.04上测试):

  1. 使用首选方式(apt-get或使用归档文件或其他方式)安装VagrantVirtualBoxHow to install from .deb file。我的看法是:手动获取源存档和isntall。这样,您可以控制所安装软件的版本。而且您还将拥有一些经验。
  2. cd ~(转到主目录)
  3. vagrant box add laravel/homestead
  4. git clone https://github.com/laravel/homestead.git ~/Homestead
  5. cd ~/Homestead
  6. git checkout release
  7. bash init.sh./init.sh。确保bash脚本可执行。或使用
sudo chmod +x init.sh

使其可执行。

  1. Configure Homestead.yaml with providers you need
  2. vagrant up(位于Homestead目录中)。
  3. 如果您的项目是一个网站,则可能要从主机访问它。因此,您必须使用/etc/hosts来编辑192.168.10.10 mywebiste.local文件。您可以在homestead.yaml中找到IP。

您可以在docs中找到更多信息。

相关问题