I'm trying to launch unoconv using exec in php. It works with apache2, but not with nginx. I've already checked my php.ini and disable_functions not contain exec in both apache2 and nginx php.ini files.
-
Please provide more details of your code, how you are testing it, and the exact wording of any errors you receive. Otherwise, we are basically having to guess all these things rather than concentrating on your problem.IMSoP– IMSoP2014-06-08 16:58:51 +00:00Commented Jun 8, 2014 at 16:58
2 Answers
I'm not familiar with unconv, but I've had a similar problem with porting my server from Apache to nginx and exec.
nginx + php-fpm have a bare minimal $PATH set compared to apache, and it's likely your unoconv is not on that path.
You could try modifying your PATH settings, but a better way would be to specify the absolute path of unoconv
You can find the absolute path by using
which unoconv
You should also re-direct the error output to stdout, so you can see exactly why unoconv isn't starting
exec("/path/to/unoconv -param0 -param1 2>&1", $output);
print_r($output); //this should give failure reason
2 Comments
putenv('PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/node/bin');. Now it's work well.Check out this post : PHP exec() does not run all commands
As said in this post :
The problem is that you're running notify-send from a service. Notify-send is a desktop-oriented program which interacts with the display. But nginx runs without being attached to a display.
Imagine, for example, that there are 3 people logged on to the computer at the same time, all with different displays. When notify-send runs, it wouldn't know which display to send the notification to.