Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I don't want phpMyAdmin to be in the folder with my site but they should have access on and respectively. But this configuration doesn't seem to work:

  • 403 on
  • No input file specified on

Configuration is presented below.

server {

    error_log /var/log/nginx/test.error.log error;
    access_log /var/log/nginx/test.access.log;

    root /home/me/test/www-site;

    gzip on;
    gzip_types application/x-javascript application/javascript text/javascript text/css;

    client_max_body_size 50m;

    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
            expires 1M;

    location / {
            index index.php index.html index.htm;

    location /phpMyAdmin/ {
            # one of those is included, both don't work
            alias /home/me/test/phpMyAdmin;
            root /home/me/test/;

    location ~ \.php {
            fastcgi_pass    unix:/var/run/php5-fpm.sock;
            fastcgi_split_path_info ^(.+\.php)(.*)$;

            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
share|improve this question

1 Answer 1

You cannot have a request terminated through several sibling location directives at the same time (unless you do URL rewriting).

  • Your request returns 403 because location /phpMyAdmin/ must not have an index file (the index directive from location / does not apply), and directory listing must not be permitted.

  • Your request can similarly fit only one location at the same time. So, it gets handled by the location ~ \.php, which has a root of /home/me/test/www-site, since the directives from location /phpMyAdmin/ don't apply.

Similarly, the directives alias and root are mutually exclusive.

share|improve this answer
Well, I mentioned in comment that I don't use alias and root at the same time. They just both don't work. I copied index into /phpMyAdmin/ sections. Then if I pass non-existed path in root, it will say me No such file or directory, but if I pass existed path, it will check the files in the global root, totally ignoring the root I passed in the location. Well, after all how can I rewrite to match another root and use all other rules like expiration of resources and php files handling? regex + local root + try_files just don't work. – efpies Dec 2 '13 at 12:50
You just have to start afresh. You cannot do what you want the way you want to do it. It still sounds like what you're trying to do relies on having various side effects from past location directives; that's basically not how nginx works. – cnst Dec 2 '13 at 20:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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