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.

Recently I've been trying to set up a web server using Nginx (I normally use Apache). However I've ran into a problem trying to set phpMyAdmin up on an alias. The alias correctly takes you too the phpMyAdmin login screen, however when you enter valid credentials and hit go you end up back on the login screen with no errors.

Sounded like a cookie or session problem to me... but if I symlink the phpMyAdmin directory and try logging in through the symlinked version it works fine! Both the symlink and the alias one set the same number of cookies and both set seem to set the cookies for the correct domain and path.

My Nginx config for the php alias is as follows:

location ~ ^/phpmyadmin/(.*\.php)$ {
    alias /usr/share/phpMyAdmin/$1;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $request_filename;
}
  • I'm running Nginx 0.8.53
  • PHP 5.3.3
  • MySQL 5.1.47
  • phpMyAdmin 3.3.9 - self install
  • And php-mcrypt is installed.

Has anyone else experienced this behaviour before? Anyone have any ideas about how to fix it?

share|improve this question
    
I have the exact same problem. Did you post at their forum? –  0scar Apr 28 '11 at 13:56
add comment

2 Answers

up vote 2 down vote accepted

I had the exact same problem. I ran a website with a doc root in /var/www/somesite and wanted to hook phpmyadmin to some sub-folder on the site. I tried this with this config in nginx:

root /var/www/somesite;

location /pma/ {
    alias /usr/share/phpmyadmin/;
}

location ~ ^/pma/(.+\.php)$ {
    alias /usr/share/phpmyadmin/$1;
    fastcgi_pass   unix:/tmp/phpfpm.sock;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $request_filename;
    include fastcgi_params;
}

This seemed to work, except when I logged in, like you described, I just saw the front page again. No errors, nothing. If I logged in with a bad password, I got a "Cannot login to MySQL server"-error, as you'd expect.

Solution
Finally what I did was I dragged in all the stuff from fastcgi_params and found that changing the DOCUMENT_ROOT-parameter fixed this. So the nginx-config above changed to:

root /var/www/somesite;

location /pma/ {
    alias /usr/share/phpmyadmin/;
}

location ~ ^/pma/(.+\.php)$ {
    alias /usr/share/phpmyadmin/$1;
    fastcgi_pass   unix:/tmp/phpfpm.sock;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $request_filename;

    # From fastcgi_params
    fastcgi_param  QUERY_STRING       $query_string;
    fastcgi_param  REQUEST_METHOD     $request_method;
    fastcgi_param  CONTENT_TYPE       $content_type;
    fastcgi_param  CONTENT_LENGTH     $content_length;
    fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
    fastcgi_param  REQUEST_URI        $request_uri;
    fastcgi_param  DOCUMENT_URI       $document_uri;
    fastcgi_param  DOCUMENT_ROOT      /usr/share/phpmyadmin; # <-- Changed
    fastcgi_param  SERVER_PROTOCOL    $server_protocol;
    fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
    fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;
    fastcgi_param  REMOTE_ADDR        $remote_addr;
    fastcgi_param  REMOTE_PORT        $remote_port;
    fastcgi_param  SERVER_ADDR        $server_addr;
    fastcgi_param  SERVER_PORT        $server_port;
    fastcgi_param  SERVER_NAME        $server_name;
    fastcgi_param  REDIRECT_STATUS    200;
}

(Side note: I think this a problem with nginx, that you can't set an alias and the doc root at the same time. Weird, actually.)

share|improve this answer
    
Top work 0scar setting the DOCUMENT_ROOT seems to do the trick :-) –  stickaforkinme Apr 29 '11 at 14:41
add comment

Igor indicates your exact config should be working:

http://forum.nginx.org/read.php?2,3059,3060#msg-3060

You might post over there and see what they have to say; your config looks entirely valid to me too.

share|improve this answer
    
When I googled the problem it seemed that my config looked correct. Good thinking on posting in the Nginx forum, will try that. –  stickaforkinme Jan 16 '11 at 16:13
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.