启动从本地运行的Apache Web服务器使用PHP的X应用程序 [英] Launching an X application from a locally running Apache web server using PHP

查看:92
本文介绍了启动从本地运行的Apache Web服务器使用PHP的X应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Apache和PHP我的本地Linux桌面上运行。我的PHP脚本启动xcalc,看起来是这样的:

I have Apache and PHP running on my local Linux desktop. My PHP script launches "xcalc", and looks like this:

<?php
    shell_exec("xcalc");
?>

当我使用PHP的二进制执行PHP脚本,我看到xcalc在桌面上运行。当我通过Apache执行相同的脚本,我什么也看不到发生在屏幕上。我想不通的地方失败。

When I execute the PHP script using the PHP binary, I see xcalc running on the desktop. When I execute the same script through Apache, I see nothing happening on the screen. I can't figure out where it fails.

我改变了Apache的用户和组,以一个普通用户,只是为了确保所有的X设置是否正确。

I changed Apache's User and Group to a regular user, just to make sure that all X settings are correct.

推荐答案

xcalc需要是 -display 选项或显示环境变量设置为知道要显示哪个X服务器。当您从shell中运行它,它可能拿起 $ DISPLAY 从你的shell环境,但Apache Web服务器通常不会有
集。

xcalc needs either a -display option or the DISPLAY environment variable set to know which X server to display on. When you run it from the shell, it's probably picking up $DISPLAY from your shell environment, but the Apache web server normally won't have that set.

您也可以运行成X个身份验证问题,如果X会话没有被相同用户作为Apache Web服务器上运行,因为X通常依赖于共享密钥(在&ldquo;魔法饼干&rdquo;的)存储在谁登录到X会话的用户的 $ HOME /文件.Xauthority 文件。

You may also run into X authentication issues, if the X session isn't being run by the same user as the Apache web server, since X normally relies on a shared secret (the “magic cookie”) stored in the $HOME/.xauthority file of the user who logged into the X session.

这篇关于启动从本地运行的Apache Web服务器使用PHP的X应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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