LB+ec2環境にphpmyadminを入れる

September 20, 2014

MySQLのホストはRDSでも、EC2でも。

phpmyadminインストール

# yum -y install phpMyAdmin

config.inc.phpで接続情報を設定

# vi /usr/share/phpMyAdmin/config.inc.php
-$cfg['Servers'][$i]['host']          = ''; // MySQL hostname or IP address
+$cfg['Servers'][$i]['host']          = 'ip-xxx-xxx-xxx-xx.xx-xxxxx-1.compute.internal'; // MySQL hostname or IP address

-$cfg['Servers'][$i]['user']          = '';          // MySQL user
+$cfg['Servers'][$i]['user']          = 'mysqluser';          // MySQL user

-$cfg['Servers'][$i]['password']      = '';          // MySQL password (only needed
+$cfg['Servers'][$i]['password']      = 'mysqluserpassword';          // MySQL password (only needed

conf.d/phpMyAdmin.confのでアクセス制御

# vi /etc/httpd/conf.d/phpMyAdmin.conf
+SetEnvIf X-Forwarded-For "xxx\.xxx\.xxx\.xxx" allowed_access
+SetEnvIf REMOTE_ADDR "xxx\.xxx\.xxx\.xxx" allowed_access

<Directory /usr/share/phpMyAdmin/>
   Order Deny,Allow
   Deny from All
   Allow from 127.0.0.1
+   Allow from env=allowed_access
</Directory>

<Directory /usr/share/phpMyAdmin/scripts/>
   Order Deny,Allow
   Deny from All
   Allow from 127.0.0.1
+   Allow from env=allowed_access
</Directory>

httpdのreload

# /etc/init.d/httpd reload


Recent blog posts



(c) Copyright 2023 Kotaro Yoshimatsu