Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 having issues with my phpmyadmin on my nginx install.

When I enter <ServerIP>/phpmyadmin and logs in, I get redirected to <ServerIP>/index.php?<tokenstuff> instead of <ServerIP>/phpmyadmin/index.php?<tokenstuff>

Nginx config file:

user  nginx;
worker_processes  5;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/;

events {
    worker_connections  1024;

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  2;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;


server {
    listen       80;
    server_name  _;

    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index  index.php index.html index.htm;

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;

    # proxy the PHP scripts to Apache listening on
    #location ~ \.php$ {
    #    proxy_pass;

    # pass the PHP scripts to FastCGI server listening on
    location ~ \.php$ {
        root           /usr/share/nginx/html;
        try_files $uri =404;
        fastcgi_pass   unix:/tmp/php5-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    location ~ /\.ht {
        deny  all;
    location /phpmyadmin {
    root /usr/share/;
    index index.php index.html index.htm;
    location ~ ^/phpmyadmin/(.+\.php)$ {
        try_files $uri =404;
        root /usr/share/;
        fastcgi_pass unix:/tmp/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $request_filename;
        include fastcgi_params;
        fastcgi_param PATH_INFO $fastcgi_script_name;

    location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
        root /usr/share/;

(Any general tips on tidying op those config files are accepted too)

share|improve this question
@MichaelHampton Actually I think that was the problem. I removed the package installed via yum, and downloaded the latest from the phpmyadmin website, and voilá. If you put up an answer, I will accept that. – Frederik Nielsen Oct 2 '12 at 19:15
up vote 2 down vote accepted

This doesn't sound like an nginx issue. This sounds like phpMyAdmin wasn't installed correctly and thinks that it is at / instead of /phpmyadmin. Check your phpMyAdmin configuration.

share|improve this answer
This is what lead me to the right answer - reinstalling phpmyadmin - Thanks! :) – Frederik Nielsen Oct 2 '12 at 20:41

You're problem seems to be similar to this:

If by reading that and changing you're config you still have problems please do tell!

share|improve this answer
I read that thread, and tried some of the configs, but still the same issue - either gets redirected to / instead of /phpmyadmin, or just goes 404. – Frederik Nielsen Oct 2 '12 at 11:19
404 is "generated" by "try_files", which means that its not finding phpmyadmin files... maybe something wrong with phpmyamdin install? – Mikec Oct 3 '12 at 10:38
Just notice the other comment -.- I guess it was phpmyadmin config after all! – Mikec Oct 3 '12 at 10:39
Might be.. I think it was a combination of both. – Frederik Nielsen Oct 3 '12 at 11:04

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.