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.

I installed nginx and phpmyadmin. I set up a domain with these parameters to test phpmyadmin:

server {
listen 80;
server_name domain.com;

root /usr/share/phpmyadmin;
index index.php;
fastcgi_index index.php;

location ~ \.php$ {
include /etc/nginx/fastcgi.conf;
fastcgi_param SCRIPT_FILENAME /usr/share/phpmyadmin$fastcgi_script_name;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}


}

And everything works properly (if I visit the domain I can login to phpmyadmin). The problem is that it was just for testing phpmyadmin, now I'd like to move this to my 'default' site. But I can't figure out how to have it on /phpmyadmin. Here's the config for the 'default' nginx site (where I'd like to put this /phpmyadmin location):

server {

server_name blabla;

access_log  /var/log/nginx/$host.access.log;
error_log   /var/log/nginx/error.log;

root    /var/www/default;
index   index.php index.html;

location / {
try_files $uri $uri/ index.php;
}  

location ~ \.php$ {
include /etc/nginx/fastcgi.conf;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}

### NginX Status
location /nginx_status {
stub_status on;
access_log   off; 
}

### FPM Status
location ~ ^/(status|ping)$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
access_log      off;
}

}
share|improve this question
    
Where are the files for your 'default' site going to be? If you implement @womble's solution, you will want to make sure you change the root under your server block to the location of the files for your 'default' site. –  tfitzgerald Jun 11 '12 at 2:02
add comment

2 Answers

up vote 3 down vote accepted

As weird as it seems to sound, the "standard" config did not work for phpMyAdmin on my side.

Here is what I ended up doing, now working with success on "/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/;
           }
    }

I am nowhere a seasoned admin, and this piece of config needs cleaning, but it is a good starter I hope.

share|improve this answer
    
Thanks!! Your solution worked flawlessly! ;) –  MultiformeIngegno Jun 12 '12 at 17:49
    
I am redirected from myserver.com/phpmyadmin to localhost/phpmyadmin with this config. –  pinouchon Aug 7 '13 at 8:24
add comment

There's nothing special about phpmyadmin; a standard PHP location block will suffice:

location /phpmyadmin {
    root /usr/share/phpmyadmin;

    location ~ \.php$ {
        include /etc/nginx/fastcgi.conf;
        fastcgi_param SCRIPT_FILENAME /usr/share/phpmyadmin$fastcgi_script_name;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
    }
}
share|improve this answer
    
Uhm.. this is what I get going to site/phpmyadmin after using that snippet and reloading nginx config :( 404 Not Found nginx/1.3.1 –  MultiformeIngegno Jun 11 '12 at 11:33
    
So you've got something wrong. Fire up the debug log and find out what. –  womble Jun 11 '12 at 12:02
    
I have a lot of these: pastebin.com/MKp3b6C5 –  MultiformeIngegno Jun 11 '12 at 15:57
    
Anyone..? :) Do you need more info? –  MultiformeIngegno Jun 11 '12 at 21:05
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.