CentOSにyumを用いてphpMyAdminをインストールする方法

Pocket

今回、RailsのアプリケーションサーバとしてPassengerを用いていたので、その点についてちょいと考慮すれば、導入は簡単です。

1.phpMyAdmin及び関連パッケージのインストール

#yum -y install --enablerepo=epel install -y phpMyAdmin php-mysql php-mcrypt

2.設定ファイルの編集

/etc/httpd/conf.d/phpMyAdmin.conf に設定ファイルが置かれているので、設定します。アクセス許可の部分と、エイリアスの箇所を修正しています。

# 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 /pma /usr/share/phpMyAdmin

<Directory /usr/share/phpMyAdmin/>
  <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 203.xxx.yyy.zzz
    Allow from 192.168.0.1
    Allow from ::1
  </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 203.xxx.yyy.zzz
    Allow from 192.168.0.1
    Allow from ::1
  </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>

3. phpMyAdminにアクセス時にPassngerの影響が及ばないようにする

一般的には、ここまでの設定でサーバを再起動すれば動くと思いますが、今回はPassengerが動いている環境にインストールしたので、上記の例では、/pma でアクセスした際に、Passengerが処理しないように設定する必要があります。

## Name-based Virtual Host Settings

NameVirtualHost *:80

<VirtualHost *:80>
  ServerName default
  DocumentRoot /var/www/html
</VirtualHost>

<VirtualHost *:80>
  ...
  Railsの設定
  ...

  # use phpMyAdmin
  <Directory &amp;amp;amp;amp;amp;quot;/usr/share/phpMyAdmin/>
    PassengerEnabled Off
  </Directory>

</VirtualHost>

以上、取り急ぎご報告まで。

投稿者紹介

株式会社ユニキャスト
私たちは、テクノロジに魅せられた個性あふれるメンバーによって構成された茨城県日立市に本社を構えるベンチャー企業です。
”テクノロジを通して「驚き」と「感動」を創造し、人々の「夢」と「笑顔」を支えます。” の経営理念をモットーに明るい未来を描き、ワクワクする企画提案を続けて参ります。

1件のコメント

yum で phpMyAdmin インスコ – ozakingblog へ返信する コメントをキャンセル

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください