ติดตั้ง 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;
        }
}

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