Just a quick post - if you’re using PHP’s shell_exec to execute shell commands, take note of the following:
Permissions
If you’re reading or writing files, ensure that your working directory has the correct permissions for the www/apache user to access what it needs. On some systems, PHP will run as the nobody user, so adjust accordingly.
Pipes
Using pipes and redirection inside your command string is not going to work most of the time, what you probably want to do is create a seperate bash script on your server that contains all the commands you want to run. Then use PHP to execute the single bash script.
Paths
This one has got me a few times - just because a command is in the path when you’re SSH’d into the server, it doesn’t mean that it’ll be on PHP’s perceived path. This means that you’ll need to specify the full path to any system applications you are using (not for standard commands like cat, though). For example:
shell_exec("/usr/local/bin/htmldoc --jpeg=0 --webpage \\
-f out.pdf in.html");








