duan0714 2011-12-29 13:07
浏览 86
已采纳

PHP shell_exec,执行-rwxrwxrwx shell脚本的权限被拒绝

I am currently over ssh on a remote CentOS 5.6 system which runs an Apache webserver. I need to use the poppler pdftohtml binary which, unfortunately, is not currently installed on that machine. So I downloaded the poppler package and built it under my user folder. Since I I am not the system admin, I didn't do

make install

and I have all my compiled files under

/users/myfolder/poppler-0.18.2/

The file that I need to execute through php shell_exec() is

/users/myfolder/poppler-0.18.2/utils/pdftohtml

If I execute it through my ssh bash, I get the correct output. If I, instead, put this line on a php script:

echo shell_exec("/users/myfolder/poppler-0.18.2/utils/pdftohtml");

I get the following output:

sh: /users/myfolder/poppler-0.18.2/utils/pdftohtml: Permission denied

I tried setting to 777 the file permissions, which currently are -rwxrwxrwx. I also noticed that using shell_exec("whoami"); results in "apache". Shouldn't apache be able to execute the script if the file permissions are -rwxrwxrwx?

I also know that installing poppler through make install would solve the problem but since this is for testing purpose, I would like to avoid "contaminating" the system outside my personal folder until the testing is complete.

Thanks to anyone who will help!

  • 写回答

1条回答 默认 最新

  • duannai1883 2011-12-29 13:50
    关注

    Just because a file is executable for a user does not mean that user is actually able to execute the file. The user needs to also be able to 'get to' the file: The user needs execution permission for all 'parent directories', in your case for /users, myfolder, poppler-0.18.2 and utils.

    Assuming /users is the same basic thing as /home, everybody should have +x on that. From there, you can set it: simply do chmod o+x /users/myfolder /users/myfolder/poppler-0.18.2 /users/myfolder/poppler-0.18.2/utils

    (Note: This will make it possible for everybody to execute this binary, not just Apache.)

    If the apache user and you share a group, it would be better to use chown the poppler directory and everything in to be owned by that group, and set g+x instead of o+x.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000
  • ¥30 ppOCRLabel导出识别结果失败