'How to configure Nginx and Adminer

I installed the Nginx server on kali linux and I manage to access it by entering localhost in the browser. I then installed Adminer in order to graphically manage my databases but when I enter http://localhost/adminer in my browser, I receive a 404 Not found.

I don't know where I missed it!

here is the content of my /etc/nginx/sites-available

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

# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;

root /usr/share/adminer;

# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;

server_name localhost;

location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
    try_files $uri $uri/ =404;
}

# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
    include snippets/fastcgi-php.conf;

    # With php-fpm (or other unix sockets):
    fastcgi_pass unix:/run/php/php7.4-fpm.sock;
    # With php-cgi (or other tcp sockets):
#   fastcgi_pass 127.0.0.1:9000;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
#   deny all;
#}
}

here is the content of /log/nginx/error.log

 2020/09/02 07:43:47 [error] 71583#71583: *1 "/usr/share/nginx/html/adminer/index.html" is 
 not found (2: No such file or directory), client: ::1, server: , request: "GET /adminer/ 
 HTTP/1.1", host: "localhost"

According to the error message, it the /usr/share/nginx/html directory does not contain the adminer folder which is true since I do not have this folder in that location. So I don't know why Nginx is looking for it there, or if it should even be there; If so why is it not there? how can I solve this problem?



Solution 1:[1]

Nginx is looking for a 'index.html' inside a path that is not your root directive, this is a fact: "/usr/share/nginx/html/adminer/index.html" is not found

Do these steps, to fix it easily:

  1. If you have not this path in your file system: "/usr/share/adminer", create it, because it is your root in your conf file.
  2. Copy your adminer file to this directory and rename it to index.php
  3. Update your index directive in your conf file, including the index.php:

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

  1. Make sure you have a simlink to your "/etc/nginx/sites-available/your.conf" in "/etc/nginx/sites-enabled" otherwise your vhost conf will not be loaded and it will not work.

    sudo ln -s /etc/nginx/sites-available/your.conf /etc/nginx/sites-enabled/

Done, reload the server and all be fine.

Solution 2:[2]

Adminer is based on adminer.php. You need to put adminer.php at the index directive. Solved for me.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 MFedatto