同步服务器操作系统公网仓库到本地02--搭建http内网仓库源 _ 麒麟KOS _ 统信UOS _ 中科方德 NFSCNS

原文链接:同步服务器操作系统公网仓库到本地02 ---搭建http内网仓库源| 麒麟KOS | 统信UOS | 中科方德 NFSCNS

Hello,大家好啊!继之前我们讨论了如何同步服务器公网仓库到本地服务器之后,今天我们将进入这个系列的第二篇文章------通过配置nginx服务,将本地源共享给其他服务器使用。这一步是建立本地镜像站点的关键环节,可以帮助我们在局域网内高效地分发软件包,大大提升更新和部署的速度,同时也节省了宽带资源。本篇文章使用麒麟KOS服务器示例,统信UOS服务器及中科方德NFSCNS服务器同样也适用。下面,让我们开始详细的配置过程。

安装和配置Nginx

Nginx是一个高性能的HTTP和反向代理服务器,也是一个非常流行的邮件代理服务器。它以其高效、稳定而闻名。我们将利用Nginx来搭建本地源服务器。

1.查看系统信息

bash 复制代码
[root@localhost ~]# cat /etc/os-release
[root@localhost ~]# uname -a

2.安装nginx

bash 复制代码
[root@localhost ~]# yum install nginx -y

3.配置软连接

bash 复制代码
[root@localhost ~]# cd /var/www/html/
[root@localhost html]# ln  -sf  /kylinv10sp3amd64  ./

4.编辑nginx配置文件

bash 复制代码
[root@localhost /]# vim /etc/nginx/nginx.conf
[root@localhost /]# 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 2048;

    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 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /var/www/html/kylinv10sp3amd64/;

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

        location / {
        autoindex on;
        }

        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 default_server;
#        listen       [::]:443 ssl http2 default_server;
#        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;
#
#        location / {
#        }
#
#        error_page 404 /404.html;
#            location = /40x.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#    }

}

5.校验nginx语法

root@localhost \~\]# nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful ![](https://file.jishuzhan.net/article/1772853929462206466/15d1e5bfb575004188a961649d535a8a.webp) 6.重启nginx服务 ```bash [root@localhost html]# systemctl restart nginx.service [root@localhost html]# systemctl enable nginx.service [root@localhost html]# systemctl status nginx.service ``` ![](https://file.jishuzhan.net/article/1772853929462206466/2f9c7d3c0153c3ece7fb7de2a893c92c.webp) 7.配置防火墙 ```bash [root@localhost html]# firewall-cmd --permanent --zone=public --add-service=http [root@localhost html]# firewall-cmd --permanent --zone=public --add-service=https [root@localhost html]# firewall-cmd --reload ``` ![](https://file.jishuzhan.net/article/1772853929462206466/2621a55a5f3e81d9ef0538e5acbed276.webp) 8.在浏览器访问测试 ```bash http://192.168.80.113/ ``` ![](https://file.jishuzhan.net/article/1772853929462206466/f87400504aafa80ab1ccc0ea3b1b2c62.webp) 9.在其他服务器配置源 ```bash [root@localhost /]# cd /etc/yum.repos.d/ [root@localhost yum.repos.d]# cp kylin_x86_64.repo{,.bak2024} [root@localhost yum.repos.d]# vim kylin_x86_64.repo [root@localhost yum.repos.d]# cat kylin_x86_64.repo ###Kylin Linux Advanced Server 10 - os repo### [ks10-adv-os] name = Kylin Linux Advanced Server 10 - Os baseurl = http://192.168.80.113/ks10-adv-os/ gpgcheck = 0 enabled = 1 [ks10-adv-updates] name = Kylin Linux Advanced Server 10 - Updates baseurl = http://192.168.80.113/ks10-adv-updates/ gpgcheck = 0 enabled = 1 ``` ![](https://file.jishuzhan.net/article/1772853929462206466/35fcd4e8da65a70040e6bd7aa4b3cb88.webp) 10.更新源 ```bash [root@localhost yum.repos.d]# yum update ``` ![](https://file.jishuzhan.net/article/1772853929462206466/7533918732b64fe1f27f967e3883651e.webp) 11.安装软件测试 ```bash [root@localhost yum.repos.d]# yum install tigervnc-server -y ``` ![](https://file.jishuzhan.net/article/1772853929462206466/4aed8846d6f83dd07766b46049c02539.webp) 至此,你已经成功配置了Nginx服务,将本地源共享给了其他服务器使用。这不仅能帮助你在内网环境中快速部署和更新软件,还能减轻公网源的负载,是一种高效且经济的解决方案。希望这篇文章对你有所帮助,如果你觉得有用,请不吝分享和转发。同时,别忘了点个关注和在看,获取更多有用的技术信息和解决方案。感谢大家的阅读,我们下次再见!

相关推荐
sukida10012 分钟前
BIOS主板(非UEFI)安装fedora42的方法
linux·windows·fedora
●^●32 分钟前
Linux 权限修改详解:chmod 命令与权限数字的秘密
linux
唯独失去了从容35 分钟前
WebRTC服务器Coturn服务器中的通信协议
运维·服务器·webrtc
光而不耀@lgy2 小时前
C++初登门槛
linux·开发语言·网络·c++·后端
偶尔微微一笑2 小时前
AI网络渗透kali应用(gptshell)
linux·人工智能·python·自然语言处理·编辑器
Run1.2 小时前
深入解析 Linux 中动静态库的加载机制:从原理到实践
linux·运维·服务器
The Mr.Nobody2 小时前
STM32MPU开发之旅:从零开始构建嵌入式Linux镜像
linux·stm32·嵌入式硬件
老兵发新帖2 小时前
Ubuntu 上安装 Conda
linux·ubuntu·conda
秋秋秋秋秋雨2 小时前
linux安装单节点Elasticsearch(es),安装可视化工具kibana
linux·elasticsearch·jenkins
码农hbk3 小时前
linux ptrace 图文详解(七) gdb、strace跟踪系统调用
linux·服务器