LoginSignup
4
8

More than 5 years have passed since last update.

PHPMyAdminインストール(CentOS6.8 yum)

Posted at

PHPMyAdminをCentOSへインストールする

yumが楽だったのでyumでインストールします。
Apache2.2系です。

インストール

yum --enablerepo=epel install -y  phpMyAdmin

うにょうにょとPHPやら何やら一緒にインストールされます。

httpdのconfigファイルを修正

インストールすると、/etc/httpd/conf.d/phpMyAdmin.conf
というファイルが作成されています。
これに必ずIP制限を書き込みましょう。

# phpMyAdmin - Web based MySQL browser written in php
#
# Allows only localhost by default
#
# But allowing phpMyAdmin to anyone other than localhost should be considered
# dangerous unless properly secured by SSL

Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin

<Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8

   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       Require ip 127.0.0.1
       Require ip ::1
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from 127.0.0.1
     Allow from ::1
     Allow from 111.222.333.444  # ここを追加

   </IfModule>
</Directory>

<Directory /usr/share/phpMyAdmin/setup/>
   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       Require ip 127.0.0.1
       Require ip ::1
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from 127.0.0.1
     Allow from ::1
     Allow from 111.222.333.444  # ここを追加。
   </IfModule>
</Directory>

# These directories do not require access over HTTP - taken from the original
# phpMyAdmin upstream tarball
#
<Directory /usr/share/phpMyAdmin/libraries/>
    Order Deny,Allow
    Deny from All
    Allow from None
</Directory>

<Directory /usr/share/phpMyAdmin/setup/lib/>
    Order Deny,Allow
    Deny from All
    Allow from None
</Directory>

<Directory /usr/share/phpMyAdmin/setup/frames/>
    Order Deny,Allow
    Deny from All
    Allow from None
</Directory>

# This configuration prevents mod_security at phpMyAdmin directories from
# filtering SQL etc.  This may break your mod_security implementation.
#
#<IfModule mod_security.c>
#    <Directory /usr/share/phpMyAdmin/>
#        SecRuleInheritance Off
#    </Directory>
#</IfModule>

DB接続情報を編集

DBが別のサーバにある場合は
/etc/phpMyAdmin/config.inc.php
を編集します。
ローカル環境にDBがある場合は必要ありません。

$cfg['Servers'][$i]['host']          = '111.222.333.111'; // MySQL hostname or IP address

あとは、Apacheの設定を再読込しましょう。

/etc/init.d/httpd configtest
/etc/init.d/httpd graceful

アクセスする

URLは、

http://111.222.333.444/phpMyAdmin/

のような、インストールしたサーバのIP/phpMyAdmin/となります。
実際に使う際は、phpMyAdmin.conf のalias設定でURLを変更するのがいいでしょう。

4
8
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
4
8