主要原理是利用xvfb提供的显卡帧缓冲区,让浏览器以为有桌面
Install xvfb in ubuntu:
sudo apt install xvfb
cat > /etc/init.d/xvfb <
XVFB=/usr/bin/Xvfb
XVFBARGS=":99 -screen 0 1024x768x24 -fbdir /var/run -ac"
PIDFILE=/var/run/xvfb.pid
case "$1" in
start)
echo -n "Starting Virtual X frame buffer: Xvfb"
start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $XVFB -- $XVFBARGS
echo "."
;;
stop)
echo -n "Stopping Virtual X frame buffer: Xvfb"
start-stop-daemon --stop --quiet --pidfile $PIDFILE
echo "."
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: /etc/init.d/xvfb {start|stop|restart}"
exit 1
esac
exit 0
EOF
chmod +x /etc/init.d/xvfb
export DISPLAY=:99.0
/etc/init.d/xvfb start
1.2. Install chrome in ubu