nginx 无法连接到 phpmyadmin

nginx cant connect to phpmyadmin

我无法使用当前的 nginx 配置连接到 phpmyadmin

/etc/nginx/sites-enabled/couponmonk_project

server {

    error_log /var/log/nginx/error.log debug;
    access_log /var/log/nginx/access.log;

    location / {
    proxy_pass http://localhost:8000;
        proxy_redirect off;

        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    location /static {
        alias  /home/giri/couponmonk_project/couponmonk_project/static;
    }

    location /phpmyadmin {
        root /usr/share/nginx/www;        
        index  index.html index.htm index.php;        
    }

    # pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock
    location ~ \.php$ {
       try_files $uri =404;
       fastcgi_pass unix:/var/run/php5-fpm.sock;
       fastcgi_index index.php;
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
       include fastcgi_params;
    }

    location /socket.io {
        proxy_pass http://localhost:8000/socket.io;
        proxy_redirect off;
        proxy_buffering off;

        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
    }

}

当我尝试使用 my_ip_address/phpmyadmin 访问 phpmyadmin 时,出现 404 Not Found 错误。我的其他路径似乎工作正常。

文件夹 /usr/share/nginx/www/phpmyadmin 包含 index.php 文件。作为快速测试,我在此处插入了一个 index.html 文件,它已正确显示。

fastcgi_params有关系吗?我不确定 how/if 是否应该编辑此文件。

任何关于我应该尝试什么的想法都将不胜感激。

意识到我只是需要移动:

location ~ \.php$ {
...
}

里面:

location /phpmyadmin {
....
}

.conf

server {

  error_log /var/log/nginx/error.log debug;
  access_log /var/log/nginx/access.log;

  location / {
    proxy_pass http://localhost:8000;
      proxy_redirect off;

      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
  location /static {
      alias  /home/giri/couponmonk_project/couponmonk_project/static;
  }

  location /phpmyadmin {
      root /usr/share/nginx/www;        
      index  index.html index.htm index.php;        

     # pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock
     location ~ \.php$ {
     try_files $uri =404;
     fastcgi_pass unix:/var/run/php5-fpm.sock;
     fastcgi_index index.php;
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
     include /etc/nginx/fastcgi_params;
     }
  }


  location /socket.io {
      proxy_pass http://localhost:8000/socket.io;
      proxy_redirect off;
      proxy_buffering off;

      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "Upgrade";
  }

}