Alibaba Cloud Linux 3.2104 LTS 64位安装浏览器?

云计算

Alibaba Cloud Linux 3.2104 LTS 64位 系统上安装浏览器,通常用于服务器环境,默认是不带图形界面(GUI)的,因此无法直接运行图形化浏览器(如 Chrome、Firefox)。但根据你的使用场景,有以下几种解决方案:


✅ 场景一:你需要在服务器上使用浏览器(无图形界面)

适用于:爬虫、自动化测试、Headless 浏览等。

推荐安装:Google Chrome HeadlessFirefox Headless

安装 Google Chrome(Headless 模式)
  1. 添加 YUM 源:
sudo tee /etc/yum.repos.d/google-chrome.repo <<EOF
[google-chrome]
name=google-chrome
baseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64
enabled=1
gpgcheck=1
gpgkey=https://dl.google.com/linux/linux_signing_key.pub
EOF
  1. 安装 Chrome:
sudo yum install -y google-chrome-stable
  1. 验证是否可以运行 Headless 模式:
google-chrome --headless --disable-gpu --dump-dom https://www.aliyun.com

这种方式适合做网页抓取、截图、自动化测试等。


✅ 场景二:你需要图形界面并运行完整浏览器(如 Firefox、Chrome 图形界面)

步骤 1:安装图形界面(X Window + GNOME)

sudo yum groupinstall -y "Server with GUI"

步骤 2:设置默认启动图形界面

sudo systemctl set-default graphical
sudo systemctl reboot

重启后系统将进入图形界面(如果你通过 VNC 或远程桌面连接)。

步骤 3:安装图形浏览器

安装 Firefox(推荐,系统自带):
sudo yum install -y firefox

启动:

firefox
安装 Chrome(图形界面版):
sudo yum install -y google-chrome-stable

启动:

google-chrome

⚠️ 注意:你需要通过 VNC、RDP 或远程桌面 连接到服务器才能看到图形界面。直接通过 SSH 是看不到的。


✅ 场景三:通过命令行浏览网页(轻量级文本浏览器)

如果你只是想查看网页内容,不需要图形界面,可以使用文本浏览器:

# 安装 w3m(支持基本 HTML 和表格)
sudo yum install -y w3m

# 使用示例
w3m https://www.aliyun.com

其他选择:lynx, elinks


🛠️ 常见问题解决

  • 缺少字体或依赖?

    sudo yum install -y liberation-fonts glibc-common
  • Chrome 启动报错?
    使用 --no-sandbox --headless --disable-gpu 参数运行:

    google-chrome --no-sandbox --headless --disable-gpu --screenshot https://example.com

✅ 总结:根据用途选择方案

目的 推荐方案
自动化测试、爬虫 google-chrome --headless
图形化操作浏览器 安装 GNOME + Firefox/Chrome + VNC
快速查看网页内容 w3mlynx 文本浏览器

如果你告诉我你的具体用途(比如:测试网页、部署爬虫、远程管理等),我可以给出更精准的建议。

未经允许不得转载:CLOUD云枢 » Alibaba Cloud Linux 3.2104 LTS 64位安装浏览器?