FiveM环境下phpMyAdmin配置文件读取失败问题求助
排查phpMyAdmin“PHP无法读取配置文件”问题
一、先修复配置文件的语法错误
你的config.inc.php最后一行存在Linux命令apt install pwgen,这行命令直接写在PHP代码里完全不符合语法规则,是导致PHP无法解析配置文件的核心原因。
1. 移除无效命令
打开config.inc.php,删除最后一行的apt install pwgen。
2. 清理重复配置项
- 你重复定义了
$cfg['blowfish_secret'],开头和结尾各出现一次,保留其中一个即可(建议保留开头的定义)。 - 服务器配置段里重复设置了
host、compress、AllowNoPassword,比如先设host = 'localhost'又改成host = '127.0.0.1',保留一个赋值即可(推荐用127.0.0.1,避免localhost解析异常)。
修复后的核心配置片段参考:
<?php /** * phpMyAdmin sample configuration, you can use it as base for * manual configuration. For easier setup you can use setup/ * * All directives are explained in documentation in the doc/ folder * or at <https://docs.phpmyadmin.net/>. */ declare(strict_types=1); /** * This is needed for cookie based authentication to encrypt the cookie. * Needs to be a 32-bytes long string of random bytes. See FAQ 2.10. */ $cfg['blowfish_secret'] = 'THPQTTKUFQFDGQCEWPGZATYKIJXGFKOO'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */ /** * Servers configuration */ $i = 0; /** * First server */ $i++; /* Authentication type */ $cfg['Servers'][$i]['auth_type'] = 'cookie'; /* Server parameters */ $cfg['Servers'][$i]['host'] = '127.0.0.1'; $cfg['Servers'][$i]['user'] = 'root'; $cfg['Servers'][$i]['password'] = 'uO8PK2NOtPEHSHT5fJjThjKCDGKdEvi'; $cfg['Servers'][$i]['extension'] = 'mysqli'; $cfg['Servers'][$i]['compress'] = false; $cfg['Servers'][$i]['AllowNoPassword'] = true; /** * phpMyAdmin configuration storage settings. */ /* User used to manipulate with storage */ // 暂时注释未配置完整的controlhost,避免异常 // $cfg['Servers'][$i]['controlhost'] = 'pma'; $cfg['Servers'][$i]['controluser'] = ''; // 其余配置保持原样... /** * You can find more configuration options in the documentation * in the doc/ folder or at <https://docs.phpmyadmin.net/>. */
二、检查文件路径与权限
如果修复配置后仍报错,检查以下内容:
- 确认
config.inc.php路径正确:phpMyAdmin默认会在安装目录下读取该文件,比如/var/www/phpmyadmin/config.inc.php(根据你的FiveM环境实际路径调整)。 - 调整文件权限:确保PHP进程能读取该文件,执行以下命令(根据你的Web服务器运行用户调整,www-data是Apache/Nginx的默认运行用户):
chmod 644 /path/to/config.inc.php chown www-data:www-data /path/to/config.inc.php
三、验证PHP环境适配性
- 确认PHP版本符合phpMyAdmin要求:比如phpMyAdmin 5.x系列需要PHP 7.4及以上版本。
- 检查mysqli扩展是否启用:通过PHP信息页面(phpinfo())查看mysqli扩展是否正常加载。
内容的提问来源于stack exchange,提问作者Aimha
相关产品推荐
相关产品推荐

