PHP警告:在第0行的Unknown中没有这样的文件或目录 [英] PHP Warning: No such file or directory in Unknown on line 0

查看:483
本文介绍了PHP警告:在第0行的Unknown中没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm using hosting in linux and configured subdomain in my website in Apache2 server. I'm using laravel but I didn't use apache2 service by default. I'm using laravel artisan commands.

php artisan服务--host 0.0.0.0

php artisan serve --host 0.0.0.0

它将监听端口8000.因此,为了访问我的网站,我使用了 http://myipaddress:8000 访问它.

It will listen to port 8000. So in order to access my website, I'm used http://myipaddress:8000 to access it.

我尝试"chmod 755或777公用文件夹",但仍然无法正常工作.我的.htaccess在laravel/公共文件夹中

I tried to "chmod 755 or 777 public folder" but still didn't work. My .htaccess in laravel/public folder

.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访问网站时,以下是我的错误:

When I access my website with port 8000, below is my errors:

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文件添加到 root包含以下内容的项目目录:

I know this is an old question, but I was having the same problem and I found a solution by adding a server.php file to the root directory of the project with the following content:

<?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警告:在第0行的Unknown中没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆