PHP Velho Oeste 2024

방법 4: 웹 트리 외부의 PHP 파서

매우 안전한 옵션은 PHP 파서 바이너리를 웹트리 밖에 위치시키는 것입니다. 예를 들면, /usr/local/bin 안에. 이 방법의 단 한가지 단점은 다음과 같은 줄을 PHP 태그를 포함하는 모든 파일의 첫번째 줄에 넣어야 한다는 점입니다:

#!/usr/local/bin/php
또한 파일을 실행 가능하게 해 둘 필요가 있습니다. 이것은 정확하게 실행을 위해서 #! 쉘 이스케이핑 메카니즘을 사용하는 펄이나 sh, 혹은 다른 일반적인 스크립팅 언어로 쓰여진 CGI 스크립트와 동일하게 취급합니다.

이 방법을 사용할 때, PHP가 PATH_INFOPATH_TRANSLATED를 올바르게 다룰 수 있게 하기 위해서는 PHP 파서를 컴파일 할 때, --enable-discard-path 옵션을 주어야 합니다.

add a note add a note

User Contributed Notes 2 notes

up
-7
Anonymous
10 years ago
To add a new structure out the PHP directory, you have to do first:

- Configure the .ini file
- Add to your IDE the interpretor
up
-9
terom at fixme dot fi
10 years ago
You can use binfmt-misc to avoid the need for the #! line, by registering your php5-cgi binary as an interpreter for *.php files. E.g. with Debian binfmt-misc installed:

    update-binfmts --install php5 /usr/bin/php5-cgi --extension php
    cat /proc/sys/fs/binfmt_misc/php5

However, you still need chmod +x on the .php file. And Apache will give a rather sad "500 Internal Server Error" if you are missing the +x permissions :( You can improve the error message using mod_rewrite (but not obliviate the need for +x)..
To Top