Running graphical application like wine on a headless server with xvfb

I needed to run a windows application using wine on linux on a headless server.

Here is the solution I have found. Running the application with a software named Xvfb. Xvfb is a virtual frame buffer so there is no need to have a screen attached to the server because it is all run virtually in memory.

Since all the action is running in memory, I use image magic to do a “screenshoot” of the virtual framebuffer. I then save the file on the file system where a web server can display it.

install xvfb and imagemagick

1
2
3
sudo apt-get install xvfb
sudo apt-get install imagemagick
sudo apt-get install apache2

Start xvfb

1
Xvfb :1 -screen 0 1280x960x24 &

Start the windows application with wine

1
DISPLAY=:1 wine terminal.exe &

Take a screen capture with the import tool of imagemagick

1
DISPLAY=:1 import -window root -quality 90 /var/www/html/screenshot.jpg