Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

phpMyAdmin says the $cfg['TempDir'] directory is not accessible

ErrorThe $cfg['TempDir'] (./tmp/) is not accessible. phpMyAdmin is not able to cache templates and will be slow because of this.

Short answer

phpMyAdmin keeps its template cache in the folder named by $cfg['TempDir'], ./tmp/ by default. The warning means the web server user cannot use that folder: it does not exist, or another user owns it. Create it, make the web server user its owner with mode 700, or point TempDir to a folder that user can write.

  • Applies to phpMyAdmin 5.2, Ubuntu 24.04, Apache 2.4
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Find the folder phpMyAdmin is using and see who owns it. Replace the path with your own install directory, and www-data with the user your web server runs as.

    ls -ld /usr/share/phpmyadmin/tmp
    ps -o user= -C apache2 | sort -u
  2. 2Match what you see, then jump to its fix

    1. 1ls reports No such file or directory for the tmp folderThe tmp folder does not existFix
    2. 2The folder exists, but its owner is root or your login user and the web server user is a different oneThe folder belongs to another userFix
    3. 3The phpMyAdmin directory is managed by a package or an image, and you cannot write inside itThe install folder is read-only, so TempDir must live elsewhereFix

What does the error look like?

  • The $cfg['TempDir'] (./tmp/) is not accessible. phpMyAdmin is not able to cache templates and will be slow because of this.

Cause 1 of 3

The tmp folder does not exist

1Check

The default value is a tmp folder inside the phpMyAdmin directory. A copy made from a download or an archive that skipped empty folders will not have it.

ls -ld /usr/share/phpmyadmin/tmp

2Fix

Create the folder and give it to the web server user, with access only for that user.

cd /usr/share/phpmyadmin
sudo mkdir tmp
sudo chown www-data:www-data tmp
sudo chmod 700 tmp

3Verify

Reload phpMyAdmin. The warning should be gone.

ls -ld /usr/share/phpmyadmin/tmp

Confirmed by docs.phpmyadmin.net

Did this fix it?

Cause 2 of 3

The folder belongs to another user

1Check

The manual says the directory only needs to be reachable by the web server user, so ownership and mode must match that user.

stat -c '%U:%G %a' /usr/share/phpmyadmin/tmp

2Fix

Change the owner to the web server user and set mode 700. If you cannot change the owner, the manual describes giving that group access with setfacl. It names 777 only as the last resort, because other users on the machine could then read the data.

sudo chown www-data:www-data /usr/share/phpmyadmin/tmp
sudo chmod 700 /usr/share/phpmyadmin/tmp

3Verify

The stat command now prints www-data:www-data 700.

stat -c '%U:%G %a' /usr/share/phpmyadmin/tmp

Confirmed by docs.phpmyadmin.net

Did this fix it?

Cause 3 of 3

The install folder is read-only, so TempDir must live elsewhere

1Check

TempDir is a normal setting, so it can name any directory the web server user can use.

grep -n "TempDir" /etc/phpmyadmin/config.inc.php /usr/share/phpmyadmin/config.inc.php

2Fix

Create a folder outside the install directory with the same owner and mode, then set TempDir to it in config.inc.php.

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

# in config.inc.php
$cfg['TempDir'] = '/var/lib/phpmyadmin/tmp';

3Verify

Reload the page in the browser. The warning no longer shows.

ls -ld /var/lib/phpmyadmin/tmp

Confirmed by docs.phpmyadmin.net

Did this fix it?

How do I stop it coming back?

  • After every manual upgrade, check that the tmp folder exists and still has the web server user as owner.
  • Keep the mode as strict as possible; only the web server user needs this folder.
  • Prefer a TempDir outside the web root when the install directory is managed by a package.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Related fixes

Back end

CodeIgniter 4 cannot write its cache files

CodeIgniter\Cache\Exceptions\CacheException: Cache unable to write to /var/www/app/writable/cache/

CodeIgniter 4's file cache needs a cache directory that the web server can really write to.

2 causes, each with a fix

Back end

CodeIgniter 3 loads the model but the property is undefined

The model name you are loading is the name of a resource that is already being used: user

CodeIgniter 3 expects a model file named like its class, with the first letter capitalised, for example User_model.php holding class User_model.

2 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.