Shader
Shader

Reputation: 88

PHP-FPM rm Permission denied

I have nginx+php-fpm and I need to delete folder recursively from php-script:

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
$out = shell_exec('/bin/rm -vrf /data/vmail/test');
var_dump($out);

$out is NULL, but in error.log i receive

WARNING: [pool www] child 7210 said into stderr: "rm: "
WARNING: [pool www] child 7210 said into stderr: "cannot remove `/data/vmail/test'"
WARNING: [pool www] child 7210 said into stderr: ": Permission denied"

Supplementary groups exists:

# groups nginx
nginx : nginx vmail
# groups vmail
vmail : vmail nginx

Solutions

I don't consider these options as a solution. Also I don't consider a solution involving root user and /etc/sudoers or running php-fpm as a root. So... how is it possible to get /bin/rm working?

Additional info ##

Upvotes: 2

Views: 756

Answers (1)

Peter
Peter

Reputation: 31701

Deleting content of a directory is a write operation in The directory. So the user that runs PHP needs write permission on /data/vmail.

Upvotes: 1

Related Questions