我在 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/