©
このドキュメントでは、 php中国語ネットマニュアル リリース
一个非常安全的做法就是把 PHP 解释器放在 web 目录外的地方,比如说 /usr/local/bin。这样做唯一不便的地方就是必须在每一个包含 PHP 代码的文件的第一行加入如下语句:
#!/usr/local/bin/php
在这种情况下,要使 PHP 能正确处理 PATH_INFO 和 PATH_TRANSLATED 等变量的话,在编译 PHP 解释器时必须加入 --enable-discard-path 参数。
[#1] Anonymous [2014-02-28 13:54:10]
To add a new structure out the PHP directory, you have to do first:
- Configure the .ini file
- Add to your IDE the interpretor
[#2] terom at fixme dot fi [2013-12-15 10:02:09]
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)..