• Ubuntu制作本地安装源


    应用场景

    • 当我们需要在多台电脑安装同一个软件,并且软件很大,下载需要很长时间
    • 需要安装软件的ubuntu不能上网。

    离线安装包的制作(可联网电脑)

    1. 可联网电脑要与不能联网电脑系统一致
    2. 修改可联网电脑源,使用国内源,加快软件下载速度
    3. 系统ubuntu20.0.4

    更新源

    sudo vi /etc/apt/sources.list
    
    deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
    deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
    deb http://mirrors.aliyun.com/ubuntu/ xenial universe
    deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
    deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
    deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
    deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu xenial-security main restricted
    deb http://mirrors.aliyun.com/ubuntu xenial-security universe
    deb http://mirrors.aliyun.com/ubuntu xenial-security multiverse
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    安装软件
    sudo apt-get -y install python3-pip
    
    • 1

    执行完上述指令后,XXXX软件的安装包就下载到了/var/cache/apt/archives目录下

    生成依赖关系

    ### 新建一个文件夹
    sudo mkdir /offlinePackage
    
    # 将下载的deb包拷贝到上述新建的文件夹下
    sudo cp -r /var/cache/apt/archives  /offlinePackage
    
    # 修改文件夹权限
    sudo chmod 777 -R /offlinePackage/
    
    # 建立deb包的依赖关系
    sudo dpkg-scanpackages /offlinePackage/ /dev/null |gzip >/offlinePackage/Packages.gz
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    如果出现错误:sudo: dpkg-scanpackages: command not found,则需要安装dpkg-dev工具
    sudo apt-get install dpkg-dev

    # 打包成压缩包
    sudo tar zcvf offlinePackage.tar.gz /offlinePackage/
    
    • 1
    • 2

    保存打包后的offlinePackage.tar.gz文件到U盘或服务器

    在另外一台Ubuntu上离线安装

    # 
    # 将offlinePackage.tar.gz复制到根目录下,解压
    sudo tar zxvf offlinePackage.tar.gz -C /
    
    # 将安装包所在和源路径添加到系统源source.list
    sudo vi /etc/apt/sources.list
    deb [trusted=yes] file:/// offlinePackage/
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    注意:offlinePackage前面有一个空格

    # 更新源
    sudo apt-get update
    
    W: The repository 'file: offlinePackage/ Release' does not have a Release file.N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.N: See apt-secure(8) manpage for repository creation and user configuration details.
    
    # 大概意思是,这是不安全的更新源
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    安装

    此时,在没有网络的情况下,我们就可以安装我们之间下载的XXXX软件了。比如安装python3-pip,注意:由于上面已经提示不安全了,所以安装软件时,必须要加--allow-unauthenticated,否则报错 E: There were unauthenticated packages and -y was used without --allow-unauthenticated

    sudo apt-get -y install python3-pip --allow-unauthenticated
    
    • 1

    使用deb http方式安装

    上线使用的是file方式,只能本机使用。那么其他服务器要使用,就不行了! 这个时候,需要使用http方式。可以让局域网的其他服务器使用!

    安装nginx

    sudo apt-get install -y nginx
    
    # 搭建项目索引页
    sudo vim /etc/nginx/nginx.conf
    
    # 找到以下内容,将sites-enabled注释掉
    include /etc/nginx/conf.d/*.conf; 
    #include /etc/nginx/sites-enabled/*;
    
    # 进入目录conf.d,新建文件deb.conf
    vim /etc/nginx/conf.d/deb.conf
    server {
       listen 80;
       server_name localhost;
       root /offlinePackage;
    
       location / {
           autoindex on;
       }
     }
    
    
    # 检查配置文件是否正确
    sudo nginx -t
    
    # 加载配置
    nginx -s reload
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27

    更新ubuntu数据库,并安装应用

    # 编辑配置文件
    sudo vim /etc/apt/sources.list
    # 最后一行增加,  最后一个是斜杠。  注意:保证有空格,否则会提示格式错误。
    # 添加 [trusted=yes] 后,使用apt-get install 安装时不用再添加--allow-unauthenticated,否则安装时需要一定要带--allow-unauthenticated ,安装命令为 apt-get install -y 软件名 --allow-unauthenticated
    deb [trusted=yes] http://nginx_ip /
    
    # 使用apt-get update来更新一下
    sudo apt-get update
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
  • 相关阅读:
    数据库锁及批量更新死锁处理
    Windows系统配置高精度时间服务
    人与人之间的差异在于外界
    生成式人工智能 - stable diffusion web-ui安装教程
    6、ByteBuffer内部结构
    【对称美学/对称字符串】python实现-附ChatGPT解析
    在win7和win10上通过INF文件安装64位WDM驱动
    OceanBase年度发布会归来
    计算机毕业设计Java电子产品购物平台(源码+系统+mysql数据库+lw文档)
    独立服务器应该怎么选择?
  • 原文地址:https://blog.csdn.net/smartboy_01/article/details/136341032