10
9

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

Amazon Linux 2にLAMP環境インストール

Last updated at Posted at 2018-07-22

2018年6月26日に正式版となったAmazon Linux 2にLAMP(Linux/Apache/MariaDB/PHP)環境のインストールを行った手順を以下に記します。
Amazon Linux Extrasリポジトリからlamp-mariadb10.2-php7.2をインストール,LAMP環境を構築し、WordPressが動作する状態とします。

Amazon Linux 2 インスタンスの起動

image.png

security group の設定では、My IP からのSSH, AnywhereからのHTTP/HTTPSアクセスを許可します。

image.png

Amazon Linux 2 インスタンスへの接続

SSH private key を利用してEC2インスタンスへSSH接続します。

$ ssh -i amazon-linux2-lamp.pem ec2-user@54.92.xx.xx
Warning: Permanently added '54.92.xx.xx' (ECDSA) to the list of known hosts.

       __|  __|_  )
       _|  (     /   Amazon Linux 2 AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-2/

タイムゾーンの変更

sudo su - 
timedatectl set-timezone Asia/Tokyo

Apache のインストール

yum -y install httpd
systemctl enable httpd
systemctl start httpd

webブラウザで IPv4 Public IP に記載されているグローバルIPアドレスにアクセスして Apache のテストページが表示されるか確認します。

image.png

PHP 7.2 のインストール

amazon-linux-extras install -y \
 lamp-mariadb10.2-php7.2=10.2.10_7.2.0 \
 php7.2=7.2.0

MariaDB 10.2 のインストール

yum install -y mariadb-server
systemctl enable mariadb
systemctl start mariadb

2019-05-29 時点では MariaDB 10.2.10 がインストールされました。

# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 10.2.10-MariaDB MariaDB Server

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

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

MariaDB [(none)]>

WordPress のインストール

WordPress ダウンロード/展開

現時点でのWordPress最新版をダウンロードし、DocumentRoot配下に展開します。

cd /var/www/html
wget https://ja.wordpress.org/latest-ja.tar.gz
tar xvf latest-ja.tar.gz
chown -R apache:apache .

WordPress 用データベース作成

文字コードUTF8でデータベース wordpress を作成します。

MariaDB [(none)]> create database wordpress default character set utf8;

WordPress 用 MariaDB ユーザの作成

さきほど作成したデータベースのみ全権限を持つ wordpress ユーザを作成します(ユーザ名/パスワードは適宜変更してください)。

MariaDB [(none)]> grant all on wordpress.* to wordpress@localhost identified by 'password';
MariaDB [(none)]> flush privileges;

WordPress 初期設定

webブラウザで 54.92.xx.xx/wordpress にアクセスし、WordPressの初期設定を行います。

image.png

image.png

正常にインストールが完了すると、指定したユーザ、パスワードでダッシュボードにログインできます。

image.png

image.png

10
9
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
10
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?