1

This configutation works:

location /phpmyadmin {
   root /usr/share/;
   index index.php index.html index.htm;
   location ~ ^/phpmyadmin/(.+\.php)$ {
           try_files $uri =404;
           root /usr/share/;
           fastcgi_pass unix:/var/run/php5-fpm.sock;
           fastcgi_index index.php;
           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
           include /etc/nginx/fastcgi_params;
   }
   location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
           root /usr/share/;
   }
}

But this returns 404 on every .php file(while .css/.txt works fine):

location /pma {
    alias /usr/share/phpmyadmin;
    index index.php index.html index.htm;

    location ~ ^/pma/(.+\.php)$ {
            alias /usr/share/phpmyadmin/$1;
            try_files $uri =404;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            include /etc/nginx/fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    }

    location ~* ^/pma/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
            alias /usr/share/phpmyadmin/$1;
    }
}

Error log is empty.

littleguga
  • 166
  • 1
  • 7
  • I found the source of the problem with Richard Smith's answer. I had the `location ~ \.php$ {` instead of redirect for pma/.php files. – littleguga Jan 05 '16 at 19:06

1 Answers1

2

There is a catalogue of problems with alias and try_files.

You might want to consider using your old configuration hidden behind an internal rewrite:

location /pma {
    rewrite ^/pma(.*)$ /phpmyadmin$1;
}
location /phpmyadmin {
    internal;
    ...
}
Richard Smith
  • 12,834
  • 2
  • 21
  • 29