debian技术--搭建debian软件仓库

    技术2025-03-31  23

    文章目录

    一.debian介绍1.特点2. debian 和 ubnutu 的关系3. debian 和 Centos 的关系 二.debian的安装1.新建虚拟机2.进入安装界面3.配置网络4.设置用户名和密码5.磁盘分区6.配置软件包管理器 三.debian配置1.更新软件源2.安装常用软件3.使用ll命令4.创建用户5.配置仓库5.1 环境准备5.2 安装部署nginx5.3 搭建仓库

    一.debian介绍

    1.特点

    1.Debian 是精简的 Linux 发行版,有着干净的作业环境。 2.安装步骤简易有效,大部分情况下只要<Enter>、<Enter>一直按下去便可以顺利安装。 3.拥有方便高效的软体包管理程序和 deb 软体包,可以让用户容易的查找、安装、移除、更新程序,或系统昇级。 4.健全的软件管理制度,包括了 Bug 汇报、包维护人等制度,让 Debian 所收集的软件品质在其它的 Linux 发行包之上。 5.拥有庞大的包库,令用户只需通过其自身所带的软件管理系统便可下载并安装包,不必再在网络上查找。 6.包库分类清楚,用户可以明确地选择安装自由软件、半自由软件或闭源软件。

    2. debian 和 ubnutu 的关系

    Ubuntu 与 Debian 使用相同的 deb 软件包格式,可以安装绝大多数为 Debian 编译的软件包,虽然不能保证完全兼容,但大多数情况是

    3. debian 和 Centos 的关系

    没什么关系.Debian 名字比较难念正确. Debian 的版本命名更好玩一些,以电影<玩具总动员里>的人物命令

    二.debian的安装

    1.新建虚拟机

    2.进入安装界面

    3.配置网络

    4.设置用户名和密码

    5.磁盘分区

    6.配置软件包管理器

    问题及反思

    1.解决root用户没法连接xshell的问题 systemctl restart sshd 2.在安装的时候不配置网络速度会更快, 1)中途退出安装重新安装的方法 按F10,再次进入安装界面,配置网络那里选择”现在不进行网络配置“ 2)进行网卡配置

    vim /etc/network/interfaces #The loopback network interface auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 10.0.0.100 netmask 255.255.255.0 gateway 10.0.0.2 ifup eth0

    3)配置dns

    vim /etc/resolv.conf search unassigned-domain nameserver 10.0.0.2

    4)连接网卡 5)启动网络 /etc/init.d/networking restart

    三.debian配置

    1.更新软件源

    https://mirrors.tuna.tsinghua.edu.cn/help/debian/

    root@debian:~# vi /etc/sources.list deb https://mirrors.tuna.tsinghua.edu.cn/debian/ jessie main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian/ jessie-updates main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian/ jessie-backports main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian-security jessie/updates main contrib non-free root@debian:~# apt install apt-transport-https root@debian:~# apt-get update

    2.安装常用软件

    root@debian:~# apt-get install vim lsof tree -y

    3.使用ll命令

    root@debian:~# vim .bashrc # ~/.bashrc: executed by bash(1) for non-login shells. # Note: PS1 and umask are already set in /etc/profile. You should not # need this unless you want different defaults for root. # PS1='${debian_chroot:+($debian_chroot)}\h:\w\$ ' # umask 022 # You may uncomment the following lines if you want `ls' to be colorized: 打开这一行: export LS_OPTIONS='--color=auto' eval "`dircolors`" alias ls='ls $LS_OPTIONS' alias ll='ls $LS_OPTIONS -l' alias l='ls $LS_OPTIONS -lA' # # Some more alias to avoid making mistakes: 打开这一行: alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' root@debian:~# source .bashrc

    4.创建用户

    root@debian:~# useradd lbzy root@debian:~# mkdir /home/lbzy root@debian:~# chown -R lbzy:lbzy /home/lbzy root@debian:~# vim /etc/passwd lbzy:x:1001:1002::/home/lbzy:/bin/sh 把这一行改为 lbzy:x:1001:1002::/home/lbzy:/bin/bash root@debian:~# su - lbzy lbzy@debian:~$ 原因: 在centos7中:[root@web01 ~]# ll /bin/sh lrwxrwxrwx. 1 root root 4 Nov 16 04:49 /bin/sh -> bash 软链接是直接到bash 在debian中:root@debian:~# ll /bin/sh lrwxrwxrwx 1 root root 4 11月 8 2014 /bin/sh -> dash

    5.配置仓库

    5.1 环境准备

    服务端:debian-100 ip地址:10.0.0.100 客户端:debian-200 ip地址:10.0.0.200

    5.2 安装部署nginx

    在服务端: root@debian-100:~# vim /etc/nginx/nginx.conf user www; #修改这一行 #include /etc/nginx/sites-enabled/* #删除这一行 mail ... #删掉mail后面的部分 root@debian-100:~# groupadd www -g 888 root@debian-100:~# useradd www -u 888 -g 888 -M -s /sbin/nologin root@debian-100:~# mkdir -p /data/mydeb/ root@debian-100:/etc/nginx/conf.d# cat > /etc/nginx/conf.d/apt-deb.conf<<EOF > server { > listen 8080; > server_name localhost; > autoindex on; > location / { > index index.html index.htm; > root /data/mydeb/; > } > } > EOF root@debian-100:~# chown -R www:www /data/ root@debian-100:~# nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful root@debian-100:~# systemctl restart nginx(因为默认已经启动,所以这里必须使用restart)

    访问成功: http://10.0.0.100:8080

    5.3 搭建仓库

    服务端搭建仓库: root@debian-100:/etc/nginx/conf.d# apt-get clean root@debian-100:~# apt-get install -d screen root@debian-100:~# apt-get install -d curl root@debian-100:~# apt-get install -d wget 在官网查找https://mirrors.tuna.tsinghua.edu.cn/help/docker-ce/ 安装依赖: apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common 添加软件仓库: add-apt-repository \ "deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian \ $(lsb_release -cs) \ stable" 查看: root@debian-100:~#apt-get update root@debian-100:~#apt-get install -d docker-ce #-d只下载不安装 root@debian-100:~# tree /var/cache/apt/archives/ root@debian-100:~# mv /var/cache/apt/archives/ /data/mydeb/ root@debian-100:~# cd /data/mydeb/ root@debian-100:/data/mydeb# ls archives root@debian-100:/data/mydeb# mv archives/* . root@debian-100:/data/mydeb# mv archives /var/cache/apt/ 创建目录索引: root@debian-100:/data/mydeb# apt-get install dpkg-dev 把最新的软件包更新加载在这个包里Packages.gz,客户端可以直接下载:(每次更新都要执行这条命令,客户端才可以直接下载更新的信息) root@debian-100:/data/mydeb# dpkg-scanpackages ./ /dev/null | gzip -9c > Packages.gz 客户端验证: root@debian-200:~# vim /etc/apt/sources.list deb http://10.0.0.100:8080/ / root@debian-200:~# apt-get update 忽略 http://10.0.0.100:8080 InRelease 忽略 http://10.0.0.100:8080 Release.gpg 忽略 http://10.0.0.100:8080 Release 获取:1 http://10.0.0.100:8080 Packages [14.6 kB] 忽略 http://10.0.0.100:8080 Translation-zh_CN 忽略 http://10.0.0.100:8080 Translation-zh 忽略 http://10.0.0.100:8080 Translation-en 下载 14.6 kB,耗时 0秒 (241 kB/s) 正在读取软件包列表... 完成 root@debian-200:~# apt-cache search docker-ce docker-ce - Docker: the open-source application container engine root@debian-200:~# systemctl start docker root@debian-200:~# docker pull nginx root@debian-200:~# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 3d13d92b06ff nginx "nginx -g 'daemon of…" 49 seconds ago Exited (0) 34 seconds ago keen_carson root@debian-200:~# docker start 3d13d92b06ff 3d13d92b06ff root@debian-200:~# docker exec -it 3d13d92b06ff /bin/bash root@3d13d92b06ff:/#

    查看http://10.0.0.100:8080

    Processed: 0.010, SQL: 9