由于PHP版本导致Apache中的MyPHPMyAdmin 500内部服务器错误 [英] PHPMyAdmin 500 Internal Server Error in Apache due to PHP Version

查看:100
本文介绍了由于PHP版本导致Apache中的MyPHPMyAdmin 500内部服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

版本:

  • OS lsb_release -a :Ubuntu 18.04.5 LTS
  • PHP php -v :8.0.1
  • Apache apache2 -v :2.4.29(Ubuntu)
  • MySQL mysql --version :mysql Ver 14.14 Distrib 5.7.32
  • OS lsb_release -a : Ubuntu 18.04.5 LTS
  • PHP php -v : 8.0.1
  • Apache apache2 -v : 2.4.29 (Ubuntu)
  • MySQL mysql --version : mysql Ver 14.14 Distrib 5.7.32

问题:

我正在尝试使用以下

I'm trying to install LAMP Stack using following article. However, I was getting HTTP 500 Error while accessing phpmyadmin from browser.

并使用以下命令安装了phpmyadmin.

And installed phpmyadmin using below command.

  • sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl

尝试过:

因此,我检查了错误日志 tail -f/var/log/apache2/error.log ,发现Phpmyadmin在PHP的贬值版本上运行.

So, I checked with Error Log tail -f /var/log/apache2/error.log and found that Phpmyadmin was running on depreciated version of PHP.

[Sat Jan 30 12:56:38.798871 2021] [php:error] [pid 17271] [client 
103.25.169.179:28514] PHP Fatal error:  Array and string offset access 
syntax with curly braces is no longer supported in 
/usr/share/phpmyadmin/libraries/Util.php on line 2087

[Sat Jan 30 12:56:38.798871 2021] [php:error] [pid 17271] [client 103.25.169.179:28514] PHP Fatal error:  Uncaught ValueError: 
mb_convert_encoding(): Argument #2 ($to_encoding) must be a valid 
encoding, "" given in /usr/share/php/php-php-
gettext/gettext.inc:181\nStack trace:\n#0 /usr/share/php/php-php-
gettext/gettext.inc(181): mb_convert_encoding()\n#1 /usr/share/php/php-
php-gettext/gettext.inc(278): _encode()\n#2 /usr/share/php/php-php-
gettext/gettext.inc(285): _gettext()\n#3 
/usr/share/phpmyadmin/libraries/sanitizing.lib.php(179): __()\n#4 
/usr/share/phpmyadmin/libraries/Message.php(607): PMA_sanitize()\n#5 
/usr/share/phpmyadmin/libraries/Message.php(672): 
PMA\\libraries\\Message::decodeBB()\n#6 
/usr/share/phpmyadmin/libraries/Error.php(220): PMA\\libraries\\Message-
>getMessage()\n#7 /usr/share/phpmyadmin/libraries/ErrorHandler.php(193): 
PMA\\libraries\\Error->getHash()\n#8 
/usr/share/phpmyadmin/libraries/ErrorHandler.php(156): 
PMA\\libraries\\ErrorHandler->addError()\n#9 [internal function]: 
PMA\\libraries\\ErrorHandler->handleError()\n#10 
/usr/share/phpmyadmin/libraries/session.inc.php(133): ini_set()\n#11 
/usr/share/phpmyadmin/libraries/common.inc.php(280): require('...')\n#12 
/usr/share/phpmyadmin/index.php(13): require_once('...')\n#13 {main}\n  
thrown in /usr/share/php/php-php-gettext/gettext.inc on line 181

  • 我通过用 []
  • 删除了 {} 来解决了数组和字符串偏移量访问语法错误
  • 运行以下命令 sudo phpenmod mbstring
    • I'd solved Array and string offset access syntax error by removing { } with [ ]
    • Run the following command sudo phpenmod mbstring
    • 推荐答案

      这是从聊天中获取的.有些事情可能不准确,但这解决了OP的问题

      This was taken from a chat. Some things might be inaccurate, but this solved the OP's problem

      使用以下教程安装PHPMyAdmin:

      Install PHPMyAdmin using the following tutorial:

      1.

      apt purge phpmyadmin -y
      

      cd /path/to/somefolder
      

      wget https://files.phpmyadmin.net/phpMyAdmin/5.1.0-rc1/phpMyAdmin-5.1.0-rc1-all-languages.zip && unzip phpMyAdmin-5.1.0-rc1-all-languages.zip && 
      cd phpMyAdmin-5.1.0-rc1-all-languages
      

      apt install pwgen -y
      

      1. 记下该命令的输出,我将其称为 pw

      pwgen -s 32 1
      

      cp config.sample.inc.php config.inc.php
      

      1. 使用收藏夹编辑器编辑config.inc.php,并在此行中粘贴 pw :

      . . .
      $cfg['blowfish_secret'] = 'STRINGOFTHIRTYTWORANDOMCHARACTERS'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
      . . .
      

      vim /etc/apache2/conf-available/phpmyadmin-custom.conf
      

      1. 将以下内容粘贴到先前的命令中:

      Alias /phpmyadmin /path/to/that/phpMyAdmin-5.1.0-rc1-all-languages
      <Directory "/path/to/that/phpMyAdmin-5.1.0-rc1-all-languages">
      Options SymLinksIfOwnerMatch
      DirectoryIndex index.php
      Require all granted
      </Directory>
      

      1. 使用:wq 保存上一个,运行以下命令
      1. Save the previous one using :wq, Run the following command

      a2enconf phpmyadmin-custom && systemctl restart apache2 && mysql
      

      1. 您的密码_此处替换为您自己的密码.
      1. Replace your_password_here to your own password.

      ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_password_here';
      

      systemctl restart mysql
      

      现在应该可以正常工作了.

      It should work now.

      这篇关于由于PHP版本导致Apache中的MyPHPMyAdmin 500内部服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆