Trouble with sql-log.php permissions #1234
-
|
hello, installed adminer_5.2.1+dfsg-1_all.deb on ubuntu 24.04. /etc/adminer/conf.php redacted for brevity
`<?php`
2
3 define('ADMINER_DIR', '/usr/share/adminer');
...
14 $plugins = array(
15 // specify enabled plugins here
16 new AdminerVersionNoverify(), // disable phoning home
**21 new AdminerSqlLog(),**
22 );
23
...
33 include ADMINER_DIR . "/adminer.php";
34 `?>`With the sql-log.php as above, receive permissions error; [Wed Jan 14 20:27:09.874097 2026] [proxy_fcgi:error] AH01071: Got error 'PHP message: PHP Warning: fopen(.sql): Failed to open stream: Permission denied in /usr/share/adminer/plugins/sql-log.php on line 31; PHP message: PHP Fatal error: Uncaught TypeError: flock(): Argument #1 ($stream) must be of type resource, false given in /usr/share/adminer/plugins/sql-log.php:32
Stack trace:
#0 /usr/share/adminer/plugins/sql-log.php(32): flock()
#1 /usr/share/adminer/plugins/sql-log.php(24): AdminerSqlLog->log()
#2 [internal function]: AdminerSqlLog->sqlCommandQuery()
#3 /usr/share/adminer/adminer.php(1181): call_user_func_array()
#4 /usr/share/adminer/adminer.php(1537): Adminer\\Plugins->__call()
#5 /etc/adminer/conf.php(30): include('...')
#6 {main}
thrown in /usr/share/adminer/plugins/sql-log.php on line 32'not sure what permissions to change?? adminer works w/o sql-log enabled. Any help appreciated |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
the error is because www-data (apache/php user) doesnt have permission to write to the log file. adminer sql-log plugin tries to write to the current directory by default which www-data cant access. fix:
sudo mkdir -p /var/log/adminer
sudo chown www-data:www-data /var/log/adminer
sudo chmod 755 /var/log/adminer
new AdminerSqlLog("/var/log/adminer/sql.log")instead of: new AdminerSqlLog()
sudo touch /var/log/adminer/sql.log
sudo chown www-data:www-data /var/log/adminer/sql.log
sudo chmod 644 /var/log/adminer/sql.log
sudo systemctl restart apache2alternatively, if you want to log per-session, you could use /tmp but thats less persistent: new AdminerSqlLog("/tmp/adminer-" . session_id() . ".sql")the key issue is that fopen(.sql) tries to open in current working directory which for php-fpm/apache is usually not writable. |
Beta Was this translation helpful? Give feedback.
-
|
Yayyyyy, thank you, have it working again. Weird for the longest time the plugin worked writing to the same adminer directory folder. |
Beta Was this translation helpful? Give feedback.
the error is because www-data (apache/php user) doesnt have permission to write to the log file.
adminer sql-log plugin tries to write to the current directory by default which www-data cant access.
fix:
instead of: