首页 > 解决方案 > 如何防止以任何方式从其目录中访问 PHP?

问题描述

我试图设置open_basedir常数。

这种方式有一个问题:我可以通过调用 PHP 命令绕过限制,exec并且我可以使用 PHP 调用终端命令。我可以阻止使用exec,但我不需要使用 PHP 阻止终端命令。

只有我想要实现的是阻止从我以open_basedir任何可能的方式设置的路径访问 PHP。

Fe 有一条路/var/www/public_html/test。和open_basedir="/var/www/public_html/test"

我想以任何可能的方式防止 PHP 访问路径之外。

标签: phpsecuritydirectory

解决方案


对不起,我不能发表评论,所以我会在这里写,如果你创建特定用户来运行 php

https://www.binarytides.com/php-fpm-separate-user-uid-linux/

然后设置他只能访问项目文件夹的权限

https://unix.stackexchange.com/questions/101576/give-user-read-write-access-to-only-one-directory


推荐阅读