Ok i'm having a nightmare with permissions..
I've got /var/www/src/myshell.sh which is executable
#!/bin/bash
echo "It's working" > /var/www/html/myshell.txt
This works fine from the CLI, the txt file is created containing the "It's working" text.
But when I try to run it from /var/www/html/test.php
<?php
$message=shell_exec("/var/www/src/myshell.sh 2>&1");
print_r($message);
?>
It returns the following in the browser :
/var/www/src/myshell.sh: line 3: /var/www/html/myshell.txt: Permission denied
And myshell.txt isn't created in /var/www/html
I spent all of last night trying every possible way I could find here on SO and elsewhere to set the correct permissions to no avail so I've given up trying to figure it out and would like to know if it's possible to run this shell script WITHOUT it trying to return anything to the browser as that seems to be causing the permission error.
So basically test.php starts the .sh script and then forgets about it. The processes I intend to use here don't need to be sent back to the browser anyway.
Could this be achieved by NOT using shell_exec and by using another php command instead maybe?
Many thanks