一:自建yum仓库的本地源(Centos8为例)

1.1 在/var/www/html创建目录

[root@hhw- html]#mkdir centos/8 -pv
mkdir: created directory 'centos'
mkdir: created directory 'centos/8'
[root@hhw- html]#tree					验证目录是否创建
.
└── centos
    └── 8

2 directories, 0 files

1.2 挂载光驱到/var/www/html/centos/8

[root@hhw- 8]#mount /dev/sr0 /var/www/html/centos/8
mount: /var/www/html/centos/8: WARNING: device write-protected, mounted read-only.
[root@hhw- 8]#lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0          11:0    1  8.6G  0 rom  /var/www/html/centos/8

1.3 这时已经可以正常访问了

[root@hhw- 8]#ls
AppStream  BaseOS  EFI  images  isolinux  LICENSE  media.repo  TRANS.TBL
[root@hhw- 8]#pwd
/var/www/html/centos/8
浏览器也可以看到

image.png

1.4 为另一台Centos8添加本地yum的私有仓库
[root@hhw832 yum.repos.d]#vim base.repo 
[BaseOS]
name=BaseOS
#baseurl=https://mirrors.cloud.tencent.com/centos/$releasever/BaseOS/$basearch/os
baseurl=http://10.0.0.150:8080/centos/8/BaseOS			#添加本地源
gpgcheck=0
[AppStream]
name=AppStream
#baseurl=https://mirrors.cloud.tencent.com/centos/$releasever/AppStream/$basearch/os
baseurl=http://10.0.0.150:8080/centos/8/AppStream			##添加本地源
gpgcheck=0	
[root@hhw832 yum.repos.d]#yum clean all 		清楚缓存
0 files removed
[root@hhw832 yum.repos.d]#yum repolist 
repo id                                             repo name
AppStream                                           AppStream
BaseOS                                              BaseOS

1.5 测试是否能正常yum

[root@hhw832 yum.repos.d]#yum list vsftpd
Last metadata expiration check: 0:00:47 ago on Tue 19 Apr 2022 12:46:39 PM CST.
Available Packages
vsftpd.x86_64                                   3.0.3-32.el8                                   AppStream
[root@hhw832 yum.repos.d]#yum -y install vsftpd				#速度非常快
Last metadata expiration check: 0:01:09 ago on Tue 19 Apr 2022 12:46:39 PM CST.
Dependencies resolved.
========================================================================================================
 Package               Architecture          Version                     Repository                Size
========================================================================================================
Installing:
 vsftpd                x86_64                3.0.3-32.el8                AppStream                180 k

Transaction Summary
========================================================================================================
Install  1 Package

Total download size: 180 k
Installed size: 343 k
Downloading Packages:
vsftpd-3.0.3-32.el8.x86_64.rpm                                           41 MB/s | 180 kB     00:00    
--------------------------------------------------------------------------------------------------------
Total                                                                    18 MB/s | 180 kB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                1/1 
  Installing       : vsftpd-3.0.3-32.el8.x86_64                                                     1/1 
  Running scriptlet: vsftpd-3.0.3-32.el8.x86_64                                                     1/1 
  Verifying        : vsftpd-3.0.3-32.el8.x86_64                                                     1/1 

Installed:
  vsftpd-3.0.3-32.el8.x86_64                                                                            

Complete!

二:自建yum仓库的网络源(Centos8为例)

2.1首先在服务端配置好epel源

[root@hhw- 8]#cat /etc/yum.repos.d/base.repo
[epel]
name=EPEL
baseurl=http://mirrors.aliyun.com/epel/$releasever/Everything/$basearch
	http://mirrors.cloud.tencent.com//epel/$releasever/Everything/$basearch
	http://repo.huaweicloud.com/epel/$releasever/Everything/$basearch

gpgcheck=0
enabled=1

2.2 在服务端下载包和元数据

[root@hhw- html]#dnf reposync --repoid=epel --download-metadata -p /var/www/html

2.3 查看目录
[root@hhw- html]#cd epel/
[root@hhw- epel]#ls
Packages  repodata
[root@hhw- epel]#tree 
.
├── Packages
│   ├── 3
│   │   └── 3proxy-0.8.13-1.el8.x86_64.rpm
│   ├── a
│   │   ├── aalib-1.4.0-0.37.rc5.el8.x86_64.rpm
│   │   ├── aalib-devel-1.4.0-0.37.rc5.el8.x86_64.rpm
│   │   ├── aalib-libs-1.4.0-0.37.rc5.el8.x86_64.rpm
…………

2.4 给客户端配置epel源

[root@hhw832 yum.repos.d]#vi /etc/yum.repos.d/base.repo
[epel]
name=EPEL
baseurl=http://10.0.0.150:8080/epel

2.5 测试
[root@hhw832 yum.repos.d]#yum repolist -v
Loaded plugins: builddep, changelog, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, needs-restarting, playground, repoclosure, repodiff, repograph, repomanage, reposync
YUM version: 4.2.23
cachedir: /var/cache/dnf
BaseOS                                                                  3.8 MB/s | 3.9 kB     00:00    
AppStream                                                               2.3 MB/s | 4.3 kB     00:00    
EPEL                                                                    235 MB/s |  11 MB     00:00    
extras                                                                   34 kB/s |  11 kB     00:00
…………
Repo-id            : epel
Repo-name          : EPEL
Repo-revision      : 1650230875
Repo-updated       : Mon 18 Apr 2022 05:34:54 AM CST
Repo-pkgs          : 8,517
Repo-available-pkgs: 8,517
Repo-size          : 12 G
Repo-baseurl       : http://10.0.0.150:8080/epel
Repo-expire        : 172,800 second(s) (last: Tue 19 Apr 2022 01:10:39 PM CST)
Repo-filename      : /etc/yum.repos.d/base.repo

上面可以看到成功获取到epel源

三:编译安装http2.4。

3.1 下载httpd安装包

wget https://dlcdn.apache.org/httpd/httpd-2.4.53.tar.bz2

3.2 解压并且进入目录

tar xvf httpd-2.4.53.tar.bz2 
cd httpd-2.4.53/

3.3 执行configuer

[root@hhw832 httpd-2.4.53]#./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd --enable-ssl
…… 
checking for APR... no
configure: error: APR not found.  Please read the documentation.
发现有个报错,下载apr-devel包,并且重新执行configure
[root@hhw832 httpd-2.4.53]#yum -y install apr-devel
[root@hhw832 httpd-2.4.53]#./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd --enable-ssl
checking for APR-util... no
configure: error: APR-util not found.  Please read the documentation.
发现报错,下载apr-util-devel的包,重新执行
[root@hhw832 httpd-2.4.53]#yum -y install apr-util-devel
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/data/httpd-2.4.53':
configure: error: C compiler cannot create executables
See `config.log' for more details
下载gcc然后重新执行
[root@hhw832 httpd-2.4.53]#yum -y install gcc
[root@hhw832 httpd-2.4.53]#./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd --enable-ssl
checking for pcre-config... no
configure: error: pcre(2)-config for libpcre not found. PCRE is required and available from http://pcre.org/
下载pcre-devel,然后重新执行
[root@hhw832 httpd-2.4.53]#yum -y install pcre-devel
[root@hhw832 httpd-2.4.53]#./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd --enable-ssl
checking for OpenSSL version >= 0.9.8a... FAILED
configure: WARNING: OpenSSL version is too old
no
checking whether to enable mod_ssl... configure: error: mod_ssl has been requested but can not be built due to prerequisite failures
下载openssl重新执行
[root@hhw832 httpd-2.4.53]#yum -y install openssl-devel
[root@hhw832 httpd-2.4.53]#./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd --enable-ssl
然后无报错后执行make

3.4 执行make和make install

[root@hhw832 httpd-2.4.53]#make   
-bash: make: command not found
没有make,下载make后执行
[root@hhw832 httpd-2.4.53]#yum -y install make
[root@hhw832 httpd-2.4.53]#make
gcc: error: /usr/lib/rpm/redhat/redhat-hardened-ld: No such file or directory
make[4]: *** [/data/httpd-2.4.53/modules/aaa/modules.mk:2: mod_authn_file.la] Error 1
make[4]: Leaving directory '/data/httpd-2.4.53/modules/aaa'
make[3]: *** [/data/httpd-2.4.53/build/rules.mk:117: shared-build-recursive] Error 1
make[3]: Leaving directory '/data/httpd-2.4.53/modules/aaa'
make[2]: *** [/data/httpd-2.4.53/build/rules.mk:117: shared-build-recursive] Error 1
make[2]: Leaving directory '/data/httpd-2.4.53/modules'
make[1]: *** [/data/httpd-2.4.53/build/rules.mk:117: shared-build-recursive] Error 1
make[1]: Leaving directory '/data/httpd-2.4.53'
make: *** [/data/httpd-2.4.53/build/rules.mk:75: all-recursive] Error 1
发现报错,使用yum provides查找所需要的包
[root@hhw832 httpd-2.4.53]#yum provides /usr/lib/rpm/redhat/redhat-hardened-ld
Last metadata expiration check: 0:11:54 ago on Tue 19 Apr 2022 10:57:02 AM CST.
redhat-rpm-config-125-1.el8.noarch : Red Hat specific rpm configuration files
Repo        : AppStream
Matched from:
Filename    : /usr/lib/rpm/redhat/redhat-hardened-ld
下载redhat-rpm-config-125-1.el8.noarch后重新执行make
[root@hhw832 httpd-2.4.53]#yum -y install redhat-rpm-config-125-1.el8.noarch
[root@hhw832 httpd-2.4.53]#make
没有报错执行make install
[root@hhw832 httpd-2.4.53]#make install

3.5 配置环境变量并且启动服务验证

[root@hhw832 bin]#echo 'PATH=/apps/httpd/bin:$PATH' > /etc/profile.d/httpd.sh
[root@hhw832 bin]#. /etc/profile.d/httpd.sh
[root@hhw832 bin]#apachectl start

浏览器验证: image.png

四:ubuntu软件管理工具apt用法总结

下载[root@ubuntu httpd-2.4.53]#apt -y install tree	
卸载[root@ubuntu httpd-2.4.53]#apt remove tree          使用此条命令配置文件还在如果需要完全删除加上加--purge
更新包索引[root@ubuntu httpd-2.4.53]#apt update 					类似yum clean
列出仓库包[root@ubuntu httpd-2.4.53]#apt list 
查看文件来自哪个包[root@ubuntu1804 ~]#apt-file search -x '/sl$'       要先下载apt-file
查看包的详细信息[root@ubuntu httpd-2.4.53]#apt show wget
查看仓库中的软件版本[root@ubuntu httpd-2.4.53]##apt-cache madison docker-ce

五:sed命令用法

利用sed 取出ifconfig命令中本机的IPv4地址
[root@hhw- profile.d]#ifconfig ens160|sed -r -n 's/.*inet ([0-9.]+)  netmask.*/\1/p'
10.0.0.150
删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符
[root@hhw- profile.d]#cat /etc/fstab |sed  -r 's@^#[[:blank:]]+@@g'
处理/etc/fstab路径,使用sed命令取出其目录名和基名
[root@hhw- profile.d]#echo /etc/fstab |sed  -r -n 's@(/.*/)(.*)@\1@p'
/etc/
[root@hhw- profile.d]#echo /etc/fstab |sed  -r -n 's@(/.*/)(.*)@\2@p'
fstab