How do I limit PHP apps to their own directories and their own php.ini?(如何将 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 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何将 PHP 应用程序限制在它们自己的目录和它们自己的 php.ini 中?


基础教程推荐
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何替换eregi() 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01