1

I am trying to configure Nginx so that I can access PhpMyAdmin from a subdirectory (aka domain.com/phpmyadmin). 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_pass 127.0.0.1:9000;
               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 { ...

to...

location /secret { ...

everything seems to break. What am I doing wrong?

1 Answer 1

1

You should use an alias instead:

location /mysecretdirectory {
    alias /usr/share/phpmyadmin/;
}
2
  • 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, 2013 at 18:19
  • So check your error logs and find out why. Jan 7, 2013 at 18:36

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.