[英]Laravel 5.4 throws 500 error after fresh install
Information : 信息:
Php version 7.1
All extensions installed : 已安装所有扩展:
OpenSSL PHP Extension
PDO PHP Extension
Mbstring PHP Extension
Tokenizer PHP Extension
XML PHP Extension
Tried running : 尝试运行:
composer dump-autoload
composer clear-cache
artisan clear:cache
artisan config:Cache
Error in error log : 错误日志中的错误:
PHP Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /home/username/laravel/public/index.php on line 50
PHP解析错误:语法错误,意外的“类”(T_CLASS),期望的标识符(T_STRING)或变量(T_VARIABLE)或第50行/home/username/laravel/public/index.php中的“ {”或“ $”
When visiting site : HTTP ERROR 500 当访问站点时:HTTP ERROR 500
Any ideas? 有任何想法吗?
EDIT 1: 编辑1:
Content of public/index.php public / index.php的内容
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <taylor@laravel.com>
*/
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/
require __DIR__.'/../bootstrap/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once __DIR__.'/../bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
?>
How i installed laravel : 我如何安装laravel:
Logged in through SSH to server. 通过SSH登录服务器。
cd /home/username/
// Download composer & install & unistall
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
// Download laravel
/opt/cpanel/ea-php71/root/usr/bin/php /home/username_here/composer.phar create-project --prefer-dist laravel/laravel
// Create soft link
rm -rf public_html
ln -s laravel/public/ public_html
// Change ownership permissions
chown -R username_here:username_here /home/username_here/laravel
chown -R username_here:username_here /home/username_here/public_html
// Generate a key
/opt/cpanel/ea-php71/root/usr/bin/php /home/username_here/laravel/artisan key:generate
Server uses MultiPHP Manager so in order to use php version 7.1 i have to use the selected php version (/opt/cpanel/ea-php71/root/usr/bin/php) 服务器使用MultiPHP Manager,因此要使用7.1版的php,我必须使用所选的php版本(/ opt / cpanel / ea-php71 / root / usr / bin / php)
My be web server using my old PHP version 5. To solve it try 我的be web服务器使用旧的PHP版本5。要解决该问题,请尝试
sudo a2dismod php5 sudo a2enmod php7.0 sudo service apache2 restart sudo a2dismod php5 sudo a2enmod php7.0 sudo服务apache2重新启动
解决方案是与我的托管服务提供商联系,并将PHP版本更改为> = 5.6.4。
You have problem with your index.php file 您的index.php文件有问题
require __DIR__.'/../bootstrap/autoload.php';
In this line you have to replace this bootstrap with vendor because laravel 5.6 store autoload file in the vendor folder not in bootstrap folder 在这一行中,您必须用供应商替换该引导程序,因为laravel 5.6将自动加载文件存储在供应商文件夹中,而不是在引导程序文件夹中
Please remove bootstrap and add vendor and run composer dump-autoload command
than try to access :) 请删除引导程序并添加供应商,然后运行
composer dump-autoload command
不要尝试访问:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.