RancherOS上に作ったLaradock環境にLaravel-Adminをインストールメモ

  • ComposerでLaravel-Adminをインストール

    laradockディレクトリに移動して
    ./docker-compose exec workspace bash
    composer require encore/laravel-admin
    php artisan vendor:publish –provider=”Encore\Admin\AdminServiceProvider”
    php artisan admin:install

  • php artisan admin:installで、下記エラーが出たので調査

    Illuminate\Database\QueryException : SQLSTATE[HY000] [2002] Connection refused

  • MySQLの接続情報(.env)を修正(https://nobuhiroharada.com/2018/07/21/laravel-laradock-mysql-refused/)

    DB_HOST=127.0.0.1

    DB_HOST=mysql

  • 下記エラーが出たので調査

    Illuminate\Database\QueryException : SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client

  • MySQLの認証方式の変更(https://qiita.com/shunichi_com/items/9b09c5949233b88b9a4a)

    ./docker-compose exec mysql bash
    # mysql -u root -p
    パスワード:root
    mysql> SELECT user, host, plugin FROM mysql.user;
    認証方式をcaching_sha2_passwordからmysql_native_passwordに変更
    mysql> ALTER USER ‘default’@’%’ IDENTIFIED WITH mysql_native_password BY ‘secret’;
    mysql> \q
    # exit
    sudo vi mysql/my.cnf
    [mysqld]内に下記を追加
    default_authentication_plugin= mysql_native_password

  • 再度、php artisan admin:installを実行

    php artisan admin:install

    Nothing to migrate.
    Database seeding completed successfully.
    Admin directory was created: /app/Admin
    HomeController file was created: /app/Admin/Controllers/HomeController.php
    AuthController file was created: /app/Admin/Controllers/AuthController.php
    ExampleController file was created: /app/Admin/Controllers/ExampleController.php
    Bootstrap file was created: /app/Admin/bootstrap.php
    Routes file was created: /app/Admin/routes.php

  • こうなればOK。
  • さらにLaravel-Adminの動作確認。下記を開いて、admin/adminでログインできればOK。

    http://192.168.23.3/admin/auth/login

  • 以上

Comments are closed.