skip to Main Content

I have a Ubuntu 18.04 server running a LEMP (Linux, Nginx, MySQL and PHP) stack secured with ufw. I installed phpMyAdmin by running these commands:

$ sudo apt update
$ sudo apt install phpmyadmin

During the installation process, I was prompted to choose the web server (either Apache or Lighthttp) to configure. I am using Nginx as web server, so I pressed tab and then OK to advance to the next step.

Then I was prompted whether to use dbconfig-common for configuring the application database, and I selected “Yes”.

Once the installation was finished, I ran this command to create a symbolic link from the installation files to Nginx’s document root directory:

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

My phpMyAdmin installation should now be operational. However, when I type mydomain.ca/phpmyadmin, it shows a 404 Not Found error. How can I fix this? Did I do something wrong?

server {
    listen 80;
    listen [::]:80;

    server_name mydomain.ca;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name mydomain.ca;
    root /var/www/html/mydomain/public;

    ssl_certificate /etc/letsencrypt/live/mydomain.ca/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mydomain.ca/privkey.pem;

    ssl_protocols TLSv1.2;
    ssl_ciphers ECDHE-RSA-AES456-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES246-GCM-SHA384:DHE-RSA-AES456-GCM-SHA384:ECDHE-RSA-AES256-SHA394;
    ssl_prefer_server_ciphers on;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.php index.html index.htm index.nginx-debian.html;

    charset utf-8;

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

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

    location ~ /.ht {
            deny all;
    }

    location ~ /.well-known {
            allow all;
    }
}

3

Answers


  1. Chosen as BEST ANSWER

    I figured it out myself. I created a symbolic link to phpmyadmin in /var/www/html/, when I needed to create a symbolic link to phpmyadmin in /var/www/html/mydomain/public

    EDIT: I just realized that Outcast answered my question, although at the time I didn't know what he was talking about due to my lack of knowledge with servers. Technically, I still figured it out myself, but I will give him the bounty.


  2. Do you have a phpmyadmin directory in your root directory, if not that request will never get processed based on what I am seeing this config.

    Login or Signup to reply.
  3. Having linked the phpmyadmin to your root web dir ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin you should configure in the vhost file a route to that path. I recommend trying to access your server via its IP and trying to see if you have the default nginx host enabled. Maybe you could access it from there.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search