LoginSignup
1
0

More than 1 year has passed since last update.

AWSのEC2内にWordPress用のWebサーバー(Apache)とデータベースサーバー(MySQL)を構築する(備忘録)

Last updated at Posted at 2022-04-29

EC2インスタンス内にApacheサーバーとMySQLサーバーを設置する

//Apacheサーバーの起動
$ systemctl start httpd

//インスタンス軌道とともにApacheサーバーが起動する設定
$ systemctl enable httpd

//phpサーバーの設定
$ amazon-linux-extras install php7.2
$ yum install -y php

//MySQLサーバーの設定
$ yum localinstall https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm -y
$ yum install -y mysql-community-server

//MySQLサーバーの起動
$ systemctl start mysqld

//インスタンス軌道とともにMySQLサーバーが起動する設定
$ systemctl enable mysqld

MySQLDBの作成

//ログインの初期パスワードを取得
$ cat /var/log/mysqld.log | grep localhost

//先ほどの新規パスワードでログイン後に、ルートユーザーに新規パスワードで作成
$ mysql -u root -p
$ alter user root@localhost identified by 'パスワード入力';

//新規データベースを作成し確認
$ create database [データベース名];
$ show databases;

//新規ユーザーを作成しパスワードを設定
$ create user [ユーザー名]@localhost identified with mysql_native_password by 'パスワードを入力';

//作成した新規ユーザーのデータベースを利用する権限を付与
$  grant all privileges on [ユーザー名].* to [ユーザー名]@localhost;
$ flush privileges;

WordPressのインストール

//WordPressをDLし解凍後にhtmlディレクトリに移動
$ wget http://ja.wordpress.org/latest-ja.tar.gz
$ tar -xzvf latest-ja.tar.gz
$ cp -r wordpress/* /var/www/html

//ApacheサーバーがWordPressを読み取れるように設定し再起動
$ chown apache:apache /var/www/html/ -R
$ systemctl restart httpd.service

WordPressの設定

Image from Gyazo

Image from Gyazo

Image from Gyazo
上記が出れば無事に成功

Image from Gyazo
作成したサイトの設定

Image from Gyazo

Image from Gyazo
早速ログインしてみる

Image from Gyazo
無事に完成!

関連記事

AWSプライベートサブネット内のインスタンスにMySQLサーバーを設置(備忘録)
AWSのEC2にApacheサーバーを設定してWebサーバーを立ち上げる(備忘録)
AWS SSH 認証のメモ(備忘録)

1
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
1
0