使用 Fedora 28 中的模块
Fedora 模块化
![](/data/attachment/album/201901/27/205100merrbu3z93khhm5z.jpg)


最近 Fedora Magazine 中题为 [Fedora 28 服务器版的模块化](/article-10479-1.html)在解释 Fedora 28 中的模块化方面做得很好。它还给出了一些示例模块并解释了它们解决的问题。本文将其中一个模块用于实际应用，包括使用模块安装设置 Review Board 3.0。


### 入门


想要继续并使用模块，你需要一个 [Fedora 28 服务器版](https://getfedora.org/server/)并拥有 [sudo 管理权限](https://fedoramagazine.org/howto-use-sudo/)。另外，运行此命令以确保系统上的所有软件包都是最新的：



```
sudo dnf -y update
```

虽然你可以在 Fedora 28 非服务器版本上使用模块，但请注意[上一篇文章评论中提到的警告](https://fedoramagazine.org/modularity-fedora-28-server-edition/#comment-476696)。


### 检查模块


首先，看看 Fedora 28 可用的模块。运行以下命令：



```
dnf module list
```

输出列出了一组模块，这些模块显示了每个模块的关联的流、版本和可用安装配置文件。模块流旁边的 `[d]` 表示安装命名模块时使用的默认流。


输出还显示大多数模块都有名为 `default` 的配置文件。这不是巧合，因为 `default` 是默认配置文件使用的名称。


要查看所有这些模块的来源，请运行：



```
dnf repolist
```

与通常的 [fedora 和更新包仓库](https://fedoraproject.org/wiki/Repositories)一起，输出还显示了 fedora-modular 和 updates-modular 仓库。


介绍声明你将设置 Review Board 3.0。也许名为 reviewboard 的模块在之前的输出中引起了你的注意。接下来，要获取有关该模块的一些详细信息，请运行以下命令：



```
dnf module info reviewboard
```

根据描述确认它是 Review Board 模块，但也说明是 2.5 的流。然而你想要 3.0 的。查看可用的 reviewboard 模块：



```
dnf module list reviewboard
```

2.5 旁边的 `[d]` 表示它被配置为 reviewboard 的默认流。因此，请明确你想要的流：



```
dnf module info reviewboard:3.0
```

有关 reviewboard:3.0 模块的更多详细信息，请添加详细选项：



```
dnf module info reviewboard:3.0 -v
```

### 安装 Review Board 3.0 模块


现在你已经跟踪了所需的模块，请使用以下命令安装它：



```
sudo dnf -y module install reviewboard:3.0
```

输出显示已安装 ReviewBoard 以及其他几个依赖软件包，其中包括 django:1.6 模块中的几个软件包。安装还启用了 reviewboard:3.0 模块和相关的 django:1.6 模块。


接下来，要查看已启用的模块，请使用以下命令：



```
dnf module list --enabled
```

输出中，`[e]` 表示已启用的流，`[i]` 表示已安装的配置。对于 reviewboard:3.0 模块，已安装默认配置。你可以在安装模块时指定其他配置。实际上，你仍然可以安装它，而且这次你不需要指定 3.0，因为它已经启用：



```
sudo dnf -y module install reviewboard/server
```

但是，安装 reviewboard:3.0/server 配置非常平常。reviewboard:3.0 模块的服务器配置与默认配置文件相同 —— 因此无需安装。


### 启动 Review Board 网站


现在已经安装了 Review Board 3.0 模块及其相关软件包，[创建一个本地运行的 Review Board 网站](https://www.reviewboard.org/docs/manual/dev/admin/installation/creating-sites/)。无需解释，请复制并粘贴以下命令：



```
sudo rb-site install --noinput \
    --domain-name=localhost --db-type=sqlite3 \
    --db-name=/var/www/rev.local/data/reviewboard.db \
    --admin-user=rbadmin --admin-password=secret \
    /var/www/rev.local
sudo chown -R apache /var/www/rev.local/htdocs/media/uploaded \
    /var/www/rev.local/data
sudo ln -s /var/www/rev.local/conf/apache-wsgi.conf \
    /etc/httpd/conf.d/reviewboard-localhost.conf
sudo setsebool -P httpd_can_sendmail=1 httpd_can_network_connect=1 \
    httpd_can_network_memcache=1 httpd_unified=1
sudo systemctl enable --now httpd
```

现在启动系统中的 Web 浏览器，打开 <http://localhost>，然后享受全新的 Review Board 网站！要以 Review Board 管理员身份登录，请使用上面 `rb-site` 命令中的用户 ID 和密码。


### 模块清理


完成后清理是个好习惯。为此，删除 Review Board 模块和站点目录：



```
sudo dnf -y module remove reviewboard:3.0
sudo rm -rf /var/www/rev.local
```

### 总结


现在你已经探索了如何检测和管理 Review Board 模块，那么去体验 Fedora 28 中提供的其他模块吧。


在 [Fedora 模块化](https://docs.pagure.org/modularity/)网站上了解有关在 Fedora 28 中使用模块的更多信息。dnf 手册页中的 module 命令部分也包含了有用的信息。




---


via: <https://fedoramagazine.org/working-modules-fedora-28/>


作者：[Merlin Mathesius](https://fedoramagazine.org/author/merlinm/) 选题：[lujun9972](https://github.com/lujun9972) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
The recent Fedora Magazine article entitled [ Modularity in Fedora 28 Server Edition](https://fedoramagazine.org/modularity-fedora-28-server-edition/) did a great job of explaining Modularity in Fedora 28. It also pointed out a few example modules and explained the problems they solve. This article puts one of those modules to practical use, covering installation and setup of Review Board 3.0 using modules.


## Getting started

To follow along with this article and use modules, you need a system running [Fedora 28 Server Edition](https://getfedora.org/server/) along with [ sudo administrative privileges](https://fedoramagazine.org/howto-use-sudo/). Also, run this command to make sure all the packages on the system are current:

sudo dnf -y update

While you can use modules on Fedora 28 non-server editions, be aware of the [caveats described in the comments of the previous article](https://fedoramagazine.org/modularity-fedora-28-server-edition/#comment-476696).

## Examining modules

First, take a look at what modules are available for Fedora 28. Run the following command:

dnf module list

The output lists a collection of modules that shows the associated stream, version, and available installation profiles for each. A *[d]* next to a particular module stream indicates the default stream used if the named module is installed.

The output also shows most modules have a profile named *default*. That’s not a coincidence, since *default* is the name used for the default profile.

To see where all those modules are coming from, run:

dnf repolist

Along with the usual [ fedora and updates package repositories](https://fedoraproject.org/wiki/Repositories), the output shows the

*fedora-modular*and

*updates-modular*repositories.

The introduction stated you’d be setting up Review Board 3.0. Perhaps a module named *reviewboard* caught your attention in the earlier output. Next, to get some details about that module, run this command:

dnf module info reviewboard

The description confirms it is the Review Board module, but also says it’s the 2.5 stream. However, you want 3.0. Look at the available *reviewboard* modules:

dnf module list reviewboard

The *[d]* next to the 2.5 stream means it is configured as the default stream for *reviewboard*. Therefore, be explicit about the stream you want:

dnf module info reviewboard:3.0

Now for even more details about the *reviewboard:3.0* module, add the verbose option:

dnf module info reviewboard:3.0 -v

## Installing the Review Board 3.0 module

Now that you’ve tracked down the module you want, install it with this command:

sudo dnf -y module install reviewboard:3.0

The output shows the ReviewBoard package was installed, along with several other dependent packages, including several from the *django:1.6* module. The installation also enabled the *reviewboard:3.0* module and the dependent *django:1.6* module.

Next, to see enabled modules, use this command:

dnf module list --enabled

The output shows *[e]* for enabled streams, and *[i]* for installed profiles. In the case of the *reviewboard:3.0* module, the *default* profile was installed. You could have specified a different profile when installing the module. In fact, you still can — and this time you don’t need to specify the 3.0 stream since it was already enabled:

sudo dnf -y module install reviewboard/server

However, installation of the *reviewboard:3.0/server* profile is rather uneventful. The *reviewboard:3.0* module’s *server* profile is the same as the *default* profile — so there’s nothing more to install.

## Spin up a Review Board site

Now that the Review Board 3.0 module and its dependent packages are installed, [create a Review Board site](https://www.reviewboard.org/docs/manual/dev/admin/installation/creating-sites/) running on the local system. Without further ado or explanation, copy and paste the following commands to do that:

sudo rb-site install --noinput \ --domain-name=localhost --db-type=sqlite3 \ --db-name=/var/www/rev.local/data/reviewboard.db \ --admin-user=rbadmin --admin-password=secret \ /var/www/rev.local sudo chown -R apache /var/www/rev.local/htdocs/media/uploaded \ /var/www/rev.local/data sudo ln -s /var/www/rev.local/conf/apache-wsgi.conf \ /etc/httpd/conf.d/reviewboard-localhost.conf sudo setsebool -P httpd_can_sendmail=1 httpd_can_network_connect=1 \ httpd_can_network_memcache=1 httpd_unified=1 sudo systemctl enable --now httpd

Now fire up a web browser on the system, point it at *http://localhost*, and enjoy the shiny new Review Board site! To login as the Review Board admin, use the userid and password seen in the *rb-site* command above.

## Module cleanup

It’s good practice to clean up after yourself. To do that, remove the Review Board module and the site directory:

sudo dnf -y module remove reviewboard:3.0 sudo rm -rf /var/www/rev.local

## Closing remarks

Now that you’ve explored how to examine and administer the Review Board module, go experiment with the other modules available in Fedora 28.

Learn more about using modules in Fedora 28 on the [Fedora Modularity](https://docs.pagure.org/modularity/) web site. The *dnf* manual page’s *Module Command* section also contains useful information.

## Ricky Tigg

$ dnf module list

Fedora 28 – x86_64 – Updates 2.7 MB/s | 15 MB 00:05

Fedora 28 – x86_64 12 MB/s | 60 MB 00:05

Last metadata expiration check: 0:00:00 ago on Thu 07 Jun 2018 09:33:28 CEST.

Nothing to show.

## Merlin Mathesius

You don’t appear to have the modular repos enabled. If you’re using a Fedora 28 Server Edition system, something is wrong with your installation. If you’re using a non-server system, follow the link in the “Getting started” section above–but beware of the caveats!

## Ricky Tigg

Fedora 28 Desktop Edition. Repository named ‘Modular’ was not yet added.

## Matěj Koudelka

Try to install package fedora-repos-modular