How to install Xvfb (X11 Server) in Linux Server

Xvfb is a virtual frame buffer X11 server that can be installed on linux servers without a monitor and graphics card. It can be customized for multiple displays and screens as well. In this tutorial i will show how to install, setup and configure a display. I am installing the Xvfb (X11 server) on a Centos/ Redhat linux system.

Example:

If you want to capture a screen shot but you have only a linux server running and no graphics card or monitor. To get the output you have to dump the virtual display to a file and then convert to suitable jpg or png graphics with ImageMagick

To Install Xvfb

yum install Xvfb

To intialize the display

Xvfb :1 -screen 0 800x600x24&

This sets the display number 1 and screen 0 to 800×600 resolution with the color depth of 24.

If you get error like

Fatal server error:
Couldn't add screen 0

then most probably you have set the color depth to 32bit which never worked for me. You have to set to 16 bit or 24 bit color for the virtual buffer.

To export the display to X11

export DISPLAY=localhost:1.0

If you get errors like while running Xvfb then you install necessary fonts

Could not init font path element unix/:7100, removing from list!
FreeFontPath: FPE "built-ins" refcount is 2, should be 1; fixing.

yum install xorg-x11-fonts*

It should in most cases fix the problem!

To Run a program in the virtual display.


Use Xvfb. It gives you an X server to doesn't connect to a physical display.

So, on CentOS, you'd do something like yum install xorg-x11-server-Xvfb.

You can then start it up on display :1 with the command /usr/X11R6/bin/Xvfb :1 -screen 0 1024x768x24 &. This will create a screen 1027x768 depth 24 and put the command into the background.

So, the environmental variable you'd specify before launching Firefox would be export DISPLAY=:1, pointing to whatever host is appropriate.


DISPLAY=localhost:1.0 firefox


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值