php shell_Exec在shell中运行时无法正常工作 [英] php shell_Exec not working while the command works in shell

查看:98
本文介绍了php shell_Exec在shell中运行时无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须从php使用 imagemagick 转换命令。所以我使用的是 shell_exec ,但输出结果为空字符串。我知道命令转换不会在STDOUT上打印任何内容,但是也无法实现 convert 的所需输出。还 exec 不起作用。这些命令从shell或php命令行运行良好。可能是什么问题?

I have to use imagemagick convert command from php. So I'm using shell_exec but the output of that is null string. I know that the command convert doesn't print anyting on STDOUT but the desired output of convert is also not achieved. also exec doesn't work. these commands run fine from shell or from php command line. What can be the issue?

编辑 :添加2>& 1,我知道转换是抛出错误:缺少图像文件名 /a5d98168a524a331c5e06d60096debd63cbdce1f.jpg'@ error / convert.c / ConvertImageCommand / 2970。其中完整命令是转换/var/www/weblog/web/uploads/poster/a5d98168a524a331c5e06d60096debd63cbdce1f.png / var / www / weblog / web / uploads / poster / a5d98168a524a331c5e06d60096debd63cbdce1f.jpg`。

EDIT :adding the 2>&1, I learn that convert is throwing an error : missing an image filename/a5d98168a524a331c5e06d60096debd63cbdce1f.jpg' @ error/convert.c/ConvertImageCommand/2970.where the full command isconvert /var/www/weblog/web/uploads/poster/a5d98168a524a331c5e06d60096debd63cbdce1f.png /var/www/weblog/web/uploads/poster/a5d98168a524a331c5e06d60096debd63cbdce1f.jpg`.

推荐答案

Apache在linux中使用的用户名为www-data,你必须确保该用户有权使用使用您使用的文件和命令。您可以使用chmod更改文件权限,也可以使用chown将文件/目录所有者更改为www-data。

The user that Apache is using in linux is called www-data, you have to make sure that that user has permission to work with the files and commands you use. You can either use chmod to change the file permissions or chown to change the file/dir owners to www-data.

这篇关于php shell_Exec在shell中运行时无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆