ciumes has asked for the wisdom of the Perl Monks concerning the following question:

I have one linux box (box1) which provides the X server.
On another linux box (box2), I have my perl scripts to debug.
On box1, I can do "ssh -X box2" and the DISPLAY variable is set to "localhost:10.0" and if I run my perl script manually (perl -d:ptkdb dbs.pl), the ptkdb window comes up on box1. I can click RUN and all goes well.
The perl code for dbs.pl is
#!/usr/bin/perl print "Hello World\n";
Now, when I want to run a CGI program, things don't go so well: The code is just as simple for dbs.cgi:
#!/usr/bin/perl -d:ptkdb use CGI (':standard'); print header; print start_html; print "Hello"; print end_html;
The problem now is that I get the message:
couldn't connect to display ":0" at /perl_modules/lib/site_perl/5.12.0/s390x-linux/Tk/MainWindow.pm line 55.

Doing ssh -X sets the DISPLAY variable for me, but the web server does not know what to do. I tried adding a line like
$ENV{DISPLAY} = "localhost:0.0";
But that didn't work. I have also used xhost to try and set things up, but to no avail. If I don't invoke with -d:ptkdb, then the cgi script properly displays "Hello" on the browser screen.
So, what other steps might I try, so that my cgi scripts can connect to the X server display? I guess the problem is that apache doesn't know how to redirect the X11 output to the host running my browser.

Replies are listed 'Best First'.
Re: ptkdb cannot connect to DISPLAY
by zentara (Cardinal) on Apr 15, 2011 at 17:35 UTC
Re: ptkdb cannot connect to DISPLAY
by Anonymous Monk on Nov 11, 2011 at 09:30 UTC
    Try adding
    SetEnv PTKDB_DISPLAY <box1-IP>:0.0
    to your "/etc/apache2/vhosts/*.conf". This worked for me, using a windows host with xming.