php 在某个域上安装phpmyadmin后内部服务器错误(HTTP Error 500)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21699774/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 04:23:09  来源:igfitidea点击:

Internal server error (HTTP Error 500) after installing phpmyadmin on a certain domain

phpmysqlphpmyadmin

提问by Phantom

I'm getting internal server error (HTTP Error 500) after installing phpmyadmin on a certain domain.

在某个域上安装 phpmyadmin 后,我收到内部服务器错误(HTTP 错误 500)。

This is what my config.inc.phpfile currently reads.

这是我的config.inc.php文件当前读取的内容。

<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * 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 <http://docs.phpmyadmin.net/>.
 *
 * @package PhpMyAdmin
 */

/*
 * This is needed for cookie based authentication to encrypt password in
 * cookie
 */
$cfg['blowfish_secret'] = 'a8b7c6d'; /* 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'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysql if your server does not have mysqli */
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = false;

/*
 * phpMyAdmin configuration storage settings.
 */

/* User used to manipulate with storage */
// $cfg['Servers'][$i]['controlhost'] = '';
// $cfg['Servers'][$i]['controlport'] = '';
// $cfg['Servers'][$i]['controluser'] = 'pma';
// $cfg['Servers'][$i]['controlpass'] = 'pmapass';

/* Storage database and tables */
// $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
// $cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
// $cfg['Servers'][$i]['relation'] = 'pma__relation';
// $cfg['Servers'][$i]['table_info'] = 'pma__table_info';
// $cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';
// $cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';
// $cfg['Servers'][$i]['column_info'] = 'pma__column_info';
// $cfg['Servers'][$i]['history'] = 'pma__history';
// $cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';
// $cfg['Servers'][$i]['tracking'] = 'pma__tracking';
// $cfg['Servers'][$i]['designer_coords'] = 'pma__designer_coords';
// $cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
// $cfg['Servers'][$i]['recent'] = 'pma__recent';
// $cfg['Servers'][$i]['users'] = 'pma__users';
// $cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
// $cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
/* Contrib / Swekey authentication */
// $cfg['Servers'][$i]['auth_swekey_config'] = '/etc/swekey-pma.conf';

/*
 * End of servers configuration
 */

/*
 * Directories for saving/loading files from server
 */
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';

/**
 * Defines whether a user should be displayed a "show all (records)"
 * button in browse mode or not.
 * default = false
 */
//$cfg['ShowAll'] = true;

/**
 * Number of rows displayed when browsing a result set. If the result
 * set contains more rows, "Previous" and "Next".
 * default = 30
 */
//$cfg['MaxRows'] = 50;

/**
 * disallow editing of binary fields
 * valid values are:
 *   false    allow editing
 *   'blob'   allow editing except for BLOB fields
 *   'noblob' disallow editing except for BLOB fields
 *   'all'    disallow editing
 * default = blob
 */
//$cfg['ProtectBinary'] = 'false';

/**
 * Default language to use, if not browser-defined or user-defined
 * (you find all languages in the locale folder)
 * uncomment the desired line:
 * default = 'en'
 */
//$cfg['DefaultLang'] = 'en';
//$cfg['DefaultLang'] = 'de';

/**
 * default display direction (horizontal|vertical|horizontalflipped)
 */
//$cfg['DefaultDisplay'] = 'vertical';


/**
 * How many columns should be used for table display of a database?
 * (a value larger than 1 results in some information being hidden)
 * default = 1
 */
//$cfg['PropertiesNumColumns'] = 2;

/**
 * Set to true if you want DB-based query history.If false, this utilizes
 * JS-routines to display query history (lost by window close)
 *
 * This requires configuration storage enabled, see above.
 * default = false
 */
//$cfg['QueryHistoryDB'] = true;

/**
 * When using DB-based query history, how many entries should be kept?
 *
 * default = 25
 */
//$cfg['QueryHistoryMax'] = 100;

/**
 * Should error reporting be enabled for JavaScript errors
 *
 * default = 'ask' 
 */
//$cfg['SendErrorReports'] = 'ask';

/*
 * You can find more configuration options in the documentation
 * in the doc/ folder or at <http://docs.phpmyadmin.net/>.
 */
?>

What changes do I need to do on this file? I've already followed up various posts but its not helping. It this the problem with the domain being down?

我需要对这个文件做哪些更改?我已经跟进了各种帖子,但没有帮助。这是域关闭的问题吗?

Thanks in advance.

提前致谢。

回答by Fredrick Anyera M

If you are using apache2.4 and PHP 7, run

如果您使用的是 apache2.4 和 PHP 7,请运行

sudo apt-get install php-mbstring php7.0-mbstring php-gettext

then restart your server

然后重启你的服务器

sudo service apache2 restart

回答by Raúl

I know it has been a couple of years, and I noticed by your comments that still no luck. Here I run into the same 500 error after installing through apt. I look for my Apache error log file (/var/log/apache2/error.log), and there was the following entry:

我知道已经有几年了,我注意到你的评论仍然没有运气。通过apt安装后,我在这里遇到了同样的500错误。我查找我的 Apache 错误日志文件 (/var/log/apache2/error.log),并且有以下条目:

[Thu Aug 11 22:38:25.930453 2016] [:error] [pid 18138] [client ::1:35026] PHP Fatal error:  require_once(): Failed opening required '/usr/share/php/php-gettext/gettext.inc' (include_path='.:/usr/share/php') in /usr/share/phpmyadmin/libraries/select_lang.lib.php on line 477

It shows that the library gettext was not found, so I intalled it:

它表明没有找到库gettext,所以我安装了它:

sudo apt-get install  php-gettext

And restarted Apache:

并重新启动Apache:

sudo service apache2 restart

That worked for me. Hope it helps. PS: If still not working you may try to sym link the folder just in case:

那对我有用。希望能帮助到你。PS:如果仍然无法正常工作,您可以尝试符号链接文件夹以防万一:

sudo ln -s /usr/share/phpmyadmin /var/www/

回答by Maion

if you want to access the mysql data from your server to your computer

如果您想从您的服务器访问 mysql 数据到您的计算机

you need to change

你需要改变

$cfg['Servers'][$i]['host'] = 'localhost';

to you server ip address.

给你的服务器ip地址。

$cfg['Servers'][$i]['host'] = 'your.server.ip.add.here';


update

更新

$cfg['Servers'][$i]['AllowNoPassword'] = true;
$cfg['Servers'][$i]['host'] = 'your.server.ip.add.here';
$cfg['Servers'][$i]['user'] = 'db name here';
$cfg['Servers'][$i]['password'] = 'db password';

make sure that those fields are properly set up..

确保这些字段设置正确..

回答by User Rebo

Ensure that your PHP version matches the used PHP module in Apache2:

确保您的 PHP 版本与 Apache2 中使用的 PHP 模块匹配:

php -v  //PHP 7.4.4 
ls -d /etc/apache2/mods-enabled/php*.conf // php7.3.conf

sudo a2dismod php7.3  // disable 7.3
sudo a2enmod php7.4   // enable 7.4
sudo systemctl restart apache2

I installed the php-mbstringphp-gettext(also excplicitly for latest PHP version), but it still wasn't working. At least it took me hours until I noticed apache decides itself what PHP version is used.

我安装了php-mbstringphp-gettext(也专门用于最新的 PHP 版本),但它仍然无法正常工作。至少我花了几个小时才注意到 apache 自己决定使用什么 PHP 版本。

回答by bytepan

OK, if you have already installed packages php-mbstringand php-gettextand it still doesn't work, first take a look to Apache logs:

好的,如果您已经安装了php-mbstringphp-gettext 包,但仍然无法正常工作,请先查看 Apache 日志:

tail /var/log/apache2/error.log

If you find something like this:

如果你发现这样的事情:

Fatal error: Uncaught Twig_Error_Syntax: Unexpected "apply" tag (expecting closing tag for the "if" tag defined near line 17). in /usr/share/phpmyadmin/templates/columns_definitions/column_virtuality.twig on line 17

致命错误:未捕获的 Twig_Error_Syntax:意外的“apply”标记(期望在第 17 行附近定义的“if”标记的结束标记)。在第 17 行的 /usr/share/phpmyadmin/templates/columns_definitions/column_virtuality.twig 中

This is a known bug in phpmyadmin 4.9.4

这是 phpmyadmin 4.9.4 中的一个已知错误

The bug has been fixed in phpmyadmin 4.9.5 but please note that if you are under Debian 10 Buster you will need to upgrade the package php-twigto an higher version rather than the one included with Buster, or package phpmyadmin will be kept back to 4.9.4 during system upgrades.

该错误已在 phpmyadmin 4.9.5 中修复,但请注意,如果您使用的是 Debian 10 Buster,则需要将软件包php-twig升级到更高版本,而不是 Buster 附带的版本,否则软件包 phpmyadmin 将被保留在系统升级期间到 4.9.4。

You can simply upgrade php-twig from next Debian version (11, Bullseye)

您可以简单地从下一个 Debian 版本(11,Bullseye)升级 php-twig

apt-get install php-twig/bullseye

This worked for me. Hope this doesn't broke something else in Deb 10 LAMP setup.

这对我有用。希望这不会破坏 Deb 10 LAMP 设置中的其他内容。