How to add custom configuration options to phpMyAdmin on Debian/Ubuntu

By default, phpMyAdmin is missing a number of useful configuration options. When you install it from source, you can set these options by editing /path/to/phpmyadmin/config.inc.php. However, Debian and Ubuntu package up phpMyAdmin and store things in a slightly different place. This makes installation, update and maintenance much more convenient, but does make things slightly more confusing when you want to set custom options.

Both Debian and Ubuntu store the configuration options for phpMyAdmin in /etc/phpmyadmin/config.inc.php. Editing this file is not recommended, because if you edit it then you can no longer automatically upgrade it – every time you upgrade phpMyAdmin, you will get a prompt about having edited the file, and will need to confirm what to do with the changes.

The solution, similar to many other packages on Debian and Ubuntu, is to add your custom configuration options in the specially provided subfolder /etc/phpmyadmin/conf.d/. All files in there with the suffix .php will automatically be loaded by phpMyAdmin. For example, on my development setup, I have created the file /etc/phpmyadmin/conf.d/custom.php with the following contents:

<?php
// Increase session timeout to 1 day
ini_set( 'session.gc_maxlifetime', '86400' );
$cfg['LoginCookieValidity'] = 86400;

// Use full UTF-8 encoding by default
$cfg['DefaultCharset'] = 'utf8mb4';
$cfg['DefaultConnectionCollation'] = 'utf8mb4_unicode_ci';

These options stop the login session timing out so quickly, and defaults all connections between phpMyAdmin and the database to use utf8mb4. See the documentation for phpMyAdmin for many more possible options.

Add new comment