5

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

server {
listen 80;
server_name example.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;
}

}
masegaloeh
  • 18,236
  • 10
  • 57
  • 106
MultiformeIngegno
  • 1,687
  • 9
  • 26
  • 31
  • 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 02:02

2 Answers2

13

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.

Justin T.
  • 346
  • 1
  • 3
0

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;
    }
}
womble
  • 96,255
  • 29
  • 175
  • 230