There is no easy way to do that, because the Web-server processes (and thereby PHP) running with very low rights. That's on purpose.
You probably need to play with the "sudo" system which allows you to selectively grant root permissions to selected users (like the special web-server user), running selected commands. But be very careful: Don't do it unless you are 100% sure what you are doing.
Botton line: It's not easy to do it, but it's certainly possible. You need to be comfortable with the "sudo" utility software package.