当我尝试让 phpmyadmin 在我的 Nginx 服务器上运行时,它会重写请求https://fellowshipmedia.eu/phpmyadmin到https://fellowshipmedia.eu/index.php。
我尝试读取设置了“rewrite_log”和“debug”标志的 error.log,但日志对我来说很难理解。我可以看到在某个点路径的前缀被删除了,但为什么呢?
这是 nginx conf 文件的一部分:
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /etc/letsencrypt/live/fellowshipmedia.eu/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/fellowshipmedia.eu/privkey.pem;
include snippets/ssl-params.conf;
server_name fellowshipmedia.eu;
root /usr/share/nginx/html/fellowshipmediaeu/httpsdocs/;
index index.php index.html index.htm ;
location / {
try_files $uri $uri/ /index.php?page=$uri;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}
这是访问日志:
86.83.94.220 - - [10/Jun/2017:07:24:10 +0200] "POST /phpmyadmin/index.php HTTP/2.0" 302 619 "https://fellowshipmedia.eu/phpmyadmin/index.php?db=&token=66594ef803698c67dfd27ab17d089a78&old_usr=root" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0"
86.83.94.220 - - [10/Jun/2017:07:24:10 +0200] "GET /index.php?token=cd06ccda9c2d36a7600e99474755558a HTTP/2.0" 404 233 "https://fellowshipmedia.eu/phpmyadmin/index.php?db=&token=66594ef803698c67dfd27ab17d089a78&old_usr=root" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0"
这是错误日志:https://pastebin.com/0BKXVjza
这是 fastcgi-php.conf:
fastcgi_split_path_info ^(.+\.php)(/.+)$;
try_files $fastcgi_script_name =404;
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
fastcgi_index index.php;
include fastcgi.conf;
答案1
它phpmyadmin
会将初始请求重定向到不正确的/index.php
状态 302。检查是否phpmyadmin
通过正确的前缀接收初始请求FastCGI
- 您的日志中缺少此部分,并且取决于snippets/fastcgi-php.conf
您的帖子中也缺少的内容。还请检查phpmyadmin
自己的设置,例如 PmaAbsoluteUri。
答案2
我在这个帖子中找到了另一个答案:Nginx phpmyadmin 登录后重定向到 / 而不是 /phpmyadmin
将其添加到服务器块以帮助 phpmyadmin 找到其位置:
# Phpmyadmin Configurations
location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
#fastcgi_pass 127.0.0.1:9000;
#fastcgi_param HTTPS on; # <-- add this line
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}
# Dealing with the uppercased letters
location /phpMyAdmin {
rewrite ^/* /phpmyadmin last;
}