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

查看:132
本文介绍了我如何限制PHP应用到它们自己的目录和自己的php.ini?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的Mac上运行多个PHP应用程序,运行OS X 10.5.6,阿帕奇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进入/库/ Web服务器/文件/ PROJECT1

project2.localhost去/库/ Web服务器/文件/ 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天全站免登陆