9

我正在尝试在 Amazon Linux 机器上安装 Chromium(或 Chrome,无论哪个)。

我尝试了很多步骤,但无济于事。这是我尝试过的:

简单的 Yum 安装

yum install epel       # worked
yum install chromium

生成的错误信息:

Error: Package: chromium-31.0.1650.63-2.el6.x86_64 (chromium-el6)
           Requires: libgnome-keyring.so.0()(64bit)
Error: Package: chromium-31.0.1650.63-2.el6.x86_64 (chromium-el6)
           Requires: libgtk-x11-2.0.so.0()(64bit)
Error: Package: chromium-31.0.1650.63-2.el6.x86_64 (chromium-el6)
           Requires: libgdk_pixbuf-2.0.so.0()(64bit)
Error: Package: chromium-31.0.1650.63-2.el6.x86_64 (chromium-el6)
           Requires: libXss.so.1()(64bit)
Error: Package: chromium-31.0.1650.63-2.el6.x86_64 (chromium-el6)
           Requires: libgdk-x11-2.0.so.0()(64bit)
Error: Package: chromium-31.0.1650.63-2.el6.x86_64 (chromium-el6)
           Requires: libcanberra-gtk2(x86-64)
Error: Package: chromium-31.0.1650.63-2.el6.x86_64 (chromium-el6)
           Requires: libatk-1.0.so.0()(64bit)

特定 RPM 包的 Yum 安装

我尝试下载 Chrome RPM,包括最新的稳定版本和特定版本,然后运行

yum install google-chrome-stable-64.0.3282.119-1.x86_64.rpm

它产生了相同的错误消息

手动程序

从https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Linux_x64/532015/下载的二进制文件

运行它会生成错误消息

加载共享库时出错:libXcursor.so.1:无法打开共享对象文件:没有这样的文件或目录

我跑了

yum install libXcursor
yum install libXfixes     # because chrome was then complaining about that library
yum install libXdamage    # and subsequently that one

这一切都奏效了。

然而,随后 Chrome 开始抱怨libcups图书馆:

加载共享库时出错:libcups.so.2:无法打开共享对象文件:没有这样的文件或目录

libcupsyum 没找到,看来这是因为它是 32 位库。某些页面建议安装ia32-libs为解决方案,但运行yum install ia32-libs显示它已经安装。

我无法超越那个点。

其他

  • 我也尝试了这里提到的步骤,但没有奏效
  • 一些页面指向 using dpkg,但亚马逊 Linux 上显然不存在该命令
  • apt两者都不
4

3 回答 3

19

这些答案都没有,工作,也没有一个真正解决亚马逊Linux的问题,

如果您使用 EC2 实例或运行 Amazon linux 的任何其他服务器,要真正解决问题,您应该按照以下步骤操作。

  1. 通过运行命令为 Enterprise Linux 启用和安装 Extra Packages

    sudo amazon-linux-extras install epel -y
    
  2. 成功安装所有额外的软件包后,照常安装 chromimum

    sudo yum install -y chromium
    

一旦你这样做了,Chromium 将拥有所有必需的内容,例如 libatk* libgdk* 等......

您应该能够轻松启动 Chromium

您在此处查看的错过的软件包实际上并没有错过,它们是一种默认设置,您只需启用它们,这在 AWS 文档中有详细记录。

https://aws.amazon.com/premiumsupport/knowledge-center/ec2-enable-epel/

于 2021-01-22T04:53:43.410 回答
6

为了让 headless chrome 在 Lambda 上运行,我部署了一个相同的 AMI 作为 EC2 实例(当前为 amzn-ami-hvm-2017.03.1.20170812-x86_64-gp2)。安装 chrome 后,通常会出现一系列缺少依赖项的情况。

参考:https ://medium.com/mockingbot/run-puppeteer-chrome-headless-on-ec2-amazon-linux-ami-6c9c6a17bee6

导航到包含 chrome 可执行文件的文件夹并使用 ldd 检查缺少的依赖项:

$ ldd chrome | grep not
libpangocairo-1.0.so.0 => not found
libpango-1.0.so.0 => not found
libcairo.so.2 => not found
libXcursor.so.1 => not found
libXdamage.so.1 => not found
libXfixes.so.3 => not found
libcups.so.2 => not found
libXss.so.1 => not found
libXrandr.so.2 => not found
libgconf-2.so.4 => not found
libatk-1.0.so.0 => not found
libgtk-3.so.0 => not found
libgdk-3.so.0 => not found
libgdk_pixbuf-2.0.so.0 => not found

安装以下内容:

$ sudo yum install cups-libs dbus-glib libXrandr libXcursor libXinerama cairo cairo-gobject pango

再检查一遍:

$ ldd chrome | grep not
libXss.so.1 => not found
libgconf-2.so.4 => not found
libatk-1.0.so.0 => not found
libgtk-3.so.0 => not found
libgdk-3.so.0 => not found
libgdk_pixbuf-2.0.so.0 => not found

我们需要从一大堆 RPM 中获取这些依赖项:

# Install ATK from CentOS 7
$ sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/atk-2.22.0-3.el7.x86_64.rpm
$ sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/at-spi2-atk-2.22.0-2.el7.x86_64.rpm
$ sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/at-spi2-core-2.22.0-1.el7.x86_64.rpm
# Install GTK from fedora 20
$ sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/g/GConf2-3.2.6-7.fc20.x86_64.rpm
$ sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/l/libXScrnSaver-1.2.2-6.fc20.x86_64.rpm
$ sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/l/libxkbcommon-0.3.1-1.fc20.x86_64.rpm
$ sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/l/libwayland-client-1.2.0-3.fc20.x86_64.rpm
$ sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/l/libwayland-cursor-1.2.0-3.fc20.x86_64.rpm
$ sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/g/gtk3-3.10.4-1.fc20.x86_64.rpm
# Install Gdk-Pixbuf from fedora 16
$ sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/16/Fedora/x86_64/os/Packages/gdk-pixbuf2-2.24.0-1.fc16.x86_64.rpm

这应该解决所有依赖项,并且 chrome 应该能够运行,最后!!

于 2018-04-05T18:19:27.077 回答
1

我通过 CodeBuild 启动的 AWS Ubuntu 使用 chromium 进行无头测试。我发现我必须更新节点并安装一组铬依赖项。

#!/bin/sh
echo "Installing nodejs (which will include node and npm)"
echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
curl -sL https://deb.nodesource.com/setup_10.x | bash -
apt-get install -y nodejs  
echo "Installing chromium dependencies"
apt-get install -yq gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \
libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 \
libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 \
libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 \
ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
于 2018-11-11T14:38:12.100 回答