1

I have a PHP site that's running fine. Now I need to add URL /adminer/ that is mapped to a directory outside of the root and there I have an index.php file that needs to be executed. I have following config (Debian 9.7):

server {
    listen 80;

    root /home/usr/www/xxx.xxx/web/app/www;
    index index.php;

    server_name xxx.xxx;

    location /adminer {
        root /home/usr/www/xxx.xxx/web/adminer;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/xxx.xxx.php7.0-fpm.socket;
    }
}

When I open http://xxx.xxx/adminer/ I always get 404. I am trying for more than a hour different configs but can't find a working way. Thanks

2
  • 2
    Firstly, the path is constructed by concatenating the value of root with the URI. So if /adminer/ is already part of the URI, it doesn't need to be part of the root. Try: root /home/usr/www/xxx.xxx/web;. Secondly, you need a nested location to process your PHP URIs under the second root. See this answer. Jan 26 '19 at 16:00
  • 2
    Thanks, I would swear that I tried something like you mentioned :) If you want, you can place your comment as answer and I will accept it or I will place the config that worked. @RichardSmith
    – Bruce
    Jan 26 '19 at 20:31
2

Based on Richar Smith's comment, this is a working config:

server {
    listen 80;

    root /home/usr/www/xxx.xxx/web/app/www;
    index index.php;

    server_name xxx.xxx;

    location /adminer {
        root /home/usr/www/xxx.xxx/web;

        location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/var/run/php/xxx.xxx.php7.0-fpm.socket;
        }
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/xxx.xxx.php7.0-fpm.socket;
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.