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 3 years have passed since last update.

AWS Amazon linux 2でLaravel7の環境構築

Last updated at Posted at 2020-07-20

新たにLaravel7でプロジェクトを作成する事になったため、今回必要な環境の構築覚書。

php :php 7.3
フレームワーク :Laravel 7
データベース  :MariaDB 10.5.4
テンプレートエンジン:twig
ログイン管理 :sentinel 4.x

以前素のphpで書かれていたプロジェクトの改修なのでテンプレートエンジンとログイン管理は該当プロジェクトと同じものを使用する事に。

EC2立ち上げからphp,apache,Composer,Laravelのインストールまで

[AmazonLinux2でLaravelの開発環境構築](https://qiita.com/h19e/items/02d1301d4fdd8dfa88ac) 上記ページを参考に行う。

MariaDBのインストールと設定

 yumデフォルトでインストールできるmaria-dbはバージョン5.5の為、レポジトリを設定してダウンロードする。  インストール時は MariaDB-server の綴りに注意。(MとDBが大文字)
$ curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
$ sudo yum install MariaDB-server

データベースの文字列をUTF-8に設定する。/etc/my.cnf.d/server.cnf の [mariadb] セクションに以下の設定を追加。

/etc/my.cnf.d/server.cnf
[mariadb]
character-set-server=utf8

有効化~開始~セキュリティ設定

$ sudo systemctl enable mariadb
$ sudo systemctl start mariadb

$ sudo mysql_secure_installation
Set root password? [Y/n]
Remove anonymous users? [Y/n]
Disallow root login remotely? [Y/n]
Remove test database and access to it? [Y/n] n
Reload privilege tables now? [Y/n]
 ...
Thanks for using MariaDB!

ログイン~文字コード確認

# ログイン
mysql -u root  -p

Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 23
Server version: 10.5.4-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)]> show variables like 'char%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

# ログアウト
MariaDB [(none)]> exit
Bye

twigインストール(LaravelでTwigを利用する専用パッケージrcrowe/twigbridgeのインストール)

$ composer require rcrowe/twigbridge

Sentinelインストール

$ composer require caratalyst/sentinel "^4.0"

参考文献

[AmazonLinux2でLaravelの開発環境構築](https://qiita.com/h19e/items/02d1301d4fdd8dfa88ac) [CentOS 7 に MariaDB Community Server 最新版をインストール] (https://mariadb.com/ja/resources/blog/install-mariadb-server-centos7/) [EC2(Amazon Linux 2)にmariaDBを導入する] (https://qiita.com/PAmatsuti/items/ed89719a1f4f579bd01a) [簡単!Laravelでtwigテンプレートエンジンを使う実例] (https://blog.capilano-fw.com/?p=2678) [Sentinel Manual Cartalyst 4.x] (https://cartalyst.com/manual/sentinel/4.x#installation)
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?