Chrome 在Amazon Linux上安装Chromium

zfycwa2u  于 2022-12-30  发布在  Go
关注(0)|答案(4)|浏览(391)

我正试图在亚马逊Linux机器上安装Chrome(或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)

Yum安装特定RPM包

我尝试下载Chrome RPM,包括the latest stable version和特定版本,然后运行

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/下载二进制文件
运行它生成了错误消息
加载共享库时出错:文件库Xcursor.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库:
加载共享库时出错:资料库. so. 2:无法打开共享目标文件:无此文件或目录
yum没有找到libcups,看起来是因为它是一个32位的库。一些页面建议安装ia32-libs作为解决方案,但运行yum install ia32-libs显示它已经安装。
我无法越过那一点。

其他

  • 我也尝试了这里提到的步骤,但没有效果
  • 有些页面指出要使用dpkg,但是AmazonLinux上显然没有这个命令
  • apt两者都不是
bqjvbblv

bqjvbblv1#

这些答案都不起作用,也没有一个能真正解决亚马逊Linux的问题,
如果您使用EC2示例或任何其他运行Amazon Linux的服务器,要真正解决这个问题,您应该按照以下步骤操作。
1.通过运行以下命令,启用并安装适用于Enterprise Linux的额外软件包

sudo amazon-linux-extras install epel -y

1.后安装所有额外的软件包成功,安装chromium照常

sudo yum install -y chromium

一旦你这样做, chrome 将有所有需要的,如libatk* libgdk* 等...
您应该能够轻松启动Chromium
你在这里看到的遗漏的包,实际上并没有遗漏,它们是默认的,你只需要启用它们,这在AWS文档中有很好的记录。
https://aws.amazon.com/premiumsupport/knowledge-center/ec2-enable-epel/

blmhpbnm

blmhpbnm2#

为了让headless chrome在Lambda上运行,我部署了一个相同的AMI作为EC2示例(当前为amzn-ami-hvm-2017.03.1.20170812-x86_64-gp2)。
参考: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 应该能够运行,终于!!

2cmtqfgy

2cmtqfgy3#

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

#!/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
wqlqzqxt

wqlqzqxt4#

对于使用Amazon Linux 2022的用户,有几个软件包丢失,在Chromium目录中运行ldd chrome | grep not会产生:

libnss3.so => not found
    libnssutil3.so => not found
    libsmime3.so => not found
    libnspr4.so => not found
    libgbm.so.1 => not found

这些软件包不适用于Amazon Linux 2022 *,但 * 您可以在https://rhel.pkgs.org/8上找到它们,因为此发行版基于RHEL 8。
所以这些应该可以解决这个问题:

sudo dnf install http://repo.okay.com.mx/centos/8/x86_64/release/okay-release-1-1.noarch.rpm
sudo dnf install nss
sudo dnf install mesa-libgbm

相关问题