PHP 警告 : No such file or directory in Unknown on line 0

标签 php apache .htaccess laravel

我在 Linux 中使用托管,并在 Apache2 服务器的网站中配置了子域。我正在使用 laravel,但默认情况下我没有使用 apache2 服务。我正在使用 laravel artisan 命令。

php artisan serve --host 0.0.0.0

它会监听8000端口。所以为了访问我的网站,我使用了http://myipaddress:8000。访问它。

我试过“chmod 755 or 777 public folder”但还是没用。我的 .htaccess 在 laravel/public 文件夹中

.htaccess

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On

# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

当我使用端口 8000 访问我的网站时,以下是我的错误:

PHP Warning:  Unknown: failed to open stream: No such file or directory in Unknown on line 0

PHP Fatal error:  Unknown: Failed opening required 'server.php' (include_path='.:/usr/share/php:/usr/share/php/PEAR') in Unknown on line 0

最佳答案

我知道这是一个老问题,但我遇到了同样的问题,我通过将 server.php 文件添加到 根目录 找到了解决方案项目内容如下:

<?php
$uri = urldecode(
    parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);

// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri))
{
    return false;
}

require_once __DIR__.'/public/index.php';

关于PHP 警告 : No such file or directory in Unknown on line 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28893474/

相关文章:

php - 类似 jQuery Facebook 的评论系统

PHPExcel 公式在 HTML 中不起作用

apache - 访问没有上下文根的应用程序 URL

java - 从 HTTP Post 接收 XML

php - 更改我所有的网站链接 : what is the best way?

PHP 解析错误 : syntax error, 意外的 T_STRING,期待 T_FUNCTION

php - 部分删除/销毁 $_SESSION 数据? PHP

php - 让 localhost 在 mac OS X Yosemite 上运行

php - .htaccess 通过 PHP 显示 404、403、500、错误页面

php - 使用 htaccess 格式化个人资料网址