ติดตั้ง phpMyAdmin ให้ Nginx บน Ubuntu 18.04

1.Installing phpMyAdmin

$ sudo apt update
$ sudo apt install phpmyadmin

During the installation process, you will be prompted to choose the web server (either Apache or Lighttpd) to configure. Because we are using Nginx as a web server, we shouldn’t make a choice here. Press tab and then OK to advance to the next step.

Next, you’ll be prompted whether to use dbconfig-common for configuring the application database. Select Yes. This will set up the internal database and administrative user for phpMyAdmin. You will be asked to define a new password for the phpmyadmin MySQL user. You can also leave it blank and let phpMyAdmin randomly create a password.

ถ้าจะ recofig ก็

sudo dpkg-reconfigure phpmyadmin

สร้าง link

$ sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
https://server_domain_or_IP/phpmyadmin

แต่น่าจะติด 403 Forbidden

ให้ เพิ่ม index.php ในไฟล์ /etc/nginx/sites-available/example.com

$ sudo nano /etc/nginx/sites-available/example.com
server {
        listen 80;
        root /var/www/html;
        index index.php index.html index.htm index.nginx-debian.html index.php;
        server_name example.com;

        location / {
                try_files $uri $uri/ =404;
        }

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        }

        location ~ /\.ht {
                deny all;
        }
}

ทีนี้จะเข้าได้ละ

Fixed phpMyAdmin ใน Ubuntu 18.04 “Warning in ./libraries/plugin_interface.lib.php#551 count()”

ปัญหา

Warning in ./libraries/plugin_interface.lib.php#551
 count(): Parameter must be an array or an object that implements Countable

วิธีแก้

backup ไฟล์ plugin_interface.lib.php ไว้ก่อน

$ sudo cp /usr/share/phpmyadmin/libraries/plugin_interface.lib.php /usr/share/phpmyadmin/libraries/plugin_interface.lib.php.bak

เข้าไปแก้ไขไฟล์ plugin_interface.lib.php

$ sudo nano /usr/share/phpmyadmin/libraries/plugin_interface.lib.php 

กด CTRL + W แล้วค้นหาคำว่า

if ($options != null && count($options) > 0) {

ให้แทนด้วย

if ($options != null && count((array)$options) > 0) {

Link