phpunit 설치 오류의 원인과 해결 방법

WBOY
풀어 주다: 2016-08-08 09:29:50
원래의
1277명이 탐색했습니다.

공식 지침

안타깝게도 phpunit은 아직 ArchLinux 저장소에 없습니다.

그러므로 다운로드 및 설치 방법을 이용하세요. 공식 지침을 따르세요.

<code>wget https://phar.phpunit.de/phpunit.phar
chmod +x phpunit.phar
sudo mv phpunit.phar /usr/local/bin/phpunit
phpunit --version</code>
로그인 후 복사

결과는 다음과 같은 오류입니다.

<code>PHP Warning:  realpath(): open_basedir restriction in effect. File(/usr/local/bin/phpunit) is not within the allowed path(s): (/srv/http/:/home/:/tmp/:/usr/share/pear/) in /usr/local/bin/phpunit on line 3
PHP Fatal error:  Class 'Phar' not found in /usr/local/bin/phpunit on line 714</code>
로그인 후 복사

phar 확장 활성화

먼저 해결하세요Fatal error: Class 'Phar' not found.

<code>ls /usr/lib/php/modules</code>
로그인 후 복사

phar.so를 찾았습니다. 이는 Phar 확장이 설치되었음을 의미합니다. 그러면 확장이 활성화되지 않았습니까?
/etc/php/php.ini을 열고 phar을 검색해 보니 과연 extension=phar.so이 코멘트 처리되어 있는 것을 발견했습니다. 줄 앞의 ;을 제거하고 php.ini를 저장한 후 phpunit --version을 다시 실행하세요.

<code>PHP Warning:  realpath(): open_basedir restriction in effect. File(/usr/local/bin/phpunit) is not within the allowed path(s): (/srv/http/:/home/:/tmp/:/usr/share/pear/) in /usr/local/bin/phpunit on line 3
PHP Warning:  Phar::mapPhar(): open_basedir restriction in effect. File(/usr/local/bin/phpunit) is not within the allowed path(s): (/srv/http/:/home/:/tmp/:/usr/share/pear/) in /usr/local/bin/phpunit on line 714</code>
로그인 후 복사

Fatal error해결되었으나 여전히 경고가 표시되고 phpunit이 제대로 실행되지 않습니다.

파일 액세스를 위한 PHP 보호 메커니즘

Google에서 설명을 찾았습니다: http://www.templatemonster.com/help/open_basedir-restriction-in- effect-filex-is-not-within-the-allowed-paths-y.html

PHP open_basedir 보호 조정은 폴더가 특별히 PHP open_basedir 설정을 제외하지 않는 한 사용자가 PHP를 사용하여 홈 디렉터리 외부에 있는 파일이나 스크립트를 열지 못하게 하는 안전 모드 보안 조치입니다. 특정 디렉토리 아래의 파일로 제한되어 특정 사용자의 PHP 스크립트가 승인되지 않은 사용자 계정의 파일에 액세스하는 것을 방지합니다. 파일이 지정되거나 허용되는 디렉토리 트리 외부에 있으면 PHP는 파일 열기를 거부하고 다음 오류가 발생할 수 있습니다: ...

의미: php.ini의 open_basedir은 안전한 파일 액세스를 보장하기 위한 PHP 설정입니다. 이 옵션을 할당하면 모든 파일 작업이 특정 디렉터리로 제한되므로 사용자는 PHP 스크립트를 사용하여 승인되지 않은 콘텐츠를 읽을 수 없습니다. fopen, gzopen을 통해 파일을 열려고 할 때 파일이 더 이상 허용되지 않는 디렉터리에 있으면 위와 같은 경고 메시지가 나타납니다.

경고 메시지에서 액세스 가능한 디렉터리에 /srv/http/:/home/:/tmp/:/usr/share/pear/이 포함되어 있는 것으로 나타났습니다. ~/bin은 PATH 변수에 있고 php 스크립트에서도 읽을 수 있는 디렉터리이므로

<code>mv /usr/local/bin/phpunit ~/bin</code>
로그인 후 복사

phpunit --version을 다시 실행하여 올바른 결과를 얻으세요.

<code>PHPUnit 4.5.0 by Sebastian Bergmann and contributors.</code>
로그인 후 복사

phpunit이 성공적으로 설치되었습니다!

위 내용은 관련 내용을 포함하여 phpunit 설치 오류의 원인과 해결 방법을 소개하고 있으니, PHP 튜토리얼에 관심이 있는 친구들에게 도움이 되었으면 좋겠습니다.

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!