PHP shell_exec,拒绝执行-rwxrwxrwx Shell脚本的权限 [英] PHP shell_exec, permission denied for executing -rwxrwxrwx shell script

查看:292
本文介绍了PHP shell_exec,拒绝执行-rwxrwxrwx Shell脚本的权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在运行Apache Web服务器的远程CentOS 5.6系统上通过ssh进行操作.我需要使用poppler pdftohtml二进制文件,不幸的是,该计算机当前未安装该文件.因此,我下载了poppler软件包并将其构建在我的用户文件夹下.由于我不是系统管理员,所以我没有

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

我的所有编译文件都在

/users/myfolder/poppler-0.18.2/

我需要通过php shell_exec()执行的文件是

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

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

如果我通过ssh bash执行它,则会得到正确的输出.如果是我,请将此行放在php脚本上:

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");

我得到以下输出:

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

我尝试将文件权限设置为777,当前为-rwxrwxrwx.我还注意到,使用shell_exec("whoami");会导致"apache".如果文件权限为-rwxrwxrwx,apache是​​否应该能够执行脚本?

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?

我还知道通过make install安装poppler可以解决问题,但是由于这是出于测试目的,因此我想避免在测试完成之前污染"个人文件夹之外的系统.

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!

推荐答案

仅仅因为文件对于用户而言是可执行的,并不意味着该用户实际上能够执行该文件.用户还必须能够进入"该文件:用户需要所有父目录"的执行权限,在您的情况下是/users、myfolder、poppler-0.18.2和utils.

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.

假设/users与/home是相同的基本内容,那么每个人都应该在其上加上+ x.在这里,您可以进行设置:只需执行chmod o+x /users/myfolder /users/myfolder/poppler-0.18.2 /users/myfolder/poppler-0.18.2/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

(注意:这将使每个人都可以执行此二进制文件,而不仅仅是Apache.)

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

如果apache用户和您共享一个组,最好使用chown poppler目录和该组拥有的所有内容,并设置g + x而不是o + x.

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.

这篇关于PHP shell_exec,拒绝执行-rwxrwxrwx Shell脚本的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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