laravel 在此服务器上找不到请求的资源

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

The requested resource / was not found on this server

phpapachelaravelcloud9-ide

提问by Anna.Klee

I have created a Laravel Framework 5.5.22project on c9. I am using the php version:

Laravel Framework 5.5.22c9. 我正在使用 php 版本:

$ php --version
PHP 7.0.25-1+ubuntu14.04.1+deb.sury.org+1 (cli) (built: Oct 27 2017 14:07:59) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.25-1+ubuntu14.04.1+deb.sury.org+1, Copyright (c) 1999-2017, by Zend Technologies

When I run the php built in server I get the error No such file or directory:

当我运行内置服务器的 php 时,出现错误No such file or directory

Starting PHP built-in web server, serving https://projet-laravel-testuser.c9users.io/.
PHP 7.0.25-1+ubuntu14.04.1+deb.sury.org+1 Development Server started at Thu Nov 30 17:36:08 2017
Listening on http://0.0.0.0:8080
Document root is /home/ubuntu/workspace
Press Ctrl-C to quit.
[Thu Nov 30 17:36:16 2017] 10.240.0.100:38766 [404]: / - No such file or directory

I also tested apache2:

我还测试了 apache2:

$ apache2 -v
Server version: Apache/2.4.7 (Ubuntu)
Server built:   Sep 18 2017 16:37:54

However, here I only get a blankpage back.

但是,在这里我只能blank返回一页。

Any suggestions what I am doing wrong?

任何建议我做错了什么?

I appreciate your replies!

我感谢您的回复!

UPDATE

更新

I set:

我设置:

sudo nano /etc/apache2/sites-enabled/001-cloud9.confand added /publicto the end of line 2.

sudo nano /etc/apache2/sites-enabled/001-cloud9.conf并添加/public到第 2 行的末尾。

It looks like the following:

它看起来像下面这样:

<VirtualHost *:8080>
    DocumentRoot /home/ubuntu/workspace/public

回答by Chris Forrence

When you start up the built-in server, it looks like it's running in the project root. You can specify a -tflag to tell PHP to run the server from a different folder:

当您启动内置服务器时,它看起来像是在项目根目录中运行。您可以指定一个-t标志来告诉 PHP 从不同的文件夹运行服务器:

php -S 0.0.0.0:8080 -t public/

Don't forget to call php artisan key:generateand to fill out your .envfile if needed!

如果需要,请不要忘记致电php artisan key:generate并填写您的.env文件!

回答by azwar_akbar

This error is due to not finding the right resource folder/file. You have to make sure that when you start server you are on the right directory where the project was stored. So the solution is:

此错误是由于未找到正确的资源文件夹/文件所致。您必须确保在启动服务器时位于存储项目的正确目录中。所以解决办法是:

cd your/folder/project

and then

进而

php -S localhost:8080 -t public/

Hope it helps. Thank you.

希望能帮助到你。谢谢你。