php shell_Exec not working while the command works in shell

天大地大妈咪最大 提交于 2020-01-05 12:34:33

问题


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?

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`.


回答1:


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.



来源:https://stackoverflow.com/questions/8808413/php-shell-exec-not-working-while-the-command-works-in-shell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!