简体   繁体   English

PHP exec适用于apache2但不适用于nginx

[英]PHP exec works on apache2 but not on nginx

I'm trying to launch unoconv using exec in php. 我正在尝试在php中使用exec启动unoconv。 It works with apache2, but not with nginx. 它适用于apache2,但不适用于nginx。 I've already checked my php.ini and disable_functions not contain exec in both apache2 and nginx php.ini files. 我已经检查过我的php.ini和disable_functions在apache2和nginx php.ini文件中均不包含exec。

I'm not familiar with unconv, but I've had a similar problem with porting my server from Apache to nginx and exec . 我不熟悉unconv,但是在将服务器从Apache移植到nginxexec遇到了类似的问题。

nginx + php-fpm have a bare minimal $PATH set compared to apache , and it's likely your unoconv is not on that path. apache相比, nginx + php-fpm几乎没有设置$PATH ,并且您的unoconv可能不在该路径上。

You could try modifying your PATH settings, but a better way would be to specify the absolute path of unoconv 您可以尝试修改PATH设置,但是更好的方法是指定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 您还应该将错误输出重定向到stdout,这样您才能确切地知道为什么unoconv无法启动

exec("/path/to/unoconv -param0 -param1 2>&1", $output);
print_r($output); //this should give failure reason

Check out this post : PHP exec() does not run all commands 看看这篇文章: PHP exec()不会运行所有命令

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. 但是Nginx无需附加到显示器即可运行。

Imagine, for example, that there are 3 people logged on to the computer at the same time, all with different displays. 例如,想象一下,有3个人同时登录到计算机,并且所有人的显示屏都不同。 When notify-send runs, it wouldn't know which display to send the notification to. 当notify-send运行时,它不知道将通知发送到哪个显示器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM