在AWS Amazon Linux 2上搭建Laravel 7的环境
由于要在新的Laravel7上创建项目,因此需要记录下本次构建所需的环境。
php:php 7.3
フレームワーク:Laravel 7
データベース:MariaDB 10.5.4
テンプレートエンジン:twig
ログイン管理:sentinel 4.x
中文翻译:
php:php 7.3
框架:Laravel 7
数据库:MariaDB 10.5.4
模板引擎:twig
登录管理:sentinel 4.x
由于这是一项对以前使用PHP编写的项目进行的改进工作,所以我们将使用相同的模板引擎和登录管理工具。
从EC2启动到安装php、apache、Composer和Laravel。
参考上述页面在Amazon Linux 2上搭建Laravel开发环境。
安装和配置MariaDB。
可以通过设置仓库并下载,安装MariaDB-Server(注意字母M和DB都是大写),因为yum默认安装的MariaDB版本是5.5。
$ 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]部分中添加以下配置。
[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
在Laravel中安装Twig,使用Twig桥接包rcrowe/twigbridge安装。
$ composer require rcrowe/twigbridge
哨兵安装
$ composer require caratalyst/sentinel "^4.0"
文献引用
在AmazonLinux2上搭建Laravel的开发环境
在CentOS 7上安装最新版的MariaDB Community Server
将mariaDB引入到EC2(Amazon Linux 2)中
简单!使用Laravel展示twig模板引擎的实例
Sentinel手册Cartalyst 4.x