从PHP命令行启动GUI程序,但Apache不 [英] PHP from commandline starts gui programs but apache doesn't

查看:201
本文介绍了从PHP命令行启动GUI程序,但Apache不的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我的人有类似问题阅读一些线程,但所有的答案没有超越出口显示器=:0.0和XAuth饼干。因此,这里是我的问题,在此先感谢您的时间!

First, I read some threads by people with similar problems but all answers didn't go beyond export DISPLAY=:0.0 and xauth cookies. So here is my problem and thanks in advance for your time!

我已经开发这使得使用OpenGL和GLSL货架小图书馆。
最近几天我把它包在一个PHP扩展,非常容易现在的工作。

I have developed a little library which renders shelves using OpenGL and GLSL. Last few days I wrapped it in a php extension and surprisingly easy it works now.

但问题是,当我使用命令行从延长执行PHP脚本它只能
$ PHP r100.php (我successfuly从HTTP用户运行此)。该脚本是在Apache的Web根目录,如果我从浏览器请求它,我得到 ** **关键。无法在apache的error_log中打开显示器

But the problem is it works only when I execute the php script using the extension from commandline $php r100.php(i successfuly run this from the http user). The script is in the webroot of apache and if I request it from the browser I get ** CRITICAL **: Unable to open display in apache's error_log.

因此​​,为了使事情更容易进行测试,并确保该问题不是在图书馆/扩展,此刻我只想用以下php脚本启动XMMS。
< PHP
回声了shell_exec(XMMS);
?>

它只是从shell过的作品。

So, to make things easier to test and to be sure that the problem is not in the library/extension, at the moment I just want to start xmms with following php script. <?php echo shell_exec("xmms"); ?> It works only from the shell too.

我和Apache的配置这么多,现在我真的不知道什么尝试播放。
我试图 $ xhost的+功放;&安培;出口显示器=:0.0

I've played with apache configuration so much now that I really dont know what to try. I tried $xhost + && export DISPLAY=:0.0

在http.conf中我有这些
SETENV DISPLAY:0.0 SETENV XAUTHORITY /home/OpenGL/.Xauthority

In the http.conf I have these SetEnv DISPLAY :0.0 SetEnv XAUTHORITY /home/OpenGL/.Xauthority

所以我的问题似乎是这样的:
我怎样才能让Apache执行PHP脚本与该HTTP用户拥有所有权限,包括环境?

So my problem seems to be this: How can I make apache execute php script with all privileges that the http user has, including the environment?

更多信息:
HTTP 的是视频和用户组,并有一个登录shell(bash)的。
我可以登录HTTP和没有问题,执行脚本,可以运行GUI程序这显示在显示0。
看来,Apache不提供对脚本适当的环境。
我读到CLI / CGI之间存在一些差异,但不能运行用php-cgi的xmms的太...

Additional information: HTTP is in video and users groups and has a login shell(bash). I can login as http and execute scripts with no problem and can run GUI programs which show up on display 0. It seems that apache does not provide the appropriate environment for the script. I read about some difference between CLI/CGI but cant run xmms with php-cgi too...

有关附加配置任何想法?

Any ideas for additional configuration?

问候

推荐答案

听起来有点危险,但基本上你可以添加甚至出口显示器=:0.0 apache和启动脚本(如Linux中/etc/init.d/httpd或Apache取决于发行)。
而xhost的+需要在连接到本地X服务器作为用户帐户运行,虽然我只知道它将如何为PHP脚本的工作不仅要在有生之年的Apache HTTP请求正在进行。

Sounds bit hazard, but basically you can add even export DISPLAY=:0.0 to apache start-up script (like in Linux /etc/init.d/httpd or apache depending distro). And "xhost +" need to be run on account which is connected to local X server as user, though I'm only wondering how it will work as php script should only live while apache http request is on-going.

编辑:
难道这是一种应用程序启动的?你可以用EXEC(nohub的/ usr / bin中/ PHP的运行script.php&安培;)此产卵; ..现在的Apache应该被释放和php应该继续在后台工作。

Is this is kind of application launcher?, you can spawn this with exec("nohub /usr/bin/php script.php &"); .. now apache should be released and php should continue working in background.

这篇关于从PHP命令行启动GUI程序,但Apache不的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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