📜  在跳转服务器上启动浏览器 (1)

📅  最后修改于: 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和VNC Server

在终端窗口中,输入以下命令以启动Xvfb:

Xvfb :99 -screen 0 1024x768x16 &

然后,启动VNC Server:

x11vnc -noxrecord -noxfixes -noxdamage -display :99 -forever -bg -rfbport 5900 -rfbauth /root/.vnc/passwd
启动Chrome浏览器

完成以上步骤后,可以使用以下命令在服务器上启动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。

额外提示
  1. 如果需要使用Firefox浏览器,请用以下命令启动:
firefox -no-remote -new-instance -width 1280 -height 800 -url http://example.com
  1. 在使用VNC Viewer连接服务器时,需要输入密码以连接。第一次使用VNC Server时,默认密码为空,需要设置密码。请使用以下命令:
x11vnc -storepasswd
结论

通过使用Xvfb和VNC Server在Linux服务器上启动Chrome或Firefox浏览器,可以方便地进行网站或网络应用程序的测试和调试。