Skip to content
Advertisement

How to restrict PHP file access to execution directory?

I have a bunch of PHP scripts inside of, say, /public_html/mydir/, and these scripts may possibly try to delete files / do other stuff to the filesystem.

I want to allow all filesystem modifications within the /public_html/mydir/ directory, but any access (or deletion) outside of the mydir directory shouild not be allowed.

How can I do this?

Advertisement

Answer

You either make a user that only has permission to access these directories, or you have to somehow run PHP in a sandbox like chroot

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement