LoginSignup
24
25

More than 1 year has passed since last update.

phpMyAdmin最新版を導入

Last updated at Posted at 2013-01-21

個人的にはあまり使いたくはないのだけれど、やたらと使いたがる人が多く、入れておいてくれと頼まれるのでメモ。

どうせなら実証も兼ねて最新版を入れよう、ということで、GitHubから取得して入れることにした。

最新版をGitHubから取得

git clone https://github.com/phpmyadmin/phpmyadmin.git
  • sourceforge.net にあるSVNリポジトリの方はもう使われていないので注意。
    • http://phpmyadmin.svn.sourceforge.net/viewvc/phpmyadmin/trunk
    • 古い導入記事を参考に「最新版を入れてやったぜ!」といい気になっていると、やけにUIが古いのでおかしいな、と公式サイトを見てみてようやく気付いた…。

(追記) PHPのバージョン対応について

以下の更新履歴を参照

上記によると、とりあえず以下のこと分かる。

  • phpMyAdmin 4.5.0.0 から、PHPの最小対応バージョンが 5.5 に引き上げられている。
  • phpMyAdmin 4.2.3.0 から、PHPの最小対応バージョンが 5.3 に引き上げられている。
  • phpMyAdmin 5.0.0 から、PHPの最小対応バージョンが 7.1 に引き上げられている。
  • phpMyAdmin 5.2.0 から、PHPの最小対応バージョンが 7.2 に引き上げられている。

古いPHPで利用するなら…

git clone https://github.com/phpmyadmin/phpmyadmin.git -b MAINT_4_4_15

PHP 5.5より古いPHPで利用するなら、これで。

(追記) 安定版を入れるなら…

READMEを見ると

  • STABLE is the current stable release.
  • master is the development branch.
  • Releases are tagged, for example version 4.0.1 was tagged as RELEASE_4_0_1.

とあるので、安定版を入れるなら、

git clone https://github.com/phpmyadmin/phpmyadmin.git -b STABLE

のほうが良さげ。1

インストール

rsync -aC ./phpmyadmin/ /path/to/phpMyAdmin
  • 別にそのまま公開しても、cpしても良いんだろうけど、SCMで取得したものなので、念のため「rsync -aC」しておく。

インストールしたディレクトリに移動して設定

cd /path/to/phpMyAdmin
  • 面倒臭いので、最低限の設定だけ施して、あとはsetupスクリプトにお任せする。

設定ファイルサンプルをコピーして blowfish_secret を設定

  • ただし、setupスクリプトを利用するなら、 config.inc.php を配置するとスクリプトが動かないので、やらない。
cp config.sample.inc.php config.inc.php
vi config.php
  • mkpasswd -l 46 」の出力結果(ランダムな46文字)をコピーして、config.inc.php の「 $cfg['blowfish_secret'] 」にペースト。
    • mkpasswd は例えばRHEL系だと「 expect 」というパッケージに含まれている。
    • pwgen があるなら、「 pwgen 46 1 」でも良い。

setupスクリプト用ディレクトリを作っておく

mkdir config
chmod +w config
  • 書き込み権限が必要。

(追記) GitHubからインストールした場合の手順が追加されていた。

  • 以下のものが必要になった。
    • Composer
      • PHPの追加ライブラリインストール用
    • Yarn
      • JavaScriptの追加ライブラリインストール用
      • YarnはNode.jsのパッケージマネージャなので、未導入ならさらにNode.Jsのインストールも必要になる。

以下、CentOSを前提にした依存ライブラリインストール方法。

1. Composerインストール
curl -kLRs https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && chmod +x /usr/local/bin/composer
composer self-update
2. Yarnインストール
  • Node.jsインストール
curl -kLRs https://rpm.nodesource.com/setup_14.x | bash -
  • Yarnインストール
curl -kLRs https://dl.yarnpkg.com/rpm/yarn.repo -o /etc/yum.repos.d/yarn.repo
yum install yarn
3. 追加の依存ライブラリをインストール
cd /path/to/phpMyAdmin
composer update --no-dev
yarn install

localeファイルを生成

  • git版にはlocaleファイルが付属していないので、生成する必要がある。
cd /path/to/phpMyAdmin
scripts/generate-mo
  • phpMyAdmin最上位ディレクトリからの相対PATH指定のスクリプトなので、ソースディレクトリに移動してから実行する。
  • gettext 」パッケージに含まれる msgfmt を利用しているので、「 yum install gettext 」などで先に導入しておく。

ウェブサーバ設定

  • 以下はRHEL系の場合のパッケージ付属設定を踏襲したApache HTTPd設定例。
    • /etc/httpd/conf.d/phpMyAdmin.conf 」として配置。
    • バージョン2.4以上専用記述になっている。
# 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/local/share/phpMyAdmin
Alias /phpmyadmin /usr/local/share/phpMyAdmin

<Directory /usr/local/share/phpMyAdmin/>
    AddDefaultCharset UTF-8
    <RequireAny>
        Require ip 127.0.0.1
        # allow from example
        Require ip 203.0.113.1
    </RequireAny>
</Directory>

<Directory /usr/local/share/phpMyAdmin/setup/>
    #Require all denied
    <RequireAny>
        Require ip 127.0.0.1
        # allow from example
        Require ip 203.0.113.1
    </RequireAny>
</Directory>

# These directories do not require access over HTTP - taken from the original
# phpMyAdmin upstream tarball
#
<Directory /usr/local/share/phpMyAdmin/libraries/>
    Require all denied
</Directory>

<Directory /usr/local/share/phpMyAdmin/templates/>
    Require all denied
</Directory>

<Directory /usr/local/share/phpMyAdmin/setup/lib/>
    Require all denied
</Directory>

<Directory /usr/local/share/phpMyAdmin/setup/frames/>
    Require all denied
</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/local/share/phpMyAdmin/>
#        SecRuleInheritance Off
#    </Directory>
#</IfModule>
  • 例えばRHEL最新系であれば以下で適用。
systemctl reload httpd

setupスクリプトで設定

http://url/to/phpmyadmin/setup/ にブラウザでアクセス。

  • config.inc.php があると動かない。
  • 設定した後は、 /path/to/phpMyAdmin/setup/ へのウェブアクセスができないようウェブサーバを設定しておく。

  1. @aWebprogrammer さん ご指摘 より。 

24
25
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
24
25