Step5—Nginx安装
# 使用 Nginx 搭建本地 YUM 仓库 🌐📦
Kylin V10 专题说明
本文基于 Kylin V10(SP3 Halberd) 系统环境编写,命令、包名及路径均已针对 Kylin 官方仓库 (kylin-v10.repo)
进行适配。其他操作系统(Rocky、openEuler、Ubuntu 等)请参考各自的安装章节,如路径、SELinux 策略或 repo 文件结构有所差异,请以对应章节为准。
在 Kylin V10 环境中,可以使用 Nginx 充当本地 YUM 仓库的 Web 服务端,集中分发 RPM 软件包。
相比传统 httpd (Apache),Nginx 更轻量、更高效,并天然支持目录索引,十分适合离线仓库或集群部署场景。
# 1. Nginx 作为 YUM 仓库的优势 ✅
Nginx 作为 Web 服务器提供 YUM 仓库文件访问,相比 httpd(Apache)具备以下优势:
- 更轻量级 🚀:适用于高性能场景,占用资源更少。
- 默认支持目录索引 📂:无需额外配置,允许直接访问 RPM 文件。
- 更好的静态文件处理能力 🖥️:适用于 RPM 仓库或其他静态资源托管。
# 2. Nginx 安装 📥
本地 YUM 仓库服务器需要安装 Nginx,作为 Web 服务器提供 RPM 文件的访问。
# 2.1 安装 Nginx
yum install -y nginx
1
# 2.2 验证 Nginx 是否安装成功
nginx -v
1
如果输出类似 nginx version: nginx/1.xx.x,说明安装成功。
# 3. 配置 Nginx 作为 YUM 仓库 🛠️
# 3.1 创建 YUM 资源目录
mkdir -p /data/modules
chmod -R 755 /data/modules
chown -R nginx:nginx /data/modules
1
2
3
2
3
此目录将作为 YUM 仓库的根目录,存放 RPM 包。
# 3.2 配置 Nginx
编辑配置文件:
vim /etc/nginx/conf.d/yum_repo.conf
1
添加以下内容:
server {
listen 80;
server_name _;
location / {
root /data/modules;
index index.html index.htm;
autoindex on; # 启用目录索引,允许浏览 RPM 文件
autoindex_exact_size off;
autoindex_localtime on;
}
error_page 404 /404.html;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
我的文件均放在/data/modules/ 下所有使用上述配置。下面将展示我的本地仓库路径。

# 3.3 禁用默认 Nginx 配置
mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bak
1
# 3.4 配置 SELinux(如启用)
如果 SELinux 处于 Enforcing 模式,需要执行:
chcon -Rt httpd_sys_content_t /data/modules
1
# 4. 启动并测试 Nginx 🚀
# 4.1 启动 Nginx
systemctl restart nginx
systemctl enable nginx
1
2
2
# 4.2 测试 Nginx 是否正常运行
systemctl status nginx
1
如果状态显示 active (running),则表示 Nginx 运行正常。
# 4.3 测试 Nginx 是否提供 YUM 资源
curl -I http://localhost/
1
如果返回 HTTP/1.1 200 OK,说明 YUM 资源目录已正确配置。

- 01
- Ambari开启Kerberos认证加密类型错误 Kylin V1011-05
- 02
- KERBEROS SERVICE CHECK 报错11-04