Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to configure Nginx so that I can access PhpMyAdmin from a subdirectory (aka The code provided below seems to work for me although I don't want the alias to be /phpmyadmin.

location /phpmyadmin {

       root /usr/share/;
       index index.php index.html index.htm;
       location ~ ^/phpmyadmin/(.+\.php)$ {
               try_files $uri =404;
               root /usr/share/;
               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/;

If I try to change the location name from

location /phpmyadmin { ...


location /secret { ...

everything seems to break. What am I doing wrong?

share|improve this question

You should use an alias instead:

location /mysecretdirectory {
    alias /usr/share/phpmyadmin/;
share|improve this answer
I tried that already and restarted nginx, hoping that it would be as easy as I thought. Instead, I get a 403 error :( – Danafer Jan 7 '13 at 18:19
So check your error logs and find out why. – Michael Hampton Jan 7 '13 at 18:36

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.