Phpmyadmin 5.1.0.RC1 & 5.0.4 error (Warning in ./libraries/classes/Config.php#1285 mkdir(): Permission denied)
Asked Answered
V

5

5

I test phpmyadmin 5.0.4 and 5.1.0.RC1 on ubuntu server 20.04, and I'm geeting the following error :

Warning in ./libraries/classes/Config.php#1285
 mkdir(): Permission denied
Backtrace

./libraries/classes/Config.php#1285: mkdir(
string '/usr/share/phpmyadmin//var/lib/phpmyadmin/tmp/twig',
integer 504,
boolean true,
)
./libraries/classes/Template.php#57: PhpMyAdmin\Config->getTempDir(string 'twig')
./libraries/classes/Theme.php#101: PhpMyAdmin\Template->__construct()
./libraries/classes/Theme.php#174: PhpMyAdmin\Theme->__construct()
./libraries/classes/ThemeManager.php#307: PhpMyAdmin\Theme::load(
string './themes/pmahomme',
string '/usr/share/phpmyadmin/./themes/pmahomme/',
)
./libraries/classes/ThemeManager.php#79: PhpMyAdmin\ThemeManager->loadThemes()
./libraries/classes/ThemeManager.php#121: PhpMyAdmin\ThemeManager->__construct()
./libraries/classes/ThemeManager.php#385: PhpMyAdmin\ThemeManager::getInstance()
./libraries/common.inc.php#232: PhpMyAdmin\ThemeManager::initializeTheme()
./index.php#15: require_once(./libraries/common.inc.php)

I've try to change owner of my ./libraries/classes/Config.php and /var/lib/phpmyadmin/tmp/twig (created this folder "twig" too) by www-data (original "root"), but error wasn't resolved.

my vendor config is :

<?php
/**
 * File for vendor customization, you can change here paths or some behaviour,
 * which vendors such as Linux distributions might want to change.
 *
 * For changing this file you should know what you are doing. For this reason
 * options here are not part of normal configuration.
 */

declare(strict_types=1);

// phpcs:disable PSR1.Files.SideEffects
if (! defined('PHPMYADMIN')) {
    exit;
}
// phpcs:enable

/**
 * Path to vendor autoload file. Useful when you want to
 * have have vendor dependencies somewhere else.
 */
define('AUTOLOAD_FILE', ROOT_PATH . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php');

/**
 * Directory where cache files are stored.
 */
define('TEMP_DIR', ROOT_PATH . '/var/lib/phpmyadmin/tmp/' . DIRECTORY_SEPARATOR);

/**
 * Path to changelog file, can be gzip compressed. Useful when you want to
 * have documentation somewhere else, eg. /usr/share/doc.
 */
define('CHANGELOG_FILE', ROOT_PATH . 'ChangeLog');

/**
 * Path to license file. Useful when you want to have documentation somewhere
 * else, eg. /usr/share/doc.
 */
define('LICENSE_FILE', ROOT_PATH . 'LICENSE');

/**
 * Directory where SQL scripts to create/upgrade configuration storage reside.
 */
define('SQL_DIR', ROOT_PATH . 'sql' . DIRECTORY_SEPARATOR);

/**
 * Directory where configuration files are stored.
 * It is not used directly in code, just a convenient
 * define used further in this file.
 */
define('CONFIG_DIR', '/etc/phpmyadmin/');

/**
 * Filename of a configuration file.
 */
define('CONFIG_FILE', CONFIG_DIR . 'config.inc.php');

/**
 * Filename of custom header file.
 */
define('CUSTOM_HEADER_FILE', CONFIG_DIR . 'config.header.inc.php');

/**
 * Filename of custom footer file.
 */
define('CUSTOM_FOOTER_FILE', CONFIG_DIR . 'config.footer.inc.php');

/**
 * Default value for check for version upgrades.
 */
define('VERSION_CHECK_DEFAULT', true);

/**
 * Path to files with compiled locales (*.mo)
 */
define('LOCALE_PATH', ROOT_PATH . 'locale' . DIRECTORY_SEPARATOR);

/**
 * Define the cache directory for routing cache an other cache files
 */
define('CACHE_DIR', ROOT_PATH . 'libraries' . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR);

and i work with php8.0.

Thx for your backs !

Villada answered 9/1, 2021 at 9:29 Comment(1)
Look at the path name in the error message carefully. Do you actually have a directory '/usr/share/phpmyadmin//var/lib/phpmyadmin/tmp/twig'?Spake
S
14

Enable template caching. Edit /usr/share/webapps/phpMyAdmin/config.inc.php to add the line:

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

Source: https://wiki.archlinux.org/index.php/PhpMyAdmin#Enabling_template_caching

Selfconfessed answered 2/2, 2021 at 19:22 Comment(1)
/tmp might not be writable: This line should work all the time: $cfg['TempDir'] = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'phpmyadmin';Tiein
M
5

This is an addendum to Saurabh's answer. I had to manually create the temporary directory structure, and add an additional directory titled "twig". So you may need to create:

/var/lib/phpmyadmin/tmp/twig

After following their instructions and creating the temp dirs then everything worked fine.

Monogenic answered 12/3, 2021 at 22:53 Comment(1)
I had the same issue and all I did was create a new tmp directoryAlice
N
4

Had same issue. Solved it by:

  1. Open vendor_config.php:

    sudo nano /usr/share/phpmyadmin/libraries/vendor_config.php
    
  2. Press CTRL + W and search for TEMP_DIR

  3. Change line to:

    define('TEMP_DIR', '/var/lib/phpmyadmin/tmp/');
    
  4. Press CTRL + W and search for CONFIG_DIR

  5. Change line to:

    define('CONFIG_DIR', '/etc/phpmyadmin/');
    
  6. Save file and exit. (Press CTRL + X. Press Y and then press ENTER)

  7. Select the installed version: https://www.phpmyadmin.net/files/

  8. Extract and replace the /libraries/classes/Config.php file with existing one.

Thanks & Regards.

Nisi answered 10/1, 2021 at 20:47 Comment(2)
Hi, thx for you answer but if you read my post, it's already done ;) and nothing change.Villada
@NansLOIGNE According to your question, TEMP_DIR is defined as ROOT_PATH . '/var/lib/phpmyadmin/tmp/' . DIRECTORY_SEPARATOR not just '/var/lib/phpmyadmin/tmp/'Spake
M
0

In case this is not solved, it's most likely because apache user is not the default www-data.

When you install phpmyadmin, /var/lib/phpmyadmin/tmp is owned by www-data by default.
Thus, if you changed apache default user, it can't write in this dir.

Fix is rather easy :

chown -R "apache-user:apache-group" /var/lib/phpmyadmin/*
chmod -R g+s /var/lib/phpmyadmin/tmp/

Miyokomizar answered 30/7, 2021 at 17:1 Comment(0)
M
0

If you are using VestaCP then you need to check the permission of phpMyAdmin in /home/admin/.

If the permission is in root, change it to the user permission and it will be resolved. Command:

chown -R admin:admin phpmyadmin 
Mashe answered 25/5, 2023 at 10:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.