0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Laravel-admin EC2 インストール手順 2022年版

Last updated at Posted at 2022-07-13

Laravel-AdminをEC2にインストールする手順 2022年版

パッケージのインストール

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

Databaseの準備

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の準備

/etc/httpd/conf/httpd.conf
# 以下を編集
DocumentRoot "/var/www/hoge-project/public"

<Directory "/var/www/hoge-project/public">
    AllowOverride All
</Directory>
/var/www/hoge-project/config/database.php
        // ログイン情報を記述
        '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,
        ],
/var/www/hoge-profect/config/filesystems.php
        // 以下を追記
        '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: admin
Password: admin

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?