使用 Laravel Homestead:“未指定输入文件”

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

Using Laravel Homestead: 'no input file specified'

laravellaravel-4vagrant

提问by bryant

I am new to using Laravel, and Homestead, and would appreciate any help or a point in the right direction. I have successfully been able to get to the "You have arrived" screen when I run "php artisan serve" but when I try to do the same thing via Vagrant, I get "no input file specified". My Homestead.yaml file looks like this:

我是使用 Laravel 和 Homestead 的新手,希望得到任何帮助或正确方向的观点。当我运行“php artisan serve”时,我已经成功地进入了“你已经到达”屏幕,但是当我尝试通过 Vagrant 做同样的事情时,我得到“没有指定输入文件”。我的 Homestead.yaml 文件如下所示:

authorize: /Users/me/.ssh/id_rsa.pub

keys:
    - /Users/me/.ssh/id_rsa

folders:
    - map: /Users/me/code/exampleproject
      to: /home/vagrant/code/exampleproject

sites:
    - map: exampleproject.app
      to: /home/vagrant/code/exampleproject/public

variables:
    - key: APP_ENV
      value: local

On my computer I have the following directories:

在我的电脑上,我有以下目录:

/Users/me/code/Homestead
/Users/me/code/exampleproject //this is the directory created with composer

On my Vagrant Box I have for some reason two directories named "code" and "Code":

在我的 Vagrant Box 上,出于某种原因,我有两个名为“code”和“Code”的目录:

/home/vagrant/code/exampleproject 
/home/vagrant/Code

I have checked and I can see changes made to my computer exampleproject files are reflected in the vagrant box files.

我已经检查过,我可以看到对我的计算机示例项目文件所做的更改反映在 vagrant box 文件中。

Not really sure how to figure this out!! I would really appreciate any help possible :)

真的不知道如何解决这个问题!!我真的很感激任何可能的帮助:)

回答by sleimanx2

Instead of reinstalling try

而不是重新安装尝试

vagrant up --provision

or

或者

homestead up --provision

回答by Rudy Jessop

I had the same exact problem and found the solution through the use of larachat.

我遇到了同样的问题,并通过使用 larachat 找到了解决方案。

Here's how to fix it you need to have your homestead.yaml file settings correct. If you want to know how its done follow Jeffery Way tutorial on homestead 2.0 https://laracasts.com/lessons/say-hello-to-laravel-homestead-two.

这是修复它的方法,您需要让 homestead.yaml 文件设置正确。如果你想知道它是如何完成的,请遵循 Homestead 2.0 https://laracasts.com/lessons/say-hello-to-laravel-homestead-two上的 Jeffery Way 教程。

Now to fix Input not specifiedissue you need to ssh into homestead box and type

现在要解决Input not specified问题,您需要通过 ssh 进入 homestead 框并输入

serve domain.app /home/vagrant/Code/path/to/public/directorythis will generate a serve script for nginx. You will need to do this everytime you switch projects.

serve domain.app /home/vagrant/Code/path/to/public/directory这将为 nginx 生成一个服务脚本。每次切换项目时都需要这样做。

He also discussed what I explained in this series https://laracasts.com/series/laravel-5-fundamentals/

他还讨论了我在本系列中解释的内容https://laracasts.com/series/laravel-5-fundamentals/

回答by Truc

This is easy to fix, because you have changed the folder name to: exampleproject

这很容易修复,因为您已将文件夹名称更改为:exampleproject

So SSH to your vagrant:

所以SSH到你的流浪者:

ssh [email protected] -p 2222

Then change your nginx config:

然后更改您的 nginx 配置:

sudo vi /etc/nginx/sites-enabled/homestead.app

须藤vi /etc/nginx/sites-enabled/homestead.app

Edit the correct URIto the root on line 3 to this with the new folder name:

使用新文件夹名称将第 3 行上的根目录的正确 URI编辑为此:

root "/Users/MYUSERNAME/Code/exampleproject/public";

Restart Nginx

重启 Nginx

sudo service nginx reload

Reload the web browser, it should work now

重新加载网络浏览器,它现在应该可以工作了

回答by Dave Chambers

For me the following worked:

对我来说,以下工作有效:

vagrant reload --provision

vagrant reload --provision

回答by Senthil

Giving my response just in case if anybody struggling with this issue.

给出我的回应,以防万一有人在这个问题上挣扎。

  1. You might need to verify that the server.root configuration in "/etc/ngnx/sites-available/domain" matching with your sites.to config in "Homestead.yaml".

  2. If its not matching then change it and restart the webserver with "sudo service nginx restart"

  3. And still things are not working then allow write permission for the "YOURSITE/app/storage" folder as "chmod -R 777 app/storage"

  1. 您可能需要验证“/etc/ngnx/sites-available/domain”中的 server.root 配置与“Homestead.yaml”中的sites.to 配置匹配。

  2. 如果它不匹配,则更改它并使用“sudo service nginx restart”重新启动网络服务器

  3. 仍然无法正常工作,然后允许将“YOURSITE/app/storage”文件夹的写权限设为“chmod -R 777 app/storage”

回答by Arda

I also had the same problem, I had assumed that Laravel is installed "out of the box" but it seems it isn't. I SSH'ed to the machine and ran these commands:

我也遇到了同样的问题,我以为 Laravel 是“开箱即用”安装的,但似乎不是。我通过 SSH 连接到机器并运行以下命令:

cd Code
sudo composer self-update #not necessary, but I did it anyways
composer create-project laravel/laravel Laravel --prefer-dist

And everything was running as usual.

一切都照常运行。

回答by Rayzor

This issue occurred for me after editing the Homestead.yaml. I resolved this issue by

编辑 Homestead.yaml 后,我遇到了这个问题。我解决了这个问题

homestead destroy
homestead up

回答by lightup

I had the same issues

我有同样的问题

But forgot that the specs said the configuration file would be located at

但是忘了规范说配置文件将位于

~/.homestead/Homestead.yaml and was updating ~/Homestead/src/stubs/Homestead.yaml

~/.homestead/Homestead.yaml 并且正在更新 ~/Homestead/src/stubs/Homestead.yaml

So the FIX was to update the Homestead.yaml located here at

所以 FIX 是更新位于这里的 Homestead.yaml

~/.homestead/Homestead.yaml

~/.homestead/Homestead.yaml

Before

sites: - map: homestead.app to: /home/vagrant/Laravel/public

sites: - map: homestead.app to: /home/vagrant/Laravel/public

After

sites: - map: homestead.app to: /home/vagrant/Code/mysitename/public

sites: - map: homestead.app to: /home/vagrant/Code/mysitename/public

Then I ran
vagrant up --provision

然后我跑了
vagrant up --provision

Hope this works for anyone else.

希望这对其他人有用。

回答by yper

After I renamed some directories, I had to destroy and rerun vagrant. None of the solutions here worked.

在我重命名一些目录后,我不得不销毁并重新运行 vagrant。这里的解决方案都没有奏效。

This worked for me:

这对我有用:

vagrant destroy
vagrant up

回答by Nava Bogatee

I am using Windows 10 and has the following Homestead configuration

我正在使用 Windows 10 并具有以下 Homestead 配置

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

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa
folders:
    - map: ~/code               #folder in local computer where codes are stored eg, c:\xampp\htdocs\project1
      to: /home/vagrant/code    #folder in the VM where the above code will be mapped

sites:
    - map: homestead.local          #fake name of the site (redirect this domain to the above IP ie 192.168.10.10 in hosts file ie, c:\windows\system32\etc\hosts)
      to: /home/vagrant/code/public #complete path to index.php file in the local computer to be utilized by homestead.local 
databases:
    - homestead

I PINGed the homestead.local domain and was getting results.

PING编辑了 homestead.local 域并获得了结果。

But when I typed http://homestead.localin the browser, I got 'no input file specified'error

但是当我在浏览器中输入http://homestead.local时,出现“未指定输入文件”错误

I checked the code/public folder and there was no index file. I was sure the system was looking for the default file which was somehow missing.

我检查了代码/公共文件夹,没有索引文件。我确信系统正在寻找不知何故丢失的默认文件。

Once I created an index file it started working fine.

一旦我创建了一个索引文件,它就开始正常工作。

Update:

更新:

Next time it happened after a change in the Homestead.yamlfile, I ran vagrant reload --provisioncommand and it worked.

下次它发生在Homestead.yaml文件更改后,我运行了vagrant reload --provision命令并且它起作用了。

It looks that running vagrant reloadonly will not provision the vagrant box. Read here

看起来vagrant reload只运行不会提供流浪盒。在这里阅读