Laravel Homestead 安装:bash init.sh 不工作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27950807/
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:42:07  来源:igfitidea点击:

Laravel Homestead Installation: bash init.sh not working

phpgitbashlaravelhomestead

提问by Maxim Laco

I'm trying to install Laravel Homestead in order to be able to test my Laravel projects locally.

我正在尝试安装 Laravel Homestead,以便能够在本地测试我的 Laravel 项目。

I'm following this tutorial: http://laravel.com/docs/4.2/homestead

我正在关注本教程:http: //laravel.com/docs/4.2/homestead

In the "Installing Homestead" part I followed the second step "Manually Via Git (No Local PHP)",I don't have any PHP installed locally and can't use Composer. (Wasn't PHP supposed to be installed as part of Homestead?)

在“安装 Homestead”部分中,我遵循了第二步“手动通过 Git(无本地 PHP)”,我在本地没有安装任何 PHP,无法使用 Composer。(PHP 不应该作为 Homestead 的一部分安装吗?)

I got to this part:

我到了这部分:

Once you have installed the Homestead CLI tool, run the bash init.sh command to create the Homestead.yaml configuration file:

bash init.sh

安装 Homestead CLI 工具后,运行 bash init.sh 命令来创建 Homestead.yaml 配置文件:

bash init.sh

In command prompt I tried to enter the following command:

在命令提示符下,我尝试输入以下命令:

bash init.sh

I got the following error:

我收到以下错误:

'bash' is not recognized as an internal or external command, operable program or batch file.

Then I tried to enter the same command in Git Bash, and I got the following error:

然后我尝试在 Git Bash 中输入相同的命令,出现以下错误:

bash: init.sh: No such file or directory

bash: init.sh: 没有那个文件或目录

When I tried to enter in Git Bash simply

当我试图简单地进入 Git Bash 时

init.sh

init.sh

I got the following error:

我收到以下错误:

sh.exe": init.sh: command not found

sh.exe": init.sh: command not found

回答by user3430353

I ran into this problem well. You need to hop into your terminal (I am on Mac.)

我很好地遇到了这个问题。你需要跳进你的终端(我在 Mac 上。)

  • Type into your console: cd ~/Homestead
  • and to make sure you are in your newly generated Homestead folder (you can always click Finder > your home directory > Homesteadto confirm it's where it should be),
  • then while in terminal simply type ls-- if it lists all of the files like Vagrantfile, composer.lockand bash init.sh, you should be in.
  • 输入您的控制台: cd ~/Homestead
  • 并确保您位于新生成的 Homestead 文件夹中(您可以随时单击Finder > your home directory > Homestead以确认它应该在何处),
  • 然后在终端中简单地输入ls- 如果它列出了所有文件,如Vagrantfile,composer.lock和 bash init.sh,你应该在。

Once you know you are in the correct Homestead folder, it is now at that pointin which you run bash init.sh

一旦你知道你在正确的 Homestead 文件夹中,现在就是你运行的那个点bash init.sh

After doing this it now says Homestead initialized!

这样做之后,它现在说 Homestead initialized!

回答by James Durkee

.shis a unix/linux script executable, that isn't recognized on Windows. There's a init.batincluded in the package, but it isn't referenced in the tutorial.

.shunix/linux 脚本可执行文件,在Windows上无法识别。包中包含一个init.bat,但本教程中没有引用它。

Just run init.batfrom the command line. It will copy the files to:

只需从命令行运行init.bat。它将文件复制到:

%HOMEDRIVE%%HOMEPATH%\.homestead

回答by Yoel Monzon

You need install Git Bash, and then run commands into Git Bash.

您需要安装 Git Bash,然后在 Git Bash 中运行命令。

回答by NewbieCoder

I found the answer you may be looking for. I was having the same problems with this. Just make sure at the end of bash init.sh you put a ;

我找到了您可能正在寻找的答案。我遇到了同样的问题。只需确保在 bash init.sh 的末尾放置一个 ;

So in the git bash cmd you will have this line

所以在 git bash cmd 你会有这一行

$ bash init.sh;

$ bash init.sh;

回答by doglabel

Just do it using sudo.

只需使用 sudo 即可。

$sudo bash init.sh