laravel 如何在我的环境中为新站点刷新宅基地?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27085051/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 10:27:42  来源:igfitidea点击:

How can I refresh homestead for a new site in my environment?

laravellaravel-4vagrant

提问by Chris Farrugia

I'm running Laravel 4 on my development machine (Mac) with homestead and enjoying it thus far but having trouble when adding a new site. The problem is that I add lines like this for a new site in my ~/.homestead/Homestead.yaml file:

我在我的开发机器(Mac)上运行 Laravel 4 和 homestead 并享受它到目前为止但在添加新站点时遇到问题。问题是我在 ~/.homestead/Homestead.yaml 文件中为新站点添加了这样的行:

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

sites:
    - map: listingnaples.dev
      to: /home/vagrant/Sites/listingnaples.com/public

    - map: videocraftersusa.dev
      to: /home/vagrant/Sites/videocraftersusa.com/

Then, my /etc/hosts looks like this:

然后,我的 /etc/hosts 看起来像这样:

# MY SITES
192.168.10.10 listingnaples.dev
192.168.10.10 videocraftersusa.dev
192.168.10.10 laneyandchris.dev

If i go in and do a homestead destroyfollowed by homestead upI can access any of those new sites. That deletes my databases though and really sets me back. How do I "refresh" so to speak? If I add myawesomesite.dev to my /etc/hosts, how can I have homestead pick it up?

如果我进入并执行以下操作homestead destroyhomestead up我可以访问任何这些新站点。这虽然删除了我的数据库,但确实让我退缩了。可以这么说,我如何“刷新”?如果我将 myawesomesite.dev 添加到我的 /etc/hosts 中,我如何让 homestead 获取它?

I tried homestead --provisionbut that isn't a recognized command.

我试过了,homestead --provision但这不是公认的命令。

For what it's worth, in my ~/.homestead/ directory, I do not have a VagrantFile. Not sure where that's at so I can't run a vagrant provision either.

无论如何,在我的 ~/.homestead/ 目录中,我没有 VagrantFile。不确定它在哪里,所以我也不能运行一个流浪者的规定。

回答by user3556337

I just ssh using homestead sshand then add this line

我只是使用 sshhomestead ssh然后添加这一行

serve domain.app /home/vagrant/Code/path/to/public/directory

where you replace domain.app to your app name, the same you use on your yaml file and your path to your new public site directory, then just homestead upand you could see it active.

您将 domain.app 替换为您的应用程序名称,与您在 yaml 文件中使用的名称和新公共站点目录的路径相同,然后homestead up您就可以看到它处于活动状态。

回答by Beaudinn Greve

You can also reload the box and the settings

您还可以重新加载框和设置

vagrant reload --provision

This reload the box and see if there are changes, if that's the case it will make the changes while reloading

这将重新加载框并查看是否有更改,如果是这种情况,它将在重新加载时进行更改

回答by lancedikson

Try run vagrant global-status. You'll see the list of running boxes at this time, like this:

尝试运行vagrant global-status。此时您将看到正在运行的框列表,如下所示:

MacBook-Pro-lancedikson:~ lancedikson$ vagrant global-status
id       name    provider   state   directory
------------------------------------------------------------------------------------------
9710b02  default virtualbox running /Users/lancedikson/.composer/vendor/laravel/homestead

The above shows information about all known Vagrant environments
on this machine. This data is cached and may not be completely
up-to-date. To interact with any of the machines, you can go to
that directory and run Vagrant, or you can use the ID directly
with Vagrant commands from any directory. For example:
"vagrant destroy 1a2b3c4d"

That's all. Now run vagrant provision 9710b02and it will be provisioned.

就这样。现在运行vagrant provision 9710b02,它将被配置。

回答by mtpultz

As of Laravel 5 and more importantly Homestead 2.0, just run:

从 Laravel 5 和更重要的 Homestead 2.0 开始,只需运行:

homestead up

Then:

然后:

homestead provision

回答by phaberest

You have to use vagrant provisionanyway from the same directory where Homestead.yamlis.

vagrant provision无论如何,您必须从同一目录 where Homestead.yamlis 使用。

回答by bgies

You can run:

你可以运行:

homestead up --provision

回答by Roderik

In my case I had a Homestead.yamlin ~/.homestead/and in ~/Homestead/.

就我而言,我有一个Homestead.yamlin~/.homestead/和 in ~/Homestead/

I am not sure if the default location changed or that I changed it manually (maybe because I did not like the hidden dir), but make sure you don't have multiple Homestead.yamlfiles. I now symlinked them so I can not confuse myself any further.

我不确定默认位置是更改了还是我手动更改了它(可能是因为我不喜欢隐藏目录),但请确保您没有多个Homestead.yaml文件。我现在对它们进行符号链接,这样我就不会再混淆自己了。

But normally, homestead provisionor homestead up --provision(when it was turned off) should do.

但通常,homestead provision或者homestead up --provision(当它被关闭时)应该可以。