Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I created an entry in virtuals.conf for phpMyAdmin and restarted Nginx, but I can not get it to actually server phpMyAdmin. PHP is installed and configured with Nginx for fast-cgi, the virtuals.conf entry syntax checks out fine, and the mysql server is running.

Also FWIW, centos is the hostname of my CentOS VM I'm running.

Here is what my entry looks like:

    server {
    listen 80;
    server_name mysql.centos;

    location / {
        root /usr/share/phpMyAdmin;
        index index.php;
    }

    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /usr/share/phpMyAdmin$fastcgi_script_name;
        include fastcgi_params;
    }
}
share|improve this question

migrated from stackoverflow.com Oct 30 '11 at 12:38

This question came from our site for professional and enthusiast programmers.

1 Answer 1

up vote 1 down vote accepted

See an example from my setup:

server {
    listen 80;
    server_name domain.com;
    # Server root
    root /home/user/domain.com/public_html;
    index index.html index.php;

    location /MySQLAdmin {
        auth_basic "Restricted Access";
        auth_basic_user_file htpasswd_file;

        alias /usr/share/phpMyAdmin/;
        try_files $uri $uri/ @fastcgi;
    }
    location ~ .+\.php$ {
        # Return '400 Bad Request' for malformed URLs
        location ~ \..*/.*\.php$ {
            return 400;
        }
        # Map 418 error code (no bady uses) to fastcgi
        error_page 418 = @fastcgi;
        return 418;
    }
    location @fastcgi {
        fastcgi_pass 127.0.0.1:9000;
        ...
    }
    location / {
        try_files $uri $uri/ @fastcgi;
    }
}

Requests to "MySQLAdmin" will be handled by that location which is aliased to phpMyAdmin folder. Nginx will return static files directly and send PHP to @fastcgi. Requests to ".php" will be sent to @fastcgi.

Nginx tries to serves everything else and sends those not found to @fastcgi. Basically, static files will be served by Nginx. Index.php requests not explicit written out will not be found and passed to @fastcgi.

share|improve this answer

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.