Search code examples
phpsecuritydirectory

How to prevent access PHP out of its directory in any way?


I've tried to set open_basedir constant.

This way has a problem: I could bypass the limitation by calling exec PHP command and I have the ability to call a terminal command with PHP. I could block to use exec but I don't need to prevent terminal commands with PHP.

Only what I want to achieve is preventing access PHP out of some path I've set in open_basedir any possible way.

F.e There is a path /var/www/public_html/test. And open_basedir="/var/www/public_html/test"

I want to prevent PHP access out of the path in any possible way.


Solution

  • Sorry, I can't leave comment so i'll write here, what if you create specific user for run php

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

    and then set rights that he have access only for project folder

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