This question already has an answer here:
I have the following script (
alert.sh) which has been setuid'd:
DISPLAY=:0.0 notify-send --urgency=low -i python "The job has finished"
and the following PHP file
<?php echo exec("/path/to/alert.sh")
www-data and run
php alert.php, I get an alert on my screen. All good.
However, when I open
alert.php in the browser, nothing happens.
I suspect some environment variable needs to be set, but I'm not sure which.