nginx无法连接到phpmyadmin

时间:2015-06-23 08:33:14

标签: nginx phpmyadmin

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

的/ etc / nginx的/启用的站点 - / 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";
    }

}

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

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

是否与fastcgi_params有关?我不确定应该如何编辑这个文件。

对于我应该尝试的任何想法都将非常感激。

1 个答案:

答案 0 :(得分:0)

意识到我只需要移动:

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

}