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 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_index index.php;
        fastcgi_param SCRIPT_FILENAME /usr/share/phpMyAdmin$fastcgi_script_name;
        include fastcgi_params;
share|improve this question

migrated from Oct 30 '11 at 12:38

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

up vote 1 down vote accepted

See an example from my setup:

server {
    listen 80;
    # Server root
    root /home/user/;
    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 {
    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


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.