1

I am trying to configure Adminer with Nginx. This is my adminer.conf:

server {
  listen 80;
  
  location /adminer {
    root /usr/share/webapps/adminer;
    index index.php;
  }
}

However, when I go to localhost/adminer I get the error /usr/share/webapps/adminer/adminer/index.php is not found (No such file or directory).

The adminer folder is duplicated and I don't know why. The location should resolve to /usr/share/webapps/adminer/index.php.

Marlon
  • 19,924
  • 12
  • 70
  • 101
  • 1
    Check the difference between [`root`](http://nginx.org/en/docs/http/ngx_http_core_module.html#root) and [`alias`](http://nginx.org/en/docs/http/ngx_http_core_module.html#alias) nginx directives. – Ivan Shatsky Nov 15 '21 at 22:33
  • @IvanShatsky Thanks, `alias` was what I wanted – Marlon Nov 15 '21 at 22:45

1 Answers1

1

The location should just be

  • / from /usr/share/webapps/adminer for localhost
  • /adminer from /usr/share/webapps for localhost/adminer
server {
  listen 80;
  
  location /adminer {
    root /usr/share/webapps/;
    index index.php;
  }
}
ti7
  • 16,375
  • 6
  • 40
  • 68
  • Thanks... this worked.. first time using nginx... what if I wanted to set the location to `/test` for `localhost/test`. Nginx always seems to include `test` as part of the directory but I just want it as part of the URL and not part of the root directory. – Marlon Nov 15 '21 at 22:40
  • Nevermind, the `alias` keyword answered my question above. – Marlon Nov 15 '21 at 22:45
  • Not to worryl everyone's first time for something, and nginx takes some unusual mindset!.. often you want to create your own `nginx.conf`, while the default one will [include](http://nginx.org/en/docs/ngx_core_module.html#include) many files from its location in `/etc/`, which can bring in paths you don't expect or without it lose some mimetype filtering, etc. you want to support .. I've never used `alias`, but it's probably what you're after if it works! – ti7 Nov 15 '21 at 22:48