全新安装 laravel 5.6 在索引页中出现 HTTP 错误 500

Fresh installed laravel 5.6 getting HTTP ERROR 500 in index page

大家好,我在调试从 php 7.0 升级到 php 7.1 后新安装的 laravel 5.6 中的问题时遇到了困难。我已经为我的测试项目生成了一个应用程序密钥。将所有者更改为 www-data 并将权限更改为 777,因为它只是一个测试项目。

重新启动 php 7.1 fpm 和 NGINX 也已完成。

请注意,我可以在 运行ning php aritsan serve 命令后 运行 项目,我也是能够 ping 项目但无法使用 laraveltestauth.ng 在 URL.

中访问它

laravel.log

[2018-02-27 02:45:28] local.ERROR: Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE) {"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE) at /development/sites/www/laravelAuth/vendor/symfony/finder/Comparator/NumberComparator.php:42)
[stacktrace]
#0 /development/sites/www/laravelAuth/vendor/composer/ClassLoader.php(301): Composer\Autoload\includeFile('/development/si...')
#1 [internal function]: Composer\Autoload\ClassLoader->loadClass('Symfony\\Compone...')
#2 /development/sites/www/laravelAuth/vendor/symfony/finder/Finder.php(120): spl_autoload_call('Symfony\\Compone...')
#3 /development/sites/www/laravelAuth/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(420): Symfony\Component\Finder\Finder->depth(0)
#4 /development/sites/www/laravelAuth/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(381): Illuminate\Filesystem\Filesystem->directories('/development/si...')
#5 /development/sites/www/laravelAuth/vendor/laravel/framework/src/Illuminate/Support/helpers.php(1038): Illuminate\Foundation\Exceptions\Handler->Illuminate\Foundation\Exceptions\{closure}(Object(Whoops\Handler\PrettyPageHandler))
#6 /development/sites/www/laravelAuth/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(384): tap(Object(Whoops\Handler\PrettyPageHandler), Object(Closure))
#7 /development/sites/www/laravelAuth/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(334): Illuminate\Foundation\Exceptions\Handler->whoopsHandler()
#8 /development/sites/www/laravelAuth/vendor/laravel/framework/src/Illuminate/Support/helpers.php(1038): Illuminate\Foundation\Exceptions\Handler->Illuminate\Foundation\Exceptions\{closure}(Object(Whoops\Run))
#9 /development/sites/www/laravelAuth/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(339): tap(Object(Whoops\Run), Object(Closure))
#10 /development/sites/www/laravelAuth/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(314): Illuminate\Foundation\Exceptions\Handler->renderExceptionWithWhoops(Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#11 /development/sites/www/laravelAuth/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(287): Illuminate\Foundation\Exceptions\Handler->convertExceptionToResponse(Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#12 /development/sites/www/laravelAuth/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(188): Illuminate\Foundation\Exceptions\Handler->prepareResponse(Object(Illuminate\Http\Request), Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#13 /development/sites/www/laravelAuth/app/Exceptions/Handler.php(51): Illuminate\Foundation\Exceptions\Handler->render(Object(Illuminate\Http\Request), Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#14 /development/sites/www/laravelAuth/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(326): App\Exceptions\Handler->render(Object(Illuminate\Http\Request), Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#15 /development/sites/www/laravelAuth/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(124): Illuminate\Foundation\Http\Kernel->renderException(Object(Illuminate\Http\Request), Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#16 /development/sites/www/laravelAuth/public/index.php(55): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#17 {main}
"} 
[2018-02-27 02:45:28] local.ERROR: Exception thrown without a stack frame {"exception":"[object] (Symfony\Component\Debug\Exception\FatalErrorException(code: 16): Exception thrown without a stack frame at Unknown:0)
[stacktrace]
#0 {main}
"} 

NGINX 服务器配置

server {
    listen 80;

    root /development/sites/www/laravelAuth/public;
    index index.php index.html index.htm index.nginx-debian.html;
    server_name laraveltestauth.ng www.laraveltestauth.ng;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}

Hosthack

127.0.1.1   laraveltestauth.ng          www.laraveltestauth.ng

如果有任何我可以添加的内容,请告诉我。 提前致谢

php artisan server 运行正确的 CLI 版本和最新的 7.1。

您的网络服务器仍然是 运行 旧的 PHP 版本。确保使用最新版本正确设置。即使您删除了旧版本,您的服务器仍然可以将其 运行 保留在内存中,直到问题得到解决。

试试 service php7.0-fpm stopservice php7.1-fpm restartservice nginx restart