Problem :
Firstly, I am running all of these commands through www-data user..which is apache2 user…
Using php, and exec function to run these commands…
I create the directory
mkdir -p testing
Now lets see folders
ls
the directory testing is not showing…although the folder was created ( I check in physical path)
Solution :
Firstly, make sure that the directory you are writing into a) exists and b) has the right permissions to allow you to read/write to it.
Secondly, try not to use exec, system, or anything like that. Not only is it unsafe (passing args can be a real security hole), but it also adds a large overhead to the operation, having to spawn new sub-processes etc.
Also, using exec() just returns the last line of the command you run. If you really need to use a system program to perform functions then you should either use passthru() to return the data direct to the browser, or shell_exec() if you want to have the output in a string.