1
The shell command works normal via SSH, but PHP does not execute:
$cmd = '/bin/bash /usr/local/nginx/html/pHpServer-PG/api/dir.bash';
echo $cmd;
shell_exec($cmd);
BASH:
#!/bin/bash
/usr/bin/sudo mkdir -p /usr/local/nginx/html/nome_da_pasta
permissions
drwxrwxrwx. 8 ec2-user ec2-user 104 May 8 21:56 .
drwxr-xr-x. 12 ec2-user root 183 May 8 12:02 ..
drwxrwxrwx. 4 ec2-user ec2-user 4.0K May 8 21:31 admin
drwxrwxrwx. 4 ec2-user ec2-user 4.0K May 9 01:04 cliente
drwxrwxrwx. 3 ec2-user ec2-user 4.0K May 8 21:31 loja
drwxrwxrwx. 3 ec2-user ec2-user 17 May 8 12:20 pHpServer
drwxrwxrwx. 3 ec2-user ec2-user 17 May 8 12:09 pHpServer-ADm
drwxrwxrwx. 3 ec2-user ec2-user 17 May 8 12:15 pHpServer-PG
Note: I am using an AWS EC2 instance. The error log was this:
mkdir(): Permission denied
The user of php-fpm
is the 'Nginx'.
It is no longer simple to use the
mkdir
of PHP?– Woss
Check if the user running php has sudo permission.
– Filipe L. Constante
read: https://answall.com/questions/211599/php-mkdir-vs-chmod?rq=1
– David
@Andersoncarloswoss unable to use mkdir other than the fatal error in php-fpm
– Felipe Kusk
@Felipekusk And it wouldn’t be interesting to understand/solve the fatal error?
– Woss
@Andersoncarloswoss only in last case pq goes from work dmais the server and all modified with openresty Nginx etc only if can not do with bash msm I will start to enable the log to start looking
– Felipe Kusk
@David already tried all this stack post before arriving at bash
– Felipe Kusk
But what is the mistake that gives? That there is a lot of face XY problem.
– Woss
@Andersoncarloswoss he does not run bash via php, but ssh works mormal
– Felipe Kusk
But what about the mistake you make using
mkdir
?– Woss
@Andersoncarloswoss will enable Aki logs to see it from, fatal error in php-fpm, I will analyze here and come back with the error
– Felipe Kusk
@Andersoncarloswoss aew the error log was as follows: mkdir(): Permission denied, php-fpm user and Nginx'
– Felipe Kusk
@Andersoncarloswoss and sister gave, thanks
– Felipe Kusk
See? Much easier than writing a script for this :D
– Woss
@Andersoncarloswoss put this as an answer :D
– CypherPotato