Nginx

使用 nginx / php-fpm 登錄後的 phpmyadmin 空白頁面

  • April 6, 2019

我可以訪問 www.***/phpmyadmin 登錄。如果我使用 mysql 使用者登錄,只需點擊空白頁而沒有錯誤。系統在樹莓派上執行。

安裝:nginx 1.2.1,php5.4.36

我嘗試從不同機器上的不同瀏覽器登錄。我重置了 cookie。網址更改為 phpmyadmin/index.php?token=****3a35b78052f67500a6bb2bd411e6

我的 nginx 配置:

   upstream php-handler {
   server 127.0.0.1:9000;
   #server unix:/var/run/php5-fpm.sock;
   }

   server {
   listen 80;
   server_name ***.net;
   return 301 https://$server_name$request_uri; # enforce https
   }

   server {
   listen 443 ssl;
   server_name ***.net;

   ssl_certificate /etc/nginx/cert.pem;
   ssl_certificate_key /etc/nginx/cert.key;

   ssl_ciphers "AES128+EECDH:AES128+EDH";
   ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
   ssl_prefer_server_ciphers on;
   ssl_session_cache shared:SSL:10m;
   add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
   add_header X-Frame-Options DENY;
   add_header X-Content-Type-Options nosniff;

   # Path to the root of your installation
   root /var/www/owncloud;

   client_max_body_size 1000M; # set max upload size
   fastcgi_buffers 64 4K;

   rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;
   rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;
   rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;

   index index.php
   error_page 403 /core/templates/403.php;
   error_page 404 /core/templates/404.php;

   location = /robots.txt {
   allow all;
   log_not_found off;
   access_log off;
}


# phpmyadmin
location /phpmyadmin {
alias   /usr/share/phpmyadmin;
index   index.php;
}

location ~ ^/phpmyadmin/libraries {
deny all;
}

location ~ ^/phpmyadmin/setup/lib {
deny all;
}

location ~ ^/phpmyadmin/setup/(.+\.php)$ {
auth_basic              "phpMyAdmin Setup";
auth_basic_user_file    "/etc/phpmyadmin/htpasswd.setup";
alias                   /usr/share/phpmyadmin/setup/$1;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass            php-handler;
fastcgi_index           index.php;
include                 fastcgi_params;
}

location ~ ^/phpmyadmin/(.+\.php)$ {
alias                   /usr/share/phpmyadmin/$1;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass            php-handler;
fastcgi_index           index.php;
include                 fastcgi_params;
}

location ~ ^/(?:\.htaccess|data|config|db_structure\.xml|README) {
   deny all;
}


location ~ \.php(?:$|/) {
   fastcgi_split_path_info ^(.+\.php)(/.+)$;
   include fastcgi_params;
   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
   fastcgi_param PATH_INFO $fastcgi_path_info;
   fastcgi_param HTTPS on;
   fastcgi_pass php-handler;
   fastcgi_index index.php;
}

# Optional: set long EXPIRES header on static assets
location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
expires 30d;
# Optional: Don't log access to assets
access_log off;
}

}

我感謝您的幫助

我想我剛剛遇到了同樣的問題,儘管使用 Apache。如果您在頁面上查看原始碼,您是否看到大部分 html 仍然是空幀?

如果是這樣,那麼問題很可能是由於您的 nginx 設置中的以下行:

add_header X-Frame-Options DENY;

將此設置為 SAMEORIGIN 為我帶來了 phpmyadmin,該指令阻止頁面在任何上下文中顯示在框架中。

我在嘗試的任何日誌中都找不到任何錯誤。

好像有文件權限衝突,請為nginx和php-fpm設置相同的使用者執行,最常見的“nginx”或“www-data”。配置文件是 /etc/php-fpm.d/www.conf 和 /etc/nginx.conf。例如,您可以為 hpMyadmin 文件設置使用者和組chown nginx:nginx /usr/share/phpmyadmin/*

引用自:https://unix.stackexchange.com/questions/186003