如何将 PHP 应用程序限制在它们自己的目录和它们自己的 php.ini 中? [英] How do I limit PHP apps to their own directories and their own php.ini?

查看:20
本文介绍了如何将 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

这篇关于如何将 PHP 应用程序限制在它们自己的目录和它们自己的 php.ini 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆