Cyrus Hackford

Tag: error

WordPress open_basedir 제한 오류 해결 방법

by Cyrus H. on Jan.05, 2010, under FIY, PHP, WordPress

WordPress에는 자체적으로 plugin, theme 등을 자동 설치할 수 있게 하는 기능이 있다. 물론 WordPress upgrade도 동일한 방법을 사용한다. 하지만 일부 특수한 환경에서 PHP의 open_basedir 제한 오류가 발생한다. 나도 이 오류를 지난 번부터 겪다가 방금 전에 그 해결책을 찾았다. 오류는 대개 이런 메시지를 보인다.

Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/tmp/stats.tmp) is not within the allowed path(s): (/path/to/my/account/:/path/to/allowed/tmp/) in /path/to/my/blog/wp-includes/functions.php on line 2140

Warning: touch() [function.touch]: open_basedir restriction in effect. File(/tmp/stats.tmp) is not within the allowed path(s): (/path/to/my/account/:/path/to/allowed/tmp/) in /path/to/my/blog/wp-admin/includes/file.php on line 184

PHP가 가진 장점 중 하나는 오류 메시지가 매우 친절하다는 것이다. 위 오류 메시지는 PHP가 /tmp 디렉토리에 접근 권한이 없다고 불평하는 내용을 담고 있다. 또 아래를 보면 PHP에게 접근이 허용된 디렉토리는 /path/to/my/account와 /path/to/allowed/tmp라고 알려주고 있다. 즉, WordPress는 /path/to/allowed/tmp에서 모든 일을 처리해야 한다는 것이다.

구글신께 이 문제를 여쭤보았다. 그랬더니 바로 답1을 내려주시더라.
WordPress가 자동 설치를 위해 FTP 관련 함수를 사용하는데, define(‘WP_TEMP_DIR’,'/path/to/allowed/tmp’); 같이 임시 디렉토리 상수를 정의해도 ftp_rawlist() 함수가 이를 무시하기 때문에 부득이하게 PHP 환경 변수에도 손을 대어야 한다.

putenv('TMPDIR=/path/to/allowed/tmp');

위 구문을 wp-config.php 파일에 덧붙이면 모든 것이 해결된다. 아, 물론 저 /path/to/allowed/tmp는 자신에게 맞게 수정해야한다. 잘 모르겠다면 자신이 사용하는 서버의 관리자에게 물어보자.

  1. http://wordpress.org/support/topic/238738 []
Leave a Comment :, , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

나는 세벌식을 씁니다!

Hosted by AQUZ