为什么 Voyager 上线时不显示我的管理仪表板? | Forge、航海者号和 Laravel

Why Will Voyager Not Show my Admin Dashboard When Live? | Forge, Voyager & Laravel

我正在创建一个 Laravel 电子商务应用程序。我在 youtube 上关注这个教程:https://www.youtube.com/watch?v=L3EbWJmmyjo&list=PLEhEHUEU3x5oPTli631ZX9cxl6cU_sDaR&index=18

对于网站的管理部分,我使用的是 Voyager。在我的本地主机上,一切似乎都运行良好:

登陆页面(http://localhost:8000):

然后当我输入 link: http://localhost:8000/admin 时,它会将我带到 http://localhost:8000/admin/login:

然后我输入这些凭据(图像也显示数据库)。如您所见,凭据匹配,当我按下登录键时,我被带到仪表板:

到目前为止所有的屏幕截图都在我的本地主机上。当我尝试在我的实时网站上安装 Voyager 时,它停止工作了!这是我的实时网址:https://janinevalerieaesthetics.com

我正在使用 Forge 和 Envoyer 进行托管。他们正在 link 使用我的 GitLab 帐户:https://gitlab.com/rossi99/salonwebsite

我通过我的终端使用 ssh 连接到我的 Forge 服务器 link: ssh forge@janinevalerieaesthetics.com

然后我一直 cd 到当前目录(包含我所有文件夹的目录,包括 'vendor' 文件和 'artisan')然后我使用 php artisan安装航海者包的命令(https://voyager-docs.devdojo.com/getting-started/installation):

  1. 正在更改 .env 文件:

安装步骤:

APP_URL=http://localhost

我的.env:

APP_URL=https://janinevalerieaesthetics.com

安装步骤:

DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

我的.env:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=forge
DB_USERNAME=forge
DB_PASSWORD="**************"

我从我的终端 forge@salonWebsite:~/janinevalerieaesthetics.com/current$ :

php artisan voyager:install

然后我使用这个命令从同一个终端创建一个用户:

php artisan voyager:admin your@email.com --create

这是我的实时数据库 tables:

这里是角色 table(您可以看到 ID 为 1 的用户是管理员):

但是当我导航到 https://janinevalerieaesthetics.com/admin/login 时,它显示登录屏幕:

但是当我使用正确的凭据登录时,它没有让我登录并显示管理仪表板,而是让我登录并带我进入登录页面,当我尝试手动登录时,它只是将我重定向到着陆页:

我为遇到此问题的其他人找到了答案。当我检查我的 'seeds' 目录时,我没有 'DatabaseSeeder.php' 文件。然后我通过简单地右键单击然后在 mt seeds 目录中创建 DatabaseSeeder.php 来创建它,然后我将这段代码添加到其中:

<?php
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $this->call(VoyagerDatabaseSeeder::class);
    }
}

然后我不得不返回我的终端并运行执行以下命令:

ssh forge@janinevalerieaesthetics.com

cd janinevalerieaesthetics.com 
(this will be your web address, to find this run command "ll -la" after ssh command)

cd current

cd database

cd seeds

vim DatabaseSeeder.php
(this will allow you to see that the most up to date seed it being used, ':q' to exit)

cd ../
(to go back to 'database' directory)

cd ../
(to go back to 'current' directory)

php artisan db:seed
(this will popuate all the roles and tables that voyager needs)

(you might see a message like this, type yes)
**************************************
*     Application In Production!     *
**************************************

 Do you really wish to run this command? (yes/no) [no]:
 > yes

这将填充您实时站点的数据库。然后我尝试使用现有用户登录,但没有成功。我必须在“/current$”目录中使用此命令创建一个新的管理员用户:

php artisan voyager:admin admin@admin.com --create

<replace admin@admin.com with your own user email>

然后系统会提示您输入管理员的用户名和密码,输入这些后您可以导航至:https://yourURL.com/admin/login 并输入您的用户的详细信息,您将被导航至仪表板!