📅  最后修改于: 2023-12-03 15:08:06.377000             🧑  作者: Mango
在服务器上启动浏览器通常用于调试或测试网站或网络应用程序。本文将分享如何在Linux服务器上使用Xvfb和VNC Server启动Chrome浏览器。
在开始之前,需要安装Xvfb和VNC Server。
sudo apt-get update
sudo apt-get install xvfb
sudo apt-get install x11vnc
sudo apt-get install fluxbox
在终端窗口中,输入以下命令以启动Xvfb:
Xvfb :99 -screen 0 1024x768x16 &
然后,启动VNC Server:
x11vnc -noxrecord -noxfixes -noxdamage -display :99 -forever -bg -rfbport 5900 -rfbauth /root/.vnc/passwd
完成以上步骤后,可以使用以下命令在服务器上启动Chrome浏览器:
google-chrome --no-sandbox --user-data-dir --disable-gpu --remote-debugging-port=9222 --disable-translate --disable-extensions --mute-audio --window-size=1280,800 http://example.com
以上命令中,可以使用自己的网站或应用程序的URL替换http://example.com。
firefox -no-remote -new-instance -width 1280 -height 800 -url http://example.com
x11vnc -storepasswd
通过使用Xvfb和VNC Server在Linux服务器上启动Chrome或Firefox浏览器,可以方便地进行网站或网络应用程序的测试和调试。