【问题标题】:nginx cant connect to phpmyadminnginx 无法连接到 phpmyadmin
【发布时间】:2015-06-23 08:33:13
【问题描述】:

我无法使用当前的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 有关系吗?我不确定如何/是否应该编辑此文件。

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

【问题讨论】:

    标签: nginx phpmyadmin


    【解决方案1】:

    意识到我只需要搬家:

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

    【讨论】:

      猜你喜欢
      • 2019-03-11
      • 2011-03-14
      • 2016-01-08
      • 2016-06-01
      • 2014-03-13
      • 2017-02-01
      • 2016-11-16
      • 2020-05-17
      • 1970-01-01
      相关资源
      最近更新 更多