Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Here is my phpmyadmin config file:

server {
    listen   8080;
    server_name  phpmyadmin;

    access_log  /var/log/nginx/phpmyadmin.access.log;
    error_log   /var/log/nginx/phpmyadmin.error_log warn;

    root   /var/www/phpmyadmin;
    index  index.php index.htm;

    location ~ \.php {
            include /etc/nginx/fastcgi_params;
            keepalive_timeout 0;
            fastcgi_param   SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_pass    127.0.0.1:9000;
    }
}

Right now when I go to http://domain.com:8080 it brings up the phpmysdmin site. I want it to only open phpmyadmin if I go to http://domain.com:8080/phpmyadmin. What change do I need to make here?

I have about 4 or 5 apps that I am going to run from nginx, and I'd prefer to keep each one in it's own sites-enabled profile, instead of one big config file that covers them all.

share|improve this question
add comment

2 Answers 2

a little bit more verbose:

server {
  listen       8080;
  server_name  phpmyadmin;

  access_log  /var/log/nginx/phpmyadmin.access.log;
  error_log   /var/log/nginx/phpmyadmin.error_log warn;
  location ~ /phpmyadmin/.*\.php {
    root            /var/www;
    include         /etc/nginx/fastcgi_params;
    fastcgi_param   SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_pass    127.0.0.1:9000;
  }
  location /phpmyadmin/ {
    root   /var/www;
    index  index.php;
  }
  location = /phpmyadmin {
    rewrite ^ /phpmyadmin/index.php;
  }
  location / {
    return 403;
  }
}

also note the root setting: it's relative to request path, not whatever comes after that. So a request of http://phpmyadmin/phpmyadmin/index.php will make nginx try to find the file in $root/phpmyadmin/index.php where the $root is root path set in the location block.

share|improve this answer
    
Thank you! I've been trying to get this to work all night. I didn't realize it was using the full request path. –  ABentSpoon Jun 25 '12 at 5:52
add comment

Use location:

location /phpmyadmin {
        root   /var/www/phpmyadmin;
        include /etc/nginx/fastcgi_params;
        keepalive_timeout 0;
        fastcgi_param   SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_pass    127.0.0.1:9000;
}
share|improve this answer
add comment

Your Answer

 
discard

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.