如何从php网页执行程序?

编程入门 行业动态 更新时间:2024-10-27 09:33:15
本文介绍了如何从php网页执行程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在安装了某些程序的Linux机器上运行apache.我想从php页面调用该程序并获取输出.

I have apache running on a Linux machine where a certain program is installed. I want to call the program from a php page and get the output.

程序需要运行某些环境变量,例如LD_LIBRARY_PATH,带有库的路径以及其他变量.在不是 apache 用户的计算机上为用户 X 定义了环境.

The program needs certain environment variables to run, e.g. LD_LIBRARY_PATH with path to libraries plus extra variables. The environment is defined for a user X on the machine that is not the apache user.

到目前为止,我已经想到了以下选项(并不意味着它们都很聪明或安全):

So far I have thought of the following options (not meaning that they are all smart or safe):

  • 允许用户 apache 以用户 X 的身份运行程序(以允许拥有完整环境的方式).食谱 ?
  • 修改用户 apache 的环境.我不知道怎么回事,因为apache是​​ nologin 用户.
  • 以具有适当环境的用户身份SSH到另一台计算机.这意味着Web服务器与本机之间没有密码(公用/专用密钥)连接.危险吗 ?
  • Allow user apache to run the program as user X (in a way that allows having the full environment). Recipe ?
  • Modify the environment of user apache. I don't see how because apache is a nologin user.
  • SSH to another machine as a user that has the proper environment. It means to have a no password (public/private keys) connection between the web server and this machine. Is it dangerous ?
  • 问题

    • 我是否忽略了一个更简单或更佳的选择?
    • 您将使用什么选项?为什么?
    • Questions

      • Did I overlook a simpler or better option ?
      • What option would you use and why ?
      • 推荐答案

        您对此平台有完全控制权吗?

        Do you have full control over this platform?

        您可以查看 suexec 或 mpm-iTK

        您可以在虚拟主机中配置以上内容,并将运行身份作为用户或组设置为有权访问您的二进制文件的用户.

        You could configure the above within a virtual host, and set the run as user or group to that which has access to your binary.

        在当前设置中,您可以创建一个新组,将apache用户/组分配给所述组,将组应用于您要执行的具有读/写或读/执行权限的二进制文件,并让美好时光角色

        In your current setup, you could create a new group, assign the apache user/group to said group, apply group to the binary you want to execute with read/write or read/execute permissions, and let the good times role.

    更多推荐

    如何从php网页执行程序?

    本文发布于:2023-11-13 09:31:23,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1584014.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:网页   程序   php

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!