简体   繁体   English

在Linux Apache上使PHP运行python脚本的权利

[英]Rights on linux apache to make php run a python script

So, there has been a lot of question to this topic and I read a lot in the last few days. 因此,对该主题有很多疑问,最近几天我读了很多东西。

Running the php script that executes the python script from command line is fine - all works (whoami customername). 从命令行运行执行python脚本的php脚本就可以了-一切正常(whoami customername)。 Running php script in browser does not work (whoami www-data). 在浏览器中运行php脚本不起作用(whoami www-data)。 No matter who owns both scripts, no matter what php I use to run the script (exec, system ...), php.ini checked, nothing disabled that would interfere. 无论谁同时拥有两个脚本,无论我使用哪个php运行脚本(exec,system ...),检查php.ini,都不会禁用任何会干扰的脚本。 If I move the php script to the very root, it seems willing to exec the python script, but fails to find SSH folder that I need to do things with python script. 如果我将php脚本移到最根本的位置,似乎愿意执行python脚本,但是找不到需要使用python脚本执行操作的SSH文件夹。

I gather the problem is rights. 我收集的问题是权利。 I can run the python script from command line. 我可以从命令行运行python脚本。 I can run the php script from command line. 我可以从命令行运行php脚本。 Both do the stuff it should (SSH to git server and do some things) 两者都做应有的工作(SSH到git服务器并做一些事情)

Its a customer server so I am limited to the things I am able to do. 它是一个客户服务器,所以我只能做我能做的事情。 Would be nice to have a button in browser to make thing happen instead of sending customer to command line. 最好在浏览器中有一个按钮来使事情发生,而不是将客户发送到命令行。

Before I finally giving up, anyone ever had the same scenario and has found a solution? 在我最终放弃之前,有人遇到过相同的情况并找到了解决方案吗?

I think you want to run shell command using php. 我认为您想使用php运行shell命令。 Try this might be this helping you http://php.net/manual/en/function.shell-exec.php 试试这个可能会对您有所帮助http://php.net/manual/zh/function.shell-exec.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM