如何将 PHP 应用程序限制在它们自己的目录和它们自己的 php.ini 中?
我在我的 Mac 上运行多个 PHP 应用程序,运行 OS X 10.5.6、Apache 2、PHP 5.我为每个项目设置了子域、每个子域的主机文件条目以及 Apache 配置中的虚拟目录块.所以
I am running multiple PHP apps on my Mac, running OS X 10.5.6, Apache 2, PHP 5. I have subdomains setup for each project, a host file entries for each subdomain, and Virtual Directory blocks in the Apache config. So
project1.localhost 转到/Library/WebServer/Documents/Project1
project2.localhost 转到/Library/WebServer/Documents/Project2
等等……
project1.localhost goes to /Library/WebServer/Documents/Project1
project2.localhost goes to /Library/WebServer/Documents/Project2
etc...
但是,这种方法并没有真正隔离"网络应用程序.例如,如果我包含这样的脚本:
However, this method doesn't really "isolate" the web apps. For example, if I include a script like so:
<?php
include("/includes/include.php");
?>
它从我的计算机的基本目录中引用脚本.所以它访问
C:/includes/include.php
It references the script from the base directory of my computer. So it accesses
C:/includes/include.php
有没有办法让我参考一下
C:/Library/WebServer/Documents/Project2/includes/include.php
Is there a way for me to make it reference
C:/Library/WebServer/Documents/Project2/includes/include.php
基本上,让它不知道自己目录之外的任何东西.另外,有没有办法在每个子域的基础上使用 php.ini?
Basically, make it so that its not aware of anything outside of its own directory. Also, is there a way to use php.ini's on a per subdomain basis as well?
推荐答案
我相信可以为每个虚拟主机设置一个 php.ini
I believe it's possible to set a php.ini per virtual host
<VirtualHost *:80>
...
PHPINIDir /full/path/to/php/ini/
</VirtualHost>
这样你可以自定义 open_basedir 和其他
this way you can customize open_basedir and others
相关文章