Laravel-admin EC2 安装步骤 2022 版

2022年版EC2上安装Laravel-Admin的步骤

安装包

sudo amazon-linux-extras install -y php7.4
sudo yum install -y php-xml
sudo yum install -y php-mbstring
sudo amazon-linux-extras install -y mariadb10.5
sudo yum install httpd httpd-devel
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

自动启动设置

# mysql
sudo systemctl start mariadb
sudo systemctl enable mariadb
sudo systemctl is-enabled mariadb
sudo mysql_secure_installation

# httpd
sudo systemctl start httpd
sudo systemctl enable httpd
sudo systemctl is-enabled httpd

安装Laravel

sudo su -
cd /var/www/
composer create-project "laravel/laravel=5.6.*" hoge-project

cd hoge-project
composer require encore/laravel-admin

准备数据库

mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.5.10-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database hoge-project;
Query OK, 1 row affected (0.000 sec)

MariaDB [(none)]> ^DBye

准备Config

# 以下を編集
DocumentRoot "/var/www/hoge-project/public"

<Directory "/var/www/hoge-project/public">
    AllowOverride All
</Directory>
        // ログイン情報を記述
        'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'hoge-project'),
            'username' => env('DB_USERNAME', 'root'),
            'password' => env('DB_PASSWORD', 'xxxxxxxxx'),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],
        // 以下を追記
        'admin' => [
            'driver' =>'local',
            'root' => public_path('uploads'),
            'visibility' =>'public',
            'url' => env('APP_URL').'/uploads',
        ],

权限相关

将/var/www/hoge-project更改为apache.apache。

更新设定

php artisan admin:install
php artisan config:cache
php artisan vendor:publish --provider="Encore\Admin\AdminServiceProvider"

确认行动

 

ID:管理员
密码:管理员

广告
将在 10 秒后关闭
bannerAds