Reputation: 827
Version:
lsb_release -a
: Ubuntu 18.04.5 LTSphp -v
: 8.0.1apache2 -v
: 2.4.29 (Ubuntu)mysql --version
: mysql Ver 14.14 Distrib 5.7.32Problem:
I'm trying to install LAMP Stack using following article. However, I was getting HTTP 500 Error
while accessing phpmyadmin
from browser.
And installed phpmyadmin using below command.
sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl
Tried :
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
{ }
with [ ]
sudo phpenmod mbstring
Upvotes: 5
Views: 21554
Reputation: 1212
If you have an error like array and string offset access syntax with curly braces is no longer supported phpmyadmin
- the reason is that perhaps you have an old version of Linux/Ubuntu and old version of phpMyAdmin but new version of PHP 8+. Use these commands to fix the problem:
apt --yes install php-mbstring php8.1-gettext
apt --yes purge phpmyadmin
rm -rf /usr/share/phpmyadmin
mkdir /usr/share/phpmyadmin
cd /tmp
wget https://files.phpmyadmin.net/phpMyAdmin/5.2.1/phpMyAdmin-5.2.1-all-languages.zip
unzip /tmp/phpMyAdmin-5.2.1-all-languages.zip
cp -a /tmp/phpMyAdmin-5.2.1-all-languages/* /usr/share/phpmyadmin
rm -rf /tmp/phpMyAdmin-5.2.1-all-languages.zip
rm -rf /tmp/phpMyAdmin-5.2.1-all-languages/
To make a symlink use commands:
NOTE: /var/www/mysite.com/public_html/
is an example, paste your path to the site files on server
ln -s /usr/share/phpmyadmin /var/www/mysite.com/public_html/phpmyadmin
OPTIONAL. If you want to secure the phpMyAdmin folder with login and password as HTTP Basic Authentication - use commands:
apt --yes install apache2-utils
htpasswd -c /var/www/mysite.com/public_html/.htpasswd-phpmyadmin yourlogingoeshere
#enter your password
And finally Nginx additional settings on your site config
[...]
#phpmyadmin
location /phpmyadmin/ {
auth_basic "Restricted";
auth_basic_user_file /var/www/mysite.com/public_html/.htpasswd-phpmyadmin;
}
Do not forget to restart Nginx service nginx restart
Upvotes: 3
Reputation: 129
my fix was upgrading phpmyadmin
here an easy to follow guide:
https://devanswers.co/manually-upgrade-phpmyadmin/
Upvotes: 0
Reputation: 2752
I thought I'd add a quick note - If by chance you have more than one version of PHP installed either accidentally or deliberately, its possible that the PHP version in question does not have all of the necessary modules. To determine your active version, at the command line (terminal) do:
php -v
It will return the current active version. In my case this was v8.1 but I had previously installed version 8.0
To quickly fix the issue, I just re-installed the necessary packages like so:
sudo apt install php8.1 php8.1-cli php8.1-common php8.1-curl php8.1-gd php8.1-intl php8.1-mbstring php8.1-mysql php8.1-opcache php8.1-readline php8.1-xml php8.1-xsl php8.1-zip php8.1-bz2 libapache2-mod-php8.1 -y
Upvotes: 4
Reputation: 3346
This was taken from a chat. Some things might be inaccurate, but this solved the OP's problem
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
pwgen -s 32 1
cp config.sample.inc.php config.inc.php
. . .
$cfg['blowfish_secret'] = 'STRINGOFTHIRTYTWORANDOMCHARACTERS'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
. . .
vim /etc/apache2/conf-available/phpmyadmin-custom.conf
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>
:wq
, Run the following commanda2enconf phpmyadmin-custom && systemctl restart apache2 && mysql
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.
To only allow you to view phpMyAdmin, try:
<Directory "/path/to/that/phpMyAdmin-5.1.0-rc1-all-languages">
Options SymLinksIfOwnerMatch
DirectoryIndex index.php
Require local
# Or change it to
# Require ip 127.0.0.1
# change 127.0.0.1 to your personal computers ip address,
# not to the server ip
# if you want to access phpMyAdmin from a public server, but not allow others to access it
</Directory>
Upvotes: 10
Reputation: 41
My server configuration:
Particular | Command | Output |
---|---|---|
OS | # lsb_release -a | Ubuntu 18.04.5 LTS |
PHP | # php -v | PHP 8.0.3 |
Apache | # apache2 -v | Apache/2.4.29 (Ubuntu) |
MySQL | # mysql --version | mysql Ver 14.14 Distrib 5.7.33 |
I solved the issue by modifying these two files:
# nano /usr/share/php/Symfony/Component/DependencyInjection/ContainerBuilder.php
$service = null === $r->getConstructor() ? $r->newInstance() : $r->newInstanceArgs($arguments);
to
$service = null === $r->getConstructor() ? $r->newInstance() : $r->newInstanceArgs(array_values($arguments));
Another file CoreExtension.php
# nano -l /usr/share/php/Twig/Extension/CoreExtension.php
if (isset($object->$item) || \array_key_exists((string) $item, $object)) {
to
if (isset($object->$item) || array_key_exists((string) $item, json_decode(json_encode($object), true))) {
.. Finally restart the server ..
# service apache2 restart
Upvotes: 3