Last-modified: 2014-08-10 (日) 23:32:00
phpMyAdmin/Debianへのインストール

概要

phpMyAdminをソースから導入します。
Nginx, MariaDB, HHVMで構築し、全てセットアップ済みとします。
ここでは、以下のサンプルURLを使用します。
https://hoge.paburica.com/pma

手順

  1. ソース取得
    Everything is expanded.Everything is shortened.
      1
      2
    
     
     
    
    wget http://sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/4.2.7/phpMyAdmin-4.2.7-all-languages.zip
    unzip phpMyAdmin-4.2.7-all-languages.zip
  2. 解凍したディレクトリを任意の公開場所に移動
    Everything is expanded.Everything is shortened.
      1
      2
    
     
     
    
    mv <公開場所>
    chown www-data:www-data -R <移動後のパス>
  3. 初期設定
    DBにphpMyAdminのデータを永続化するなら必要ですが、
    不要ならchmod 640 config.inc.phpと$cfg['blowfish_secret']値変更のみでOKです。
    Everything is expanded.Everything is shortened.
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
    
     
     
     
    -
    !
     
     
     
     
     
    -
    !
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    -
    
    cd <公開場所>
    chmod 640 config.inc.php
     
    # DB初期化
    mysql -u root -p
    source <公開場所>/examples/create_tables.sql;
    GRANT SELECT, INSERT, UPDATE, DELETE ON phpmyadmin.* TO 'pma'@'localhost'  IDENTIFIED BY '<パスワード>';
    commit;
    quit;
     
    # config.inc.phpを編集
    vi config.inc.php
    $cfg['blowfish_secret'] = '<適当な値に変更>'
     
     
    /* ↓コメントを解除し、DBのパスワードを設定する */
    /*
     * phpMyAdmin configuration storage settings.
     */
     
    /* User used to manipulate with storage */
    $cfg['Servers'][$i]['controlhost'] = '';
    $cfg['Servers'][$i]['controlport'] = '';
    $cfg['Servers'][$i]['controluser'] = 'pma';
    $cfg['Servers'][$i]['controlpass'] = '<パスワード>';
     
    /* Storage database and tables */
    $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
    $cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
    $cfg['Servers'][$i]['relation'] = 'pma__relation';
    $cfg['Servers'][$i]['table_info'] = 'pma__table_info';
    $cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';
    $cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';
    $cfg['Servers'][$i]['column_info'] = 'pma__column_info';
    $cfg['Servers'][$i]['history'] = 'pma__history';
    $cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';
    $cfg['Servers'][$i]['tracking'] = 'pma__tracking';
    $cfg['Servers'][$i]['designer_coords'] = 'pma__designer_coords';
    $cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
    $cfg['Servers'][$i]['recent'] = 'pma__recent';
    $cfg['Servers'][$i]['favorite'] = 'pma__favorite';
    $cfg['Servers'][$i]['users'] = 'pma__users';
    $cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
    $cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
    $cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches';
    /* Contrib / Swekey authentication */
    $cfg['Servers'][$i]['auth_swekey_config'] = '/etc/swekey-pma.conf';
    # ここまで(config.inc.php)
    
  4. Nginxの設定例
    面倒なので抜粋のみ
    Everything is expanded.Everything is shortened.
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
    
    -
    !
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    
      # phpMyAdmin
      location ~ /pma/.*\.php
      {
        include                 fastcgi_params;
        fastcgi_pass            127.0.0.1:9000;
        fastcgi_keep_conn       on;
        fastcgi_index           index.php;
        fastcgi_param           SCRIPT_FILENAME $document_root$fastcgi_script_name;
        access_log              /opt/nginx/log/pma/access.log main;
        error_log               /opt/nginx/log/pma/error.log warn;
      }
      location /pam
      {
        alias                   /opt/www/hoge/pma/;
        expires                 max;
        log_not_found           off;
        access_log              off;
      }

検証時の環境