Raspberry Pi 4 Model B 4GB モデルに Adminer を入れました。
理由は SQLite のファイルを編集したいから軽い気持ちで導入したら、以前と手順が変わっていてハマったのでメモ。
環境
$ cat /etc/issue
Debian GNU/Linux 12 \n \l
導入
以前導入したときの手順を参考に導入。
$ sudo apt install -y php-cli php-sqlite3 apache2 libapache2-mod-php
$ apache2 -v
Server version: Apache/2.4.62 (Debian)
Server built: 2024-10-04T15:21:08
$ php -v
PHP 8.2.26 (cli) (built: Nov 25 2024 17:21:51) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.26, Copyright (c) Zend Technologies
with Zend OPcache v8.2.26, Copyright (c), by Zend Technologies
$ sudo apt install adminer -y
早速、adminer にアクセスするとエラーになった...
-
パスワード未入力で
Login
ボタン押下
Adminer does not support accessing a database without a password, more information.
-
パスワード入力して
Login
ボタン押下
Database does not support password.
そうだった... エラーになるんだった。
sqlite.php を経由すれば OK ... のはずなんだけど、ダメだった。
整理
デフォルトだと adminer.conf
で /etc/adminer/conf.php
を読んでいる。
$ cat /etc/apache2/conf-enabled/adminer.conf
Alias /adminer /usr/share/adminer/adminer
<Directory /etc/adminer>
Require all granted
DirectoryIndex conf.php
</Directory>
そして、/usr/share/adminer/adminer.php
インクルードしてる。
<?php
define('ADMINER_DIR', '/usr/share/adminer');
function adminer_object() {
// required to run any plugin
include_once ADMINER_DIR . "/plugins/plugin.php";
// autoloader
foreach (glob(ADMINER_DIR . "/plugins/*.php") as $filename) {
include_once $filename;
}
$plugins = array(
// specify enabled plugins here
new AdminerVersionNoverify(), // disable phoning home
//new AdminerLoginServers([
// 'my' => ['server' => 'localhost', 'driver' => 'server'], // mysql
// 'pg' => ['server' => 'localhost', 'driver' => 'pgsql'],
//]),
);
/* It is possible to combine customization and plugins:
class AdminerCustomization extends AdminerPlugin {
}
return new AdminerCustomization($plugins);
*/
return new AdminerPlugin($plugins);
}
include ADMINER_DIR . "/adminer.php";
?>
もともと窓口にしようとしていた sqlite.php
と対応DB が違うだけっぽい。
https://github.com/vrana/adminer/blob/master/adminer/sqlite.php
function adminer_object() { include_once "../plugins/plugin.php"; include_once "../plugins/login-password-less.php"; return new AdminerPlugin(array( // TODO: inline the result of password_hash() so that the password is not visible in source codes new AdminerLoginPasswordLess(password_hash("YOUR_PASSWORD_HERE", PASSWORD_DEFAULT)), )); } include "./index.php";
対応
adminer.conf
を修正・リロードして、sqlite.php
を読むように変更。
Alias /adminer /usr/share/adminer/adminer
<Directory /usr/share/adminer/adminer>
Require all granted
DirectoryIndex sqlite.php
</Directory>
これでめでたく conf.php
をスキップして、sqlite.php
経由になってログイン OK。
※パスワードは従来どおり AdminerLoginPasswordLess
行を確認(初期値 YOUR_PASSWORD_HERE
)。