3
4

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.

aws EC2 上に yum でインストールした phpMyAdmin を配置して RDS に接続する方法

Posted at

AWS EC2 上に yum でインストールした phpMyAdmin から RDS に接続する方法。

config.inc.php がどこにあるのかわからずにハマったのでメモ。

同じ問題に出くわしたら /etc/phpMyAdmin/config.inc.php を使えば OK。

以下、メモ。

インストール

$ sudo yum install -y --enablerepo=remi install phpmyadmin

phpMyAdmin.conf の設定

$ sudo cp /etc/httpd/conf.d/phpMyAdmin.conf /etc/httpd/conf.d/phpMyAdmin.conf.org
$ sudo vim /etc/httpd/conf.d/phpMyAdmin.conf
## (略)
   <IfModule mod_authz_core.c>
     # Apache 2.4
     # Require local       # これをコメントアウト
     Require all granted   # これを追加、 必要に応じて IP 制限とかするほうが良い。
   </IfModule>
$ sudo service httpd restart

Basic 認証を行う場合

$ sudo vim /etc/httpd/conf.d/phpMyAdmin.conf 
(略) // <Directory /usr/share/phpMyAdmin/> の「AddDefaultCharset UTF-8」の次に以下を追記
AllowOverride All
$ sudo service httpd restart
$ sudo htpasswd -c -b /usr/share/phpMyAdmin/.htpasswd BASIC認証のユーザー名 BASIC認証のパスワード
$ sudo vim /usr/share/phpMyAdmin/.htaccess
AuthUserFile /usr/share/phpMyAdmin/.htpasswd
AuthGroupFile /dev/null
AuthName "Developer Mode"
AuthType Basic
require valid-user
<Files ~ "^.(htpasswd|htaccess)$">
deny from all
</Files>

SSL アクセスのみ許可する場合

※証明書準備とか導入は事前に行っているものとする。

$ sudo vim /usr/share/phpMyAdmin/.htaccess
SSLRequireSSL # 先頭に追加
$ sudo service httpd restart

phpmyadmin から RDS へ接続できるように設定する。

config.inc.php/etc/phpMyAdmin/config.inc.php を使う。(/usr/share/phpMyAdmin/ 配下に何かをコピーして設定するのは間違い。)

$ sudo cp /etc/phpMyAdmin/config.inc.php /etc/phpMyAdmin/config.inc.php.org
$ sudo vim /etc/phpMyAdmin/config.inc.php
- $cfg['Servers'][$i]['host'] = 'localhost';
+ $cfg['Servers'][$i]['host'] = 'ここにRDSのエンドポイント';
3
4
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
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?