User Tools

Site Tools


linux:ubuntu_phpmyadmin_install

Ubuntu Install PhpMyAdmin On Nginx

Before you proceed be sure that you have either MariaDB or MySQL installed.

apt install phpmyadmin

You will get a few popup's

1: Configuration select nothing and hit “Ok”
2: Configure database hit “Yes”
3: Application password hit “Yes”

We will assume the the web servers document root is located in /var/www/html/ Now phpmyadmin installs itself in /usr/share/phpmyadmin so we will create a link to document root.

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

Create a phpmyadmin sql superuser.

mysql -u root -p
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password_here';
GRANT ALL PRIVILEGES ON *.* TO 'pmauser'@'localhost';
FLUSH PRIVILEGES;
exit

Create an nginx block.

server {
  listen 80;
  listen [::]:80;
  server_name pma.example.com;
  root /usr/share/phpmyadmin/;
  index index.php index.html index.htm index.nginx-debian.html;

  access_log /var/log/nginx/phpmyadmin_access.log;
  error_log /var/log/nginx/phpmyadmin_error.log;

  location / {
    try_files $uri $uri/ /index.php;
  }

  location ~ ^/(doc|sql|setup)/ {
    deny all;
  }

  location ~ \.php$ {
    fastcgi_pass unix:/run/php/php7.4-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    include snippets/fastcgi-php.conf;
  }

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

Finally restart nginx.

systemctl restart nginx

</code>

linux/ubuntu_phpmyadmin_install.txt · Last modified: 23/03/2023 13:06 by Allan