1

I am having a problem with my nginx server.

I am fairly new to nginx, so the config files aren't my strongest (yet)

I have this default.conf in /etc/nginx/conf.d/:

server {
    listen       80;
    server_name  _;
    #charset koi8-r;
    #access_log  logs/host.access.log  main;
    location / {
        root   /usr/share/nginx/html;
        index  index.php index.html index.htm;
    }
    error_page  404              /404.html;
    location = /404.html {
        root   /usr/share/nginx/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 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    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.html index.htm index.php;
    }
    location ~ \.php$ {
        root        /usr/share;
        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;
    }
}

but when I access <ServerIP>/phpMyAdmin it just gives me a 404.

Log files are like this:

2012/09/18 19:12:53 [error] 3184#0: *1 open() "/usr/share/phpMyAdmin/nginx-logo.png" failed (2: No such file or directory), client: 1.2.3.4, server: _, request: "GET /phpMyAdmin/nginx-logo.png HTTP/1.1", host: "4.3.2.1", referrer: "http://4.3.2.1/phpMyAdmin/index.php"

What do I do wrong?

1 Answer 1

1

Here is the relevant code from my configuration. I struggled to get this working as well and I'm also new to nginx.

Try adding the trailing slash to the end of the root declaration in the location section.

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/php-fpm.socket;
        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/;
    }
}
2
  • 1
    Thanks! Works like a charm! Now I just got one tiny problem left: When logging in to phpmyadmin, I get redirected to /index.php&token=stuff, where it should be /phpMyAdmin/index.php&token=stuff. Do you know how to fix this?
    – Frederik
    Sep 19, 2012 at 17:32
  • Maybe it has something to do with the other location entries in your default file. Try removing other entries. The code above works great for me.
    – Al_
    Sep 19, 2012 at 19:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .