TECH / Servers & Websites 2 min read

How to Fix phpMyAdmin “$cfg[‘TempDir’] (./tmp/) is not accessible”

Antonio NEMCD Author
Published Aug 22, 2019 · 2 min

After installing or upgrading phpMyAdmin (4.9, 5.x), you often see a yellow warning banner at the bottom of the home screen: The $cfg['TempDir'] (./tmp/) is not accessible. phpMyAdmin is not able to cache templates and will be slow because of this. The app still works, but re-renders every Twig template from scratch on every request. Fixing it takes two minutes.

phpMyAdmin logo – fixing TempDir ./tmp/ warning

phpMyAdmin warning: $cfg['TempDir'] (./tmp/) is not accessible

Quick fix: create the temporary directory, grant write ownership to your web server / PHP-FPM user (typically www-data), and set an explicit absolute path for $cfg['TempDir'] in config.inc.php.

Case 1. Manual Archive Installation of phpMyAdmin

Go to your phpMyAdmin root directory (next to config.inc.php), create tmp, and assign ownership to the web server user:

cd /var/www/phpmyadmin
sudo mkdir -p tmp
sudo chown -R www-data:www-data tmp
sudo chmod 750 tmp

Then open config.inc.php and append an explicit absolute path (more reliable than relative ./tmp/):

$cfg['TempDir'] = '/var/www/phpmyadmin/tmp/';

(Alternatively, point it to '/tmp/phpmyadmin/' after creating that directory with the same chown.)

Case 2. Installed via apt Package on Debian / Ubuntu

When installed from Debian/Ubuntu repositories, phpMyAdmin keeps its cache directory at /var/lib/phpmyadmin/tmp (and its config at /etc/phpmyadmin/config.inc.php). If ownership broke after an upgrade or switching PHP-FPM users, reset permissions there:

sudo mkdir -p /var/lib/phpmyadmin/tmp
sudo chown -R www-data:www-data /var/lib/phpmyadmin/tmp
sudo chmod 750 /var/lib/phpmyadmin/tmp

Directory Exists, Yet the Warning Won’t Go Away?

Check these three common culprits:

  1. Wrong web server / PHP-FPM user. Debian/Ubuntu typically use www-data, CentOS/Rocky/Alma use apache or nginx, and custom PHP-FPM pools may run under a per-site Linux user. Verify with ps aux | grep -E 'php-fpm|apache2|httpd'.
  2. PHP open_basedir restriction. If your PHP pool enforces open_basedir, make sure the path in $cfg['TempDir'] lies inside the allowed paths.
  3. Variable case typo. PHP variables are case-sensitive: it must be lowercase $cfg['TempDir'] (not $Cfg['TempDir']).

Reload phpMyAdmin (Ctrl + F5) – the warning disappears immediately and table pages load noticeably faster.

Related posts:

Leave a Comment