2012年7月24日火曜日

さくらのVPS1G移設作業 phpMyAdminインストール(CentOS6.2)



■phpMyAdminのインストール

# cd ~
# wget http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.3.8.1/phpMyAdmin-3.3.8.1-all-languages.tar.gz?r=http%3A%2F%2Fwww.phpmyadmin.net%2Fhome_page%2Fdownloads.php&ts=1291797693&use_mirror=jaist
# tar -zxvf phpMyAdmin-3.3.8.1-all-languages.tar.gz
# mv ./phpMyAdmin-3.3.8.1-all-languages /var/lib/phpMyAdmin
# cd /var/lib/phpMyAdmin/
# cp /var/lib/phpMyAdmin/config.sample.inc.php /var/lib/phpMyAdmin/config.inc.php
# vi /var/lib/phpMyAdmin/config.inc.php
# diff config.inc.php config.sample.inc.php
17c17
< $cfg['blowfish_secret'] = 'gqearjgjbykdc.sgS8zjdtayjz3fmgezncxxbRxzoxstvx'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
---
> $cfg['blowfish_secret'] = 'a8b7c6d'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
44,45c44,45
< $cfg['Servers'][$i]['controluser'] = 'pma';
< $cfg['Servers'][$i]['controlpass'] = 'hogepass';
---
> // $cfg['Servers'][$i]['controluser'] = 'pma';
> // $cfg['Servers'][$i]['controlpass'] = 'pmapass';
48,61c48,61
< $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]['table_uiprefs'] = 'pma_table_uiprefs';
---
> // $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]['table_uiprefs'] = 'pma_table_uiprefs';
63c63
< $cfg['Servers'][$i]['auth_swekey_config'] = '/etc/swekey-pma.conf';
---
> // $cfg['Servers'][$i]['auth_swekey_config'] = '/etc/swekey-pma.conf';

# mkdir config
# chmod o+rwx ./config
# mysql -uroot -p < /var/lib/phpMyAdmin/examples/create_tables.sql
# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.1.61 Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> grant all on phpmyadmin.* to pma@localhost identified by "hogepass";
Query OK, 0 rows affected (0.01 sec)

mysql> exit;
Bye



・ベーシック認証設定
# vi virtualhost.conf

以下の設定を追加する。

    ServerName phpmyadmin.example.jp
    DocumentRoot /var/lib/phpMyAdmin
        
                AuthType Basic
                AuthName "phpmyadmin.example.jp"
                AuthUserFile /etc/httpd/conf/phpmyadmin.example.jp_auth_file
                Require valid-user
        


ベーシック認証ファイル準備
# htpasswd -c /etc/httpd/conf/phpmyadmin.example.jp_auth_file hogehoge

# /etc/init.d/mysqld restart
mysqld を停止中:                                           [  OK  ]
mysqld を起動中:                                           [  OK  ]


これで
http://phpmyadmin.example.jp
にアクセスする。
ベーシンク認証後にphpMyAdminのログイン画面が表示されれば成功

http://phpmyadmin.example.jp/setup
にて設定が可能らしいがまだ未検証、どうやら設定すると"/var/lib/phpMyAdmin/config/"に設定ファイルが出来るので、手動で"/var/lib/phpMyAdmin/config.inc.php"にコピー?などして反映させるらしい。