shell - PHP cp permissions issue -
php script (restore.php):
var_dump( get_current_user()); var_dump( shell_exec( " cp /var/www/bkp/* /var/www/html 2>&1 " )); when script accessed in browser:
string(6) "apache" string(115) "cp: cannot create regular file `/var/www/html/227.png': permission denied cp: cannot remove `/var/www/html/234.png' permission denied " console:
cd /var/www/html sudo -u apache touch test.txt ls test.txt -> test.txt sudo -u rm 234.png -f ls 234.png -> ls: 234.png: no such file or directory sudo -u apache php restore.php ls 234.png -> 234.png can explain why getting permission issues in php script when run in browser?
are sure apache running apache user? get_current_user() returns owner of script. think apache running apache maybe it's not.
you can name of process owner this:
$processuser = posix_getpwuid(posix_geteuid()); print $processuser['name'];
Comments
Post a Comment