One thing is wrong dor sure: When using single quotes (' '), as you did, the variable $output will not
be replaced with the value of $output. Use double quotes (" ") instead.
Also, what is the value of $output? Can www-data really write there?
You can Check with this: $cmd = "tide -ml -fh -o $output 2>&1
"; Any errors from the 'tide' program will show in you browser.
I noticed 'tide' outputs html code. You could also try without the -o $output
part first. The html from 'tide' will show nicely in the browser.
$output = '/tmp/tide.html';
$cmd = "tide -ml -fh";
// $cmd = "tide -ml -fh -o $output 2>&1";
// $cmd = "tide -ml -fh -o $output";