"QXcbConnection: Could not connect to display:1" when running xvfb CuteCapt from PHP

Asked 2 years ago, Updated 2 years ago, 67 views

Thank you for your help.
I'm a new server user who recently started using Linux.


Capturing web pages (specifying URLs, rendering, and saving images) is a trial and error process. You can even install "CuteCapt" and its association in CentOS 6 to run on SSH.

The command succeeds with the following

xvfb-run --auto-servernum --server-num=1CuteCapt --url=https://www.google.co.jp/ --out=/var/www/html/capture/Google.jpg

You would like to run this command from PHP.
(I have quite a history of PHP, but I have no experience of hitting commands outside, so I'm trying to guess...)

$res=exec(escapeshellcmd('xvfb-run --auto-servernum --server-num=1CuteCapt --url=https://www.google.co.jp/ --out=/var/www/html/capture/Google.jpg'));

I just put it in and found out that $res is

QXcbConnection:Could not connect to display:1

contains and no images are generated.

I understand that there is a moss around the connection to the virtual display.

I don't understand why a successful SSH command fails when I run it in PHP. I don't know what to try next, so I'm on the rocks.

It may be a rudimentary misunderstanding or mistake, but
Thank you for your advice

php linux centos

2022-09-30 19:21

1 Answers

I haven't verified it yet, but do you have a virtual display for xvfb?

Xvfb:90-ac-screen0 1024x768x24>/dev/null2>&1&

Run

DISPLAY=:90CuteCapt --url=https://www.google.co.jp/ --out=/var/www/html/capture/google.jpg

I'm sorry to be Selenium, but I think my article will be helpful.

http://qiita.com/m3m0r7/items/355e8bbe77acbbd359d2#%E3%81%93%E3%81%93%E3%81%8B%E3%82%89%E3%81%8C%E6%A5%BD%E3%81%97%E3%81%84selenium%E3%81%A7%E3%82%B9%E3%82%AF%E3%82%B7%E3%83%A7%E3%82%92%E5%8F%96%E3%82%8B


2022-09-30 19:21

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.