php中的权限被拒绝错误 [英] Permission denied error in php

查看:147
本文介绍了php中的权限被拒绝错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在路径/root/.cabal/bin/pandoc中有pandoc包。由于根路径,我无法通过php中的shell_exec()执行pandoc包。如何解决??? div class =h2_lin>解决方案

你要做的是从安全的角度来看极其危险。请记住这一点。



也就是说,你有两个选择:



1.更改您的网站的PHP用户的权限,以便能够执行shell命令。 这是一个糟糕的想法,你不应该这样做,因为它非常危险,并允许任何Web访问者在你的服务器上执行命令。



2.通过sudo运行命令,并将您的PHP用户添加为pandoc命令的已接受sudo用户。

  echo  shell_exec('  sudo -u ThePHPUserOnYourBox -S /root/.cabal/bin/pandoc' 





你不应该这样做,因为它非常危险。它比第一个选项更安全但它仍然非常不安全。



另一种选择是建立某种代理服务,将你的pandoc请求提交给工作服务器,进行所需的转换,将转换后的文档发送到其他地方,并通知Web服务器工作完成。



换句话说,pandoc需要完全脱离网络服务器,完全在另一台服务器上。它需要从Web服务器接收作业,独立于Web服务器处理它们,并将完成的文档发送回Web服务器。


I have pandoc package in the path /root/.cabal/bin/pandoc. I couldn't to execute pandoc package through shell_exec() in php because of the root path.How to solve it??

解决方案

What you are trying to do is extremely dangerous from a security standpoint. Just keep that in mind.

That said, you have two options:

1. Change the permissions of your website's PHP user to be able to execute shell commands. This is a terrible idea and you shouldn't do it because it is very dangerous and will allow any Web visitor to execute commands on your server.

2. Run the command via sudo, and add your PHP user as an accepted sudo user for the pandoc command.

echo shell_exec('sudo -u ThePHPUserOnYourBox -S /root/.cabal/bin/pandoc')



You should not do this because it is very dangerous. It's more secure than the first option but it's still wildly insecure.

Another option is to build some sort of proxy service that submits your pandoc requests to a worker server, does the conversion you want, sends that converted document someplace else, and notifies the web server that the work is complete.

In other words, pandoc needs to be completely off the webserver, on another server entirely. It needs to receive jobs from the webserver, process them independent of the webserver, and send the completed documents back to the webserver.


这篇关于php中的权限被拒绝错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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