Laravel:在浏览器上显示 localhost:8000 时出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34457532/
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
Laravel: Error displaying localhost:8000 on browser
提问by radioactive
When I try to start Laravel artisan on a Command-line using php artisan serve
, it works because I get the "Laravel development server started on http://localhost:8000/".
当我尝试在命令行上使用 启动 Laravel artisan 时php artisan serve
,它可以工作,因为我得到“Laravel 开发服务器在http://localhost:8000/ 上启动”。
However, when I try to run 'localhost:8000'on my web browser, I get this error:
但是,当我尝试在 Web 浏览器上运行'localhost:8000'时,出现以下错误:
"Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
Fatal error: Unknown: Failed opening required 'C:\xampp\htdocs\laravel\laravel/server.php' (include_path='.;C:\xampp\php\PEAR') in Unknown on line 0"
“警告:未知:无法打开流:在第 0 行的未知中没有这样的文件或目录
致命错误:未知:在第 0 行的未知中打开所需的 'C:\xampp\htdocs\laravel\laravel/server.php' (include_path='.;C:\xampp\php\PEAR') 失败
回答by Udhav Sarvaiya
In your project folder, the server.php
file is missing so you got this error
在您的项目文件夹中,server.php
文件丢失,因此您收到此错误
The solution will to create another project then copy the newly created server.phpthis will solve it.
解决方案将创建另一个项目,然后复制新创建的server.php这将解决它。
Another Solution is:
另一个解决方案是:
- Open the link: https://github.com/laravel/laravel/blob/master/server.php
- Copy all code
- Open Notepad and paste your copy code
- save Notepad file and set name server.php
- Copy the server.phpfile and paste it inside your Laravel project
- 打开链接:https: //github.com/laravel/laravel/blob/master/server.php
- 复制所有代码
- 打开记事本并粘贴您的复制代码
- 保存记事本文件并设置名称server.php
- 复制server.php文件并将其粘贴到 Laravel 项目中
Run your project again in browser Now you will not get an error and the Laravel project will work properly.
在浏览器中再次运行您的项目现在您将不会收到错误并且 Laravel 项目将正常运行。
回答by ravi chaudhary
There are 2 ways to remove this.
FIRST WAY:
(1) copy the server.php from your project folder (
c:\xampp\htdocs\laravel\public\server.php)
NOTE: laravel is name of my project
(2) the file "server.php" which you have copied, paste this file to root folder (c:\xampp\htdocs\laravel)
有 2 种方法可以删除它。第一种方法:(1) 从你的项目文件夹 (
c:\xampp\htdocs\laravel\public\server.php) 复制 server.php 注意:laravel 是我的项目的名称 (2) 文件“server.php”您已复制,将此文件粘贴到根文件夹 (c:\xampp\htdocs\laravel)
SECOND WAY: Trying add this file to root project folder https://github.com/laravel/laravel/blob/master/server.php
第二种方式:尝试将此文件添加到根项目文件夹https://github.com/laravel/laravel/blob/master/server.php
回答by Dickson Venance
I had the same issue, but it was because of bad configuration file paths.php in Boostrap folder (Laravel 4.2).
我遇到了同样的问题,但这是因为 Boostrap 文件夹(Laravel 4.2)中的配置文件路径错误。
This Line, 'public' => DIR.'/../public',
这一行,'public' => DIR.'/../public',
It seems the project i cloned had setup the the root of the project to be public, So i removed 'public' and become
我克隆的项目似乎已将项目的根设置为公开,所以我删除了“公开”并成为
'public' => DIR.'/..', and everything worked fine. I hope this will help somebody.
'public' => DIR.'/..',一切正常。我希望这会帮助某人。
So i can conclude that, on top of missing server.php file as how others have been suggesting, also Public folder path misconfiguration in Bootstrap paths.php or app.php for higher Laravel can result into that error.
所以我可以得出结论,除了像其他人所建议的那样缺少 server.php 文件之外,Bootstrap paths.php 或 app.php 中的公共文件夹路径配置错误也可能导致该错误。
回答by Vojko
Try changing your port to 8080. Maybe some other app is already in charge of port 8000 aka port in use.
尝试将您的端口更改为 8080。也许其他一些应用程序已经负责使用端口 8000 aka 端口。
回答by saleem khan
I also face that problem and after quite a time I become to solve it. it very simple to solve it.
我也面临这个问题,经过很长时间我开始解决它。解决它非常简单。
When I copy an old project to new Laravel 5.6 setups. I face this problem. so you should first install new laravel setup.
当我将旧项目复制到新的 Laravel 5.6 设置时。我面临这个问题。所以你应该首先安装新的 Laravel 设置。
copy your previously created project. when you will use php artisan serve
. you will see this type of error.
复制您之前创建的项目。当您将使用php artisan serve
. 你会看到这种类型的错误。
So it's mean in your project folder "server.php" file is missing.
所以这意味着在您的项目文件夹中缺少“server.php”文件。
copy this file from other project and paste it your project. it will run. my problem like this which was I facing solve it by this method.
从其他项目复制此文件并将其粘贴到您的项目中。它会运行。我面临的这样的问题通过这种方法解决了。