1) Create a script (preferrably .sh) that contains what you want to be ran as root.
# cat > php_shell.sh < wrapper.c <<CONTENT
main (int argc, char *argv)
/* WARNING: Only use an absolute path to the script to execute,
* a malicious user might fool the binary and execute
* arbitary commands if not.
system (“/bin/sh /path/to/php_shell.sh”);
4) Compile and set proper permissions, including the suid bit (saying that it should run with root privileges):
# gcc wrapper.c -o php_root
# chown root php_root
# chmod u=rwx,go=xr,+s php_root
php_root will now run with root permissions, and execute the commands specified in php_root.sh.