0

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;
    }
}

1 Answer 1

1

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.

You must log in to answer this question.

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