我过去已经能够成功地部署 Laravel 项目。我第一次将 Laravel 8 与 Jetstream 和 Livewire 一起使用。Laravel 现在使用 Fortify 进行登录和注册验证。
我的本地服务器运行良好,没有问题。将项目部署到 Hostgator 共享主机帐户后,我的主页正确加载并正确读取和输出数据库中的数据。
但是,当我尝试访问
mydomain.com/login/ 或 mydomain.com/login 或 mydomain.com/register/ 或 mydomain.com/register
我收到 500 错误。在这个问题的最后,我粘贴了错误日志。
我做了以下事情:
- 更新作曲家版本
- npm 重建
- npm 安装
- 我尝试了两个: npm run dev 和 npm run production 并在每个场景中重新上传了所有内容。
- 我已将 public/index.php 路径指向正确的应用程序文件夹以读取 autoload.php 和 bootstrap/app.php 文件。
- 我有 chmod 所有文件夹和子文件夹到 755 和所有文件到 644
我发现我的主页加载完美无瑕并从数据库中带来数据真的很奇怪,因此我知道我的 .env 文件具有正确的数据库连接凭据。只有登录和注册会抛出 500 错误。
我的环境文件:
APP_NAME=NameOfApp
APP_ENV=production
APP_KEY=base64:KeyGeneratedWhenProjectCreated
APP_DEBUG=false
APP_URL=http://domain
LOG_CHANNEL=stack
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=db_works_good
DB_USERNAME=username_works_good
DB_PASSWORD=passwordWorksGood
这是 laravel.log(缩短为似乎很重要的内容):
[2020-11-30 20:25:34] production.ERROR: The Mix manifest does not exist. (View: /domain_root_path/app/resources/views/layouts/guest.blade.php) (View: /domain_root_path/app/resources/views/layouts/guest.blade.php) {"exception":"[object] (ErrorException(code: 0): The Mix manifest does not exist. (View: /domain_root_path/app/resources/views/layouts/guest.blade.php) (View: /domain_root_path/app/resources/views/layouts/guest.blade.php) at /domain_root_path/app/vendor/laravel/framework/src/Illuminate/Foundation/Mix.php:46)
[stacktrace]
#0 /domain_root_path/app/vendor/livewire/livewire/src/CompilerEngine.php(38): Illuminate\\View\\Engines\\CompilerEngine->handleViewException(Object(ErrorException), 0)
#1 /domain_root_path/app/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(60): Livewire\\CompilerEngine->handleViewException(Object(ErrorException), 0)
#2 /domain_root_path/app/vendor/livewire/livewire/src/LivewireViewCompilerEngine.php(32): Illuminate\\View\\Engines\\PhpEngine->evaluatePath('/home2/usr2...', Array)
...................
#52 /domain_root_path/public_html/index.php(52): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#53 {main}
[previous exception] [object] (Exception(code: 0): The Mix manifest does not exist. at /domain_root_path/app/vendor/laravel/framework/src/Illuminate/Foundation/Mix.php:46)
[stacktrace]
#0 /domain_root_path/app/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(506): Illuminate\\Foundation\\Mix->__invoke('/css/app.css')
#1 /domain_root_path/app/storage/framework/views/f25b68bee7f180a7da8624828693071be98325dc.php(14): mix('css/app.css')
#2 /domain_root_path/app/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(107): require('/home2/usr2...')
............................................
#66 {main}
文件结构:
root 有两个文件夹:
- 应用程序(具有除公用文件夹以外的所有文件)
- public_html :包含所有公共内容,包括 index.php
我的 index.php (公共内部)具有以下路径:
require __DIR__.'/../app/vendor/autoload.php';
$app = require_once __DIR__.'/../app/bootstrap/app.php';
GUEST.BLADE.PHP 看起来像这样:(请注意,这个文件是 Laravel 自动生成的,我没有碰过它)
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
<!-- Fonts -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap">
<!-- Styles -->
<link rel="stylesheet" href="{{ mix('css/app.css') }}">
<!-- Scripts -->
<script src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v2.7.3/dist/alpine.js" defer></script>
</head>
<body>
<div class="font-sans text-gray-900 antialiased">
{{ $slot }}
</div>
</body>
</html>
/public/mix-manifest.json:
{
"/js/app.js": "/js/app.js",
"/css/app.css": "/css/app.css"
}