Link to home
Start Free TrialLog in
Avatar of gr8gonzo
gr8gonzoFlag for United States of America

asked on

Apache & VNC - cannot open display: :2.0

I have a CentOS 5 server running Apache and vncserver. I also have a 3rd-party utility that works with vncserver to take a screenshot of the current desktop / display. We rebooted the server recently and everything came up just fine but when Apache tries to run the 3rd-party utility to take the screenshot, the utility says it "cannot open display: :2.0"

If I SSH into the server and run the utility directly on the command line as root, the utility works perfectly. Apache has all the correct permissions to execute the utility. I've restarted vncserver but that doesn't change anything. I think it's just some issue of Apache having access to the display, but I'm not sure where to go from there. Any help would be appreciated. Thank you!

ASKER CERTIFIED SOLUTION
Avatar of Mysidia
Mysidia
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gr8gonzo

ASKER

That might be it. After trying a few other things, I restarted Apache and it came right up. The environment variables might make sense, since I restarted it from the shell, while it initially started up as a standard service, so it wouldn't have inherited any of my environment.

I will try to break it again and then set those environment variables in Apache and see if that does the trick.
So it looks like that wasn't a complete solution but what I -WAS- able to do was to enable access for localhost and 127.0.0.1 (the quick fix was to just enable all hosts) using xhost. After defining the DISPLAY environment variable, type:

xhost +

...to disable the control access. If that works for you (reader), then put back control access and then use xhost to add only the IP addresses/hosts that are being blocked. The changes are temporary until the next reboot, but you can save a file into /etc/ to save those settings. Read the xhost man page for details.
Also read my followup