> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/di-14-zhang-duo-mei-ti-he-wai-bu-she-bei/di-14.9-jie-web-liu-lan-qi.md).

# 14.9 Web 浏览器

本节介绍如何在 FreeBSD 系统上安装和配置一些主流的 Web 浏览器。

## Firefox

Firefox 是一款开源浏览器，具有符合标准的 HTML 渲染引擎、标签页浏览、弹出式窗口拦截、扩展功能、增强的安全性等特点。Firefox 基于 Mozilla 代码库。

### 安装最新版本的 Firefox

* 使用 pkg 安装：

```sh
# pkg install firefox
```

* 或者使用 Ports：

```sh
# cd /usr/ports/www/firefox/
# make install clean
```

![火狐浏览器](/files/kvZfevRqqWiSMpdSKExf)

### 安装 Firefox 扩展支持版本 (ESR)

* 使用 pkg 安装：

```sh
# pkg install firefox-esr
```

* 或者使用 Ports：

```sh
# cd /usr/ports/www/firefox-esr/
# make install clean
```

## Chromium

Chromium 是一个开源浏览器项目，旨在提供更安全、更快速、更稳定的 web 浏览体验。Chromium 具有标签页浏览、弹出式窗口拦截、扩展支持等功能。Chromium 是 Google Chrome 浏览器的开源基石。

Chromium 不同于 Chrome，但是在 FreeBSD 中 Chromium 的启动命令为 `chrome`。

* 使用 pkg 安装 Chromium

```sh
# pkg install chromium
```

* 或者使用 Ports 安装 Chromium

```sh
# cd /usr/ports/www/chromium/
# make install clean
```

> **警告**
>
> 要编译 Chromium，需要至少 8 GB 内存（Release 构建），或等量的交换分区与内存之和。如果启用 LTO 优化则需要 16 GB，如果启用 Debug 构建则需要 32 GB。Chromium 仅支持 amd64 和 aarch64 架构。

## ungoogled-chromium

Chromium 仍保留了对 Google 网络服务和二进制文件的依赖，因此 ungoogled-chromium 项目在此基础上移除了所有与 Google 相关的组件，包括后台请求、域名追踪和预编译二进制文件等。

* 使用 pkg 安装 ungoogled-chromium

```sh
# pkg install ungoogled-chromium
```

* 或者使用 Ports 安装 ungoogled-chromium

```sh
# cd /usr/ports/www/ungoogled-chromium/
# make install clean
```

## Chrome（Linux 兼容层）

Chrome（Linux 兼容层）基于 FreeBSD 的 Linuxulator 运行，需先启用 Linux 二进制兼容层。

* 使用 pkg 安装 Chrome

```sh
# pkg install linux-chrome
```

* 或者使用 Ports 安装 Chrome

```sh
# cd /usr/ports/www/linux-chrome/
# make install clean
```

## 附录：让 Chromium 使用 Google 账号同步

作为开源项目，Chromium 与 Google Chrome 的关系类似于 AOSP 与 Pixel UI 的关系。Chromium 无法直接从 Google Chrome 的在线插件商店下载安装插件，只能手动从本地安装 crx（同步启用后可自动同步浏览器插件）。Chromium 也不自带 Google 翻译插件等功能。更多差异可参见：The Chromium Project. Chromium Browser vs Google Chrome\[EB/OL]. \[2026-03-26]. <https://chromium.googlesource.com/chromium/src/+/main/docs/chromium_browser_vs_google_chrome.md>. 该文档比较了 Chromium 与 Google Chrome 在功能和授权上的差异。

`Chromium` 并非 `Google Chrome`，前者是 The Chromium Project 发布的开源与自由软件，其顶层许可证为 [BSD 3-Clause “New” or “Revised” License](https://github.com/chromium/chromium/blob/main/LICENSE)，同时包含 LGPL 2.1 及 MPL 1.1 等许可的代码；后者是 Google LLC 的专有软件。

在 [Chromium 89](https://archlinux.org/news/chromium-losing-sync-support-in-early-march/) 版本发布前后，Google 限制了对私有同步 API 的访问，各发行版因此移除了之前打包时自带的与 Chrome 相同的默认 API 密钥。该公告说明了此变更的原因与影响。

在开始获取 token 之前，需要先加入以下两个 Google 邮件列表：

* [Google browser sign-in test account](https://groups.google.com/u/0/a/chromium.org/g/google-browser-signin-testaccounts)
* [Chromium-dev](https://groups.google.com/a/chromium.org/g/chromium-dev)

![加入邮件列表](/files/LPfmxDMADZzBdbQNTP0H)

由于仅需 Chrome Google API 的访问权限，必须关闭这两个邮件列表的消息通知（即“不接收电子邮件”），否则将收到大量邮件通知。

![关闭邮件通知](/files/yDOAPXRylBpUKiVgEjMM)

![邮件列表设置](/files/6SofH0p4WapxSL2VgfOT)

加入 Google browser sign-in test account 群组后，会看到“您无权访问此内容”等提示，此属正常现象，无需担心。

![join-mail-list-for-google-api-error2](/files/UQgGSFgbBmS4mRd76Zd0)

在浏览器中打开 [谷歌云控制台网站](https://console.cloud.google.com/)。

> **注意**
>
> 登录控制台时使用的谷歌账户必须与之前加入邮件列表的账户一致。

![谷歌云控制台首页](/files/JiaJ9CqEcW9uGSpCPPpR)

点击左上角的“My First Project”，随后在弹出窗口的右上角选择“新建项目”即可。

![新建项目选项](/files/SqVGHn2mcbofaQggK9Sz)

项目名称可自行填写，组织保持默认设置。

![填写项目信息](/files/7FdP00XG7XQVgiVJRIg5)

点击左上角的“My First Project”，随后在弹出窗口中选择刚才创建的项目（此处为 google-sync）。

![选择项目](/files/c1sSieQeUIWCtvhkJXA5)

点击上图中的“API 和服务”，再点击“+ 启用 API 和服务”

![启用 API 和服务](/files/Sfy7AiEEoIPytXmDenIG)

搜索“chrome-sync”找到下列内容。

![搜索 Chrome Sync](/files/Ys48wjPnnqjdsv2JdZ1e)

点击启用“Chrome Sync API”

![启用 Chrome Sync API](/files/PxIGJ93f2cKJ6rdHLotP)

之后会在已启用的 API 和服务列表中显示下列状态

![已启用 API 列表](/files/YvjM2DRgC3JzfetfBXTb)

选择“OAuth 权限请求页面”：

![OAuth 权限页面](/files/Hy7HDWteDkSaIKBGSJXb)

创建外部应用：

![创建外部应用](/files/QbcdZaWKl7knrvjpt5HU)

![填写应用信息](/files/2yvfraBjvLdgrocDUqDi)

![应用信息填写](/files/v6VNNlFMUmYi3B6d90RG)

![应用详细信息](/files/oOQ3xQhqcpkmFDmc5onC)

创建后如图：

![应用创建完成](/files/zR3aoe4WpZF8M5d1M3o0)

点击“客户端”，创建 OAuth 客户端 ID，应用类型为“桌面应用”：

![创建 OAuth 客户端](/files/Ozi3MSiHiHQayCW57223)

创建后如图：

![OAuth 客户端创建](/files/75J4GSJKXWBzQSuAExcC)

点击创建的“桌面客户端 1”

![查看客户端详情](/files/K6DwStVlgzIlrBEawNyE)

获取以下凭据（此为示例，必须自行生成）：

* 客户端 ID `502882456359-okloi0a7k6vjodss69so97tmqmv0jjj5.apps.googleusercontent.com`
* 客户端密钥 `GoCSPX-iKHEKZmP4w_zdq0Z8nwOqz6SF2_M`

返回“API 和服务”，点击“+ 创建凭据”，再点击“API 密钥”。

![创建 API 密钥](/files/3a40VM3pWoz4MKFNQPMw)

即可获得一个 API 密钥（此为示例，读者必须自行生成）：`AIzaSyDVpYvJQUn9HTjAiD89y3xBDOG3oaxV5_E`

![API 密钥生成](/files/8m2ShbDxJAZ1oCc8qXW8)

打开凭据概览：

![凭据概览](/files/txzZug1kurIOkLTVZI85)

编辑 **\~/.profile** 文件，加入：

```sh
export GOOGLE_API_KEY=AIzaSyDVpYvJQUn9HTjAiD89y3xBDOG3oaxV5_E  # 填写 API 密钥
export GOOGLE_DEFAULT_CLIENT_ID=502882456359-okloi0a7k6vjodss69so97tmqmv0jjj5.apps.googleusercontent.com  # 填写客户端 ID
export GOOGLE_DEFAULT_CLIENT_SECRET=GoCSPX-iKHEKZmP4w_zdq0Z8nwOqz6SF2_M  # 填写客户端密钥
```

> **注意**
>
> 本节仅在默认 shell sh 和 KDE 6 下测试通过。其他环境下的配置欢迎提交反馈。

重启系统，再启动 Chromium。

点击“开启同步功能”：

![开启同步功能](/files/x5TgU3MDo3NdYnwtpF3i)

输入账户：

![输入账户](/files/RcagyRaa3n1qRAyQt2WH)

输入账户密码：

![输入密码](/files/2ggVEJZa4p3nf5EFhVNV)

![登录确认](/files/qDHQw1oo1pUbSmMfmevq)

查看同步情况：

![同步状态](/files/5dW9mXIh5gvAhVHPXpIi)

### 参考文献

* LearningToPi. Chromium Sync - Learning to Pi\[EB/OL]. \[2026-03-25]. <https://www.learningtopi.com/sbc/chromium-sync>. 该教程详细介绍了 Chromium 同步功能的配置步骤。
* 凌莞. 为 Chromium 恢复登录功能\[EB/OL]. \[2026-03-25]. <https://nyac.at/posts/google-sync-in-chromium>. 该文章提供了 Chromium 恢复 Google 账号登录的方法。

## 故障排除与未竟事宜

### 缓解 Chromium 磁盘缓存过大及 GPU 加速异常的问题

将参数添加至启动图标（其本质为文本文件）中：

```sh
chrome --disk-cache-size=0 --disable-gpu
```

> **注意**
>
> `--disk-cache-size=0` 并非禁用磁盘缓存，而是让 Chromium 使用默认计算值。如需限制缓存大小，请指定具体字节数（如 `--disk-cache-size=104857600` 表示 100 MB）。`--disable-gpu` 用于禁用 GPU 硬件加速。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://book.bsdcn.org/di-14-zhang-duo-mei-ti-he-wai-bu-she-bei/di-14.9-jie-web-liu-lan-qi.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
