NGINX PhpMyAdmin ?token= 리디렉션 문제 해결 방법

NGINX

이전 포스트에서 우분투에 PhpMyAdmin을 APT 패키지 관리자를 통해 쉽게 설치하고 가상호스트의 root 디렉토리 하위에 심볼릭 링크를 연결해서 설정하는 방법을 소개한 적이 있습니다.

1

그런데 워드프레스와 같은 CMS 프로그램을 사용하면서 PhpMyAdmin을 연결하면 로그인시 위 스크린샷 처럼 최상위 디렉토리에 리디렉션 되는 문제가 발생되었는데요. 이러한 문제는 php.ini의 보안 설정중 하나인cgi.fix_pathinfo 항목이 0으로 설정되어 있는 경우 발생하게 됩니다.

보안 설정을 포기할 수는 없으므로 심링크 대신 아래의 설정을 NGINX 가상호스트 설정 아래 부분에 추가합니다.

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

        location ~ ^/phpmyadmin/(.+\.php)$ {
                try_files $uri =404;
                root /usr/share/;
                fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include /etc/nginx/fastcgi_params;
        }

        location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
                root /usr/share/;
        }
}

location /phpMyAdmin {
        rewrite ^/* /phpmyadmin last;
}

fastcgi_pass에서 운영하는 php 버전에 맞게 설정합니다.

3

위 설정을 마친 다음 NGINX를 재시작 후 다시 로그인을 해서 /phpmyadmin 으로 올바르게 접속되는 것을 확인하면 되겠습니다.

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

Fill out this field
Fill out this field
유효한 이메일 주소를 입력해주세요.