【问题标题】:The requested resource / was not found on this server在此服务器上找不到请求的资源 /
【发布时间】:2018-05-14 17:48:38
【问题描述】:

我在c9 上创建了一个Laravel Framework 5.5.22 项目。我使用的是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

当我运行内置服务器的 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

我也测试了apache2:

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

但是,在这里我只得到一个blank 页面。

任何建议我做错了什么?

感谢您的回复!

更新

我设置:

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

如下所示:

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

【问题讨论】:

  • /home/ubuntu/workspace 存在吗?
  • 我在c9上的用户路径是:admin:~/workspace (master) $ pwd /home/ubuntu/workspace
  • 您是从 Laravel 项目的根目录还是从项目的“公共”文件夹中提供服务?应该是后者。
  • 当你启动内置服务器时,你使用的完整命令是什么?
  • 好的,添加-t public/。出于好奇,您是从“运行项目”开始的吗?

标签: php apache laravel cloud9-ide


【解决方案1】:

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

php -S 0.0.0.0:8080 -t public/

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

【讨论】:

    【解决方案2】:

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

    cd your/folder/project
    

    然后

    php -S localhost:8080 -t public/
    

    希望对您有所帮助。谢谢。

    【讨论】:

      猜你喜欢
      • 2016-11-02
      • 2017-05-09
      • 2014-09-21
      • 2019-12-17
      • 2021-09-10
      • 2018-11-05
      • 1970-01-01
      • 2021-03-07
      • 2021-05-10
      相关资源
      最近更新 更多