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
sudo apt-get install xvfb
sudo apt-get install imagemagick
sudo apt-get install apache2
Xvfb :1 -screen 0 1280x960x24 &
Start the windows application with wine
DISPLAY=:1 wine terminal.exe &
Take a screen capture with the import tool of imagemagick
DISPLAY=:1 import -window root -quality 90 /var/www/html/screenshot.jpg