Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Apache & VNC - cannot open display: :2.0

Posted on 2008-10-23
4
Medium Priority
?
702 Views
Last Modified: 2012-06-21
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!

0
Comment
Question by:gr8gonzo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 23

Accepted Solution

by:
Mysidia earned 2000 total points
ID: 22793357
It may have access to the display,  but could be the case that the proper environment variables are not set,  for accessing the VNC desktop.

Normally, there are two environment variables you need set to access a display in common setups.. the first is the identity of the display.

The second is the path to the X user  'authorization'  file   that contains the secret cookie of the user's desktop.

In the shell you would type
export DISPLAY=:0
export XAUTHORITY=/home/user/.Xauthority


In other contexts, the variables need to be set before running the utility


In Apache httpd you can normally  use  mod_env
to change environment variables,  within a virtual host or  <Location>,
for example:

SetEnv DISPLAY :0
SetEnv XAUTHORITY /home/apache/.Xauthority



Or use


PassEnv DISPLAY
PassEnv XAUTHORITY


And set the environment variables accordingly   when starting  Apache httpd.
0
 
LVL 35

Author Comment

by:gr8gonzo
ID: 22813262
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.
0
 
LVL 35

Author Comment

by:gr8gonzo
ID: 23003445
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.
0
 
LVL 35

Author Closing Comment

by:gr8gonzo
ID: 31509422
Also read my followup
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question