Launching an X application from a locally running Apache web server using PHP

半世苍凉 提交于 2019-12-02 02:39:56

问题


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

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

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.

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


回答1:


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.

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.



来源:https://stackoverflow.com/questions/2357886/launching-an-x-application-from-a-locally-running-apache-web-server-using-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!