From PHP which interact with the VPS I can do:
$command = '/usr/bin/python3 say_hello.py';
$command = escapeshellcmd($command);
system($command);
with say_hello.py :
#!/usr/bin/python3
print("Hello")
print("<br>")
From terminal I can do :
/usr/bin/python3 rotate.py;
with rotate.py :
#!/usr/bin/python3
from PIL import Image
with Image.open("rotate_before.png") as im:
data = list(im.rotate(45).getdata())
imNew = Image.new(im.mode, im.size)
imNew.putdata(data)
imNew.save("rotate_after.png")
But from PHP I don't get "rotate_after.png" with this command line :
$command = '/usr/bin/python3 rotate.py';
$command = escapeshellcmd($command);
system($command);
it is the same with
shell_exec($command);
with
$command = '/usr/bin/python3 rotate.py';<br>
$command = escapeshellcmd($command);
system($command, $retval);
var_dump($retval);
I get:
int(1)
SOLUTION : With what has been said below :
For security I have kept chmod -R 0755 and added www-data for the dir_web-site