36 openEuler搭建repo服务器-部署远端repo源

2023-11-10

36 openEuler搭建repo服务器-部署远端repo源

安装openEuler操作系统,在openEuler上通过nginx部署repo源。

36.1 nginx安装与配置

  1. 在root权限下安装nginx。
# dnf install -y nginx

例如示例命令如下:

[root@repo ~]# dnf install -y nginx
Last metadata expiration check: 1:32:43 ago on 2022年11月29日 星期二 20时22分38秒.
Dependencies resolved.
=============================================================================================================================
 Package                                   Architecture         Version                           Repository            Size
=============================================================================================================================
Installing:
 nginx                                     x86_64               1:1.21.5-3.oe2203                 update               498 k
Installing dependencies:
 gd                                        x86_64               2.3.2-2.oe2203                    update               127 k
 libXpm                                    x86_64               3.5.13-1.oe2203                   OS                    41 k
 libwebp                                   x86_64               1.2.1-1.oe2203                    OS                   246 k
 nginx-all-modules                         noarch               1:1.21.5-3.oe2203                 update               7.6 k
 nginx-filesystem                          noarch               1:1.21.5-3.oe2203                 update               8.7 k
 nginx-mod-http-image-filter               x86_64               1:1.21.5-3.oe2203                 update                18 k
 nginx-mod-http-perl                       x86_64               1:1.21.5-3.oe2203                 update                27 k
 nginx-mod-http-xslt-filter                x86_64               1:1.21.5-3.oe2203                 update                17 k
 nginx-mod-mail                            x86_64               1:1.21.5-3.oe2203                 update                49 k
 nginx-mod-stream                          x86_64               1:1.21.5-3.oe2203                 update                71 k

Transaction Summary
=============================================================================================================================
Install  11 Packages

Total download size: 1.1 M
Installed size: 3.0 M
Downloading Packages:
(1/11): libXpm-3.5.13-1.oe2203.x86_64.rpm                                                    187 kB/s |  41 kB     00:00    
(2/11): libwebp-1.2.1-1.oe2203.x86_64.rpm                                                    845 kB/s | 246 kB     00:00    
(3/11): gd-2.3.2-2.oe2203.x86_64.rpm                                                         427 kB/s | 127 kB     00:00    
(4/11): nginx-all-modules-1.21.5-3.oe2203.noarch.rpm                                         155 kB/s | 7.6 kB     00:00    
(5/11): nginx-filesystem-1.21.5-3.oe2203.noarch.rpm                                          179 kB/s | 8.7 kB     00:00    
(6/11): nginx-mod-http-image-filter-1.21.5-3.oe2203.x86_64.rpm                               368 kB/s |  18 kB     00:00    
(7/11): nginx-mod-http-perl-1.21.5-3.oe2203.x86_64.rpm                                       519 kB/s |  27 kB     00:00    
(8/11): nginx-mod-http-xslt-filter-1.21.5-3.oe2203.x86_64.rpm                                350 kB/s |  17 kB     00:00    
(9/11): nginx-mod-mail-1.21.5-3.oe2203.x86_64.rpm                                            498 kB/s |  49 kB     00:00    
(10/11): nginx-mod-stream-1.21.5-3.oe2203.x86_64.rpm                                         1.2 MB/s |  71 kB     00:00    
(11/11): nginx-1.21.5-3.oe2203.x86_64.rpm                                                    1.6 MB/s | 498 kB     00:00    
-----------------------------------------------------------------------------------------------------------------------------
Total                                                                                        2.0 MB/s | 1.1 MB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                     1/1 
  Running scriptlet: nginx-filesystem-1:1.21.5-3.oe2203.noarch                                                          1/11 
  Installing       : nginx-filesystem-1:1.21.5-3.oe2203.noarch                                                          1/11 
  Installing       : libwebp-1.2.1-1.oe2203.x86_64                                                                      2/11 
  Installing       : libXpm-3.5.13-1.oe2203.x86_64                                                                      3/11 
  Installing       : gd-2.3.2-2.oe2203.x86_64                                                                           4/11 
  Running scriptlet: gd-2.3.2-2.oe2203.x86_64                                                                           4/11 
  Installing       : nginx-mod-http-perl-1:1.21.5-3.oe2203.x86_64                                                       5/11 
  Running scriptlet: nginx-mod-http-perl-1:1.21.5-3.oe2203.x86_64                                                       5/11 
  Installing       : nginx-mod-http-xslt-filter-1:1.21.5-3.oe2203.x86_64                                                6/11 
  Running scriptlet: nginx-mod-http-xslt-filter-1:1.21.5-3.oe2203.x86_64                                                6/11 
  Installing       : nginx-mod-mail-1:1.21.5-3.oe2203.x86_64                                                            7/11 
  Running scriptlet: nginx-mod-mail-1:1.21.5-3.oe2203.x86_64                                                            7/11 
  Installing       : nginx-mod-stream-1:1.21.5-3.oe2203.x86_64                                                          8/11 
  Running scriptlet: nginx-mod-stream-1:1.21.5-3.oe2203.x86_64                                                          8/11 
  Installing       : nginx-1:1.21.5-3.oe2203.x86_64                                                                     9/11 
  Running scriptlet: nginx-1:1.21.5-3.oe2203.x86_64                                                                     9/11 
  Installing       : nginx-mod-http-image-filter-1:1.21.5-3.oe2203.x86_64                                              10/11 
  Running scriptlet: nginx-mod-http-image-filter-1:1.21.5-3.oe2203.x86_64                                              10/11 
  Installing       : nginx-all-modules-1:1.21.5-3.oe2203.noarch                                                        11/11 
  Running scriptlet: nginx-all-modules-1:1.21.5-3.oe2203.noarch                                                        11/11 
  Verifying        : libXpm-3.5.13-1.oe2203.x86_64                                                                      1/11 
  Verifying        : libwebp-1.2.1-1.oe2203.x86_64                                                                      2/11 
  Verifying        : gd-2.3.2-2.oe2203.x86_64                                                                           3/11 
  Verifying        : nginx-1:1.21.5-3.oe2203.x86_64                                                                     4/11 
  Verifying        : nginx-all-modules-1:1.21.5-3.oe2203.noarch                                                         5/11 
  Verifying        : nginx-filesystem-1:1.21.5-3.oe2203.noarch                                                          6/11 
  Verifying        : nginx-mod-http-image-filter-1:1.21.5-3.oe2203.x86_64                                               7/11 
  Verifying        : nginx-mod-http-perl-1:1.21.5-3.oe2203.x86_64                                                       8/11 
  Verifying        : nginx-mod-http-xslt-filter-1:1.21.5-3.oe2203.x86_64                                                9/11 
  Verifying        : nginx-mod-mail-1:1.21.5-3.oe2203.x86_64                                                           10/11 
  Verifying        : nginx-mod-stream-1:1.21.5-3.oe2203.x86_64                                                         11/11 

Installed:
  gd-2.3.2-2.oe2203.x86_64                                          libXpm-3.5.13-1.oe2203.x86_64                            
  libwebp-1.2.1-1.oe2203.x86_64                                     nginx-1:1.21.5-3.oe2203.x86_64                           
  nginx-all-modules-1:1.21.5-3.oe2203.noarch                        nginx-filesystem-1:1.21.5-3.oe2203.noarch                
  nginx-mod-http-image-filter-1:1.21.5-3.oe2203.x86_64              nginx-mod-http-perl-1:1.21.5-3.oe2203.x86_64             
  nginx-mod-http-xslt-filter-1:1.21.5-3.oe2203.x86_64               nginx-mod-mail-1:1.21.5-3.oe2203.x86_64                  
  nginx-mod-stream-1:1.21.5-3.oe2203.x86_64                        

Complete!
[root@repo ~]# 
  1. 在root权限下配置/etc/nginx/nginx.conf。

image-20221219190513462 说明:
文档中的配置内容仅供参考,请用户根据实际情况(例如安全加固需要)进行配置。

# vi /etc/nginx/nginx.conf

例如示例命令如下:

[root@repo ~]# cat /etc/nginx/nginx.conf
# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 4096;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80;
        listen       [::]:80;
        server_name  _;
        root         /usr/share/nginx/repo;
        
        location / {
            autoindex            on;
            autoindex_exact_size on;
            autoindex_localtime  on; 
        }

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

# Settings for a TLS enabled server.
#
#    server {
#        listen       443 ssl http2;
#        listen       [::]:443 ssl http2;
#        server_name  _;
#        root         /usr/share/nginx/html;
#
#        ssl_certificate "/etc/pki/nginx/server.crt";
#        ssl_certificate_key "/etc/pki/nginx/private/server.key";
#        ssl_session_cache shared:SSL:1m;
#        ssl_session_timeout  10m;
#        ssl_ciphers PROFILE=SYSTEM;
#        ssl_prefer_server_ciphers on;
#
#        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#
#        error_page 404 /404.html;
#            location = /40x.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#    }

}

[root@repo ~]# 

36.2 启动nginx服务

  1. 在root权限下通过systemd启动nginx服务。
# systemctl enable nginx
# systemctl start nginx

例如示例命令如下:

[root@repo ~]# systemctl enable nginx
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.
[root@repo ~]# 
[root@repo ~]# systemctl start nginx
[root@repo ~]# 
  1. nginx是否启动成功可通过下面命令查看。
# systemctl status nginx
  • 图1 表示nginx服务启动成功:

    图 1 nginx服务启动成功
    image-20221129221539117

  • 若nginx服务启动失败,查看错误信息并整改。

# systemctl status nginx.service --full

36.3 repo源部署

  1. 在root权限下创建nginx配置文件/etc/nginx/nginx.conf中指定的目录/usr/share/nginx/repo。
# mkdir -p /usr/share/nginx/repo

例如示例命令如下:

[root@repo ~]# mkdir -p /usr/share/nginx/repo
[root@repo ~]#
  1. 在root权限下修改目录/usr/share/nginx/repo的权限。
# chmod -R 755 /usr/share/nginx/repo

例如示例命令如下:

[root@repo ~]# chmod -R 755 /usr/share/nginx/repo
[root@repo ~]# 
  1. 设置防火墙规则,开启nginx设置的端口(此处为80端口),在root权限下通过firewall设置端口开启。
# firewall-cmd --add-port=80/tcp --permanent
# firewall-cmd --reload

例如示例命令如下:

[root@repo ~]# firewall-cmd --add-port=80/tcp --permanent
success
[root@repo ~]# 
[root@repo ~]# firewall-cmd --reload
success
[root@repo ~]# 
  1. 在root权限下查询80端口是否开启成功,输出为yes则表示80端口开启成功。
# firewall-cmd --query-port=80/tcp

例如示例命令如下:

[root@repo ~]# firewall-cmd --query-port=80/tcp
yes
[root@repo ~]#

或者也可在root权限下通过iptables来设置80端口开启,本次不使用iptables,只做了解

# iptables -I INPUT -p tcp --dport 80 -j ACCEPT
  1. nginx服务设置好之后,即可通过ip直接访问网页,如图2

图 2 nginx部署成功
image-20221130195540764

  1. 通过下面几种方式将repo源放入到/usr/share/nginx/repo下:
  • 在root权限下拷贝镜像中相关文件至/usr/share/nginx/repo下,并修改目录权限。
# mount -o loop /home/openEuler-22.03-LTS-everything-x86_64-dvd.iso /mnt
# cp -r /mnt/* /usr/share/nginx/repo
# chmod -R 755 /usr/share/nginx/repo

例如示例命令如下:

[root@repo ~]# mount -o loop /home/openEuler-22.03-LTS-everything-x86_64-dvd.iso /mnt
mount: /mnt: WARNING: source write-protected, mounted read-only.
[root@repo ~]# 
[root@repo ~]# cp -r /mnt/* /usr/share/nginx/repo
[root@repo ~]# 
[root@repo ~]# chmod -R 755 /usr/share/nginx/repo
[root@repo ~]# 

openEuler-22.03-LTS-everything-x86_64-dvd.iso存放在/home目录下。

  • 使用root在/usr/share/nginx/repo下创建repo源的软链接。
# ln -s /home/repo/* /usr/share/nginx/repo/

/home/repo为已经创建好的repo源,/usr/share/nginx/repo/将指向/home/repo。

例如示例命令如下:

[root@repo ~]# ln -s /home/repo/* /usr/share/nginx/repo/
[root@repo ~]#

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

36 openEuler搭建repo服务器-部署远端repo源 的相关文章

随机推荐

  • pid巡线算法程序_技术分享——从单个到多个颜色传感器巡线原理解析

    巡线竞速是常见的机器人比赛项目 它对速度和精准度要求都比较高 该项目大多要求现场进行结构搭建 并且赛前只提供培训参考地图 比赛使用的地图和巡线任务一般是现场才进行公布 对于参赛选手的能力要求较高 巡线任务的基础要求是车体 符合规格 的正投影
  • 关于通用型人工智能语言模型ChatGPT的感悟

    现在目前全世界只有一家真正有实在意义的通用性人工智能 也就是自然语言处理模型 即米国OpenAI旗下的ChatGPT 目前已经更新至GPT 4模型 这个秘密企划是从2017年开始的 一直到2023年才正式公开 在公开的几天内 被众领域学者科
  • docker入门学习笔记

    docker基础操作入门笔记 镜像操作 容器操作 数据卷操作 挂载 为什么要挂载 如何挂载 其他 docker设置开机自启 时间同步问题 jar包的运行 文章中几乎所有的写容器Id的地方 都可以使用容器名称来写命令 镜像操作 列出镜像列表
  • 安卓app后台运行时activity和dialog的一些区别

    Android app后台运行时 startactivity时可以启动其他activity 但是要弹出一个dialog是不被允许的 所以我的方案是把activity当做dialog来使用 这样就能正常弹出了 方法是给activity一个di
  • 【c++之容器】——list的源码模拟实现

    目录 1 list的概述 2 list的节点 3 list的迭代器 4 list的数据结构 a 插入节点 b 删除节点 1 list的概述 list的底层是 双向链表结构 双向链表中每个元素存储在互不相关的独立节点中 在节点中通过指 针指向
  • Docker学习2-docker存储之卷(Volume)

    参考博客 https www cnblogs com sammyliu p 5932996 html 有状态容器都有数据持久化需求 Docker 采用 AFUS 分层文件系统时 文件系统的改动都是发生在最上面的容器层 在容器的生命周期内 它
  • PRML一书中关于贝叶斯曲线拟合结论的推导细节

    PRML一书中关于贝叶斯曲线拟合结论的推导细节 我们令训练数据集为 X T X T X T 对于一个新的点 x
  • GitBook使用教程

    各大站长平时除了写博客外 可以使用 gitbook 将一系列的博客专栏整理成电子书出版 这样既方便各大网友阅读 还可以带来新的离线阅读功能 在以前我们只能靠出版社 或者编写 word 文档 来实现 然而有了 gitbook 之后 一切都变得
  • Python 炫技操作:条件语句的六种写法(Python就是这么炫酷)

    有的人说 Python 入门容易 但是精通难的语言 这点我非常赞同 Python 语言里有许多 而且是越来越多 的高级特性 是 Python 发烧友们非常喜欢的 在这些人的眼里 能够写出那些一般开发者看不懂的高级特性 就是高手 就是大神 但
  • 1.两数之和

    两数之和 给定一个整数数组 nums 和一个整数目标值 target 请你在该数组中找出 和为目标值 target 的那 两个 整数 并返回它们的数组下标 你可以假设每种输入只会对应一个答案 但是 数组中同一个元素在答案里不能重复出现 你可
  • 网络—安全—防火墙

    网络 安全 防火墙 是什么 表面概念 防火墙 一种高级访问控制设备 置于不同网络安全域之间 它通过相关的安全策略来控制 允许 拒绝 监视 记录 进出网络的访问行为 是什么 设备结构和运行原理 设备结构 Netfilter是由Rusty Ru
  • [Vue3 博物馆管理系统] 使用Vue3、Element-plus的Layout 布局构建组图文章

    系列文章目录 第一章 定制上中下 顶部菜单 底部区域 中间主区域显示 三层结构首页 第二章 使用Vue3 Element plus菜单组件构建菜单 第三章 使用Vue3 Element plus走马灯组件构建轮播图 第四章 使用Vue3 E
  • 使用python程序进行手势识别

    python代码 从视频读取帧保存为图片 import cv2 import numpy as np cap cv2 VideoCapture C Users lenovo Videos 1 mp4 读取文件 cap cv2 VideoCa
  • QGraphicsScene管理QGraphicsItem(单击/选择/移动/缩放/删除)

    文章目录 前言 简述 操作细节 示例 效果 源码 疑问自解自答 那么正方形旋转参照的是哪个点那 前言 本文参考博文https blog csdn net liang19890820 article details 53504323 简述 在
  • 初级运维(九)

    1 静态资源和动态资源的区别 优缺点如何 答 静态资源 URL固定 后缀名诸如 html和 jpg和 gif 它是服务端存在的一种文件 浏览器进行解析 不与数据库交互 有利于网站推广 SEO 维护麻烦 动态资源 有数据库支持 内容丰富 后缀
  • Linux操作系统 第八章

    实验1 磁盘引导 开启虚拟机 mbr 主引导记录 0磁道1扇区446 作用 记录grub2引导文件的位置 dd if dev zero of dev vda bs 446 count 1 清空系统 dev sda上的mbr数据 fdisk
  • android app 跳转到微信

    公司做了个微信投票活动 必须下载安装我们的app才能参加 所以当新客户投票时就会下载安装我们的 然后在注册完成后客户信息同步到微信接口上 然后就有一个回到微信的跳转 主要代码如下 try catch 捕捉到ActivityNotFoundE
  • 【论文笔记04】Model-driven approach for the design of multi-chainsmart contracts—用于设计多链智能合约的模型驱动方法

    A Bari i E Zhu and F Mallet Model driven approach for the design of Multi Chain Smart Contracts 2021 3rd Conference on B
  • g++十个最常用参数

    g 重要参数 1 g 产生调试信息 可以调试程序 2 O n 优化源代码 O0 不作优化 O1 默认 O2 指令调整 O3 循环展开 处理特性优化 编译速度会变慢 3 l指定库文件 L指定库文件路径 要链接哪些库 库直接紧接着比如 lglo
  • 36 openEuler搭建repo服务器-部署远端repo源

    文章目录 36 openEuler搭建repo服务器 部署远端repo源 36 1 nginx安装与配置 36 2 启动nginx服务 36 3 repo源部署 36 openEuler搭建repo服务器 部署远端repo源 安装openE