一、自建yum仓库,分别为网络源和本地源
#1 网络源
#1.1备份默认的yum配置到其他路径
[root@CentOS8 ~]# cd /etc/yum.repos.d
[root@CentOS8 yum.repos.d]# ls
CentOS-AppStream.repo CentOS-CR.repo CentOS-fasttrack.repo CentOS-PowerTools.repo
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-HA.repo CentOS-Sources.repo
CentOS-centosplus.repo CentOS-Extras.repo CentOS-Media.repo CentOS-Vault.repo
[root@CentOS8 yum.repos.d]# mkdir bk;mv *.repo bk
#1.2 配置yum网络源仓库
[root@CentOS8 yum.repos.d]# vi BaseOS.repo
[BaseOS]
name=BaseOS
baseurl=
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[root@CentOS8 yum.repos.d]# vi AppStream.repo
[AppStream]
name=AppStream
baseurl=
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
#1.3 安装软件,验证yum
[root@CentOS8 yum.repos.d]# yum repolist
repo idrepo name status
AppStream AppStream 5,059
BaseOS BaseOS 1,695
[root@CentOS8 yum.repos.d]# yum provides httpd
[root@CentOS8 yum.repos.d]# yum -y install httpd
[root@CentOS8 yum.repos.d]# rpm -qe httpd
httpd-2.4.37-30.module_el8.3.0+561+97fdbbcc.x86_64
#2 本地源(http方式)
#2.1 服务端配置
[root@repo-server ~]#systemctl stop firewalld.service
[root@repo-server ~]#systemctl status firewalld.service
[root@repo-server ~]#yum -y install httpd --安装httpd服务
[root@repo-server ~]#systemctl enable --now httpd;systemctl status httpd
[root@repo-server ~]#mkdir -pv /var/www/html/centos/8
mkdir: created directory '/var/www/html/centos'
mkdir: created directory '/var/www/html/centos/8'
[root@repo-server ~]#mount /dev/sr0 /var/www/html/centos/8
#2.2 客户端配置
[root@repo-client ~]# cd /etc/yum.repos.d/
[root@repo-client yum.repos.d]# mkdir bk;mv *.repo bk
[root@CentOS8 yum.repos.d]# vi BaseOS.repo
[BaseOS]
name=BaseOS
baseurl=file:///var/www/html/centos/8/BaseOS
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[root@CentOS8 yum.repos.d]# vi AppStream.repo
[AppStream]
name=AppStream
baseurl=file:///var/www/html/centos/8/AppStream
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[root@repo-client yum.repos.d]# yum repolist
二、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。
[root@CentOS8 httpd-2.4.46]#rpm -q httpd
package httpd is not installed
[root@CentOS8 ~]#wget -P /usr/local/src
[root@CentOS8 ~]#cd /usr/local/src/
[root@CentOS8 src]#ls
httpd-2.4.46.tar.bz2
[root@CentOS8 src]#tar xvf httpd-2.4.46.tar.bz2
[root@CentOS8 src]#cd httpd-2.4.46/
[root@CentOS8 httpd-2.4.46]#cat README
[root@CentOS8 httpd-2.4.46]#cat INSTALL
$ ./configure--prefix=PREFIX
$ make
$ makeinstall
$ PREFIX/bin/apachectlstart
[root@CentOS8 httpd-2.4.46]#yum -y install gcc make autoconf apr-devel apr-util-devel pcre-devel openssl-devel redhat-rpm-config
[root@CentOS8 httpd-2.4.46]#make -j 4 && make install
[root@CentOS8 httpd-2.4.46]#echo $?
[root@CentOS8 ~]#/apps/httpd24/bin/apachectl start
[root@CentOS8 bin]#systemctl stop firewalld.service
三、利用 sed 取出ifconfig命令中本机的IPv4地址
[root@CentOS8 ~]#ifconfig ens33 | sed -rn '2s/^[^0-9]+([0-9.]+) .*$/\1/p'
10.0.0.205
四、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符
删除前:
[root@CentOS8 ~]#cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Sun Feb 28 12:11:21 2021
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
UUID=19cfb9c8-bd59-4c52-8403-70527758bf86 / xfs defaults 0 0
UUID=ccb9e34d-a43a-4276-a697-d8ce684cd699 /bootext4 defaults 1 2
UUID=759de453-b2ff-4553-8e01-e830d2f2468f /dataxfs defaults 0 0
UUID=84faeb9d-3694-40bb-b0c9-f55047d09799 swap swap defaults 0 0
删除后:
[root@CentOS8 data]#sed -Ei.bak /^#./s/^#.// fstab;more fstab
#
/etc/fstab
Created by anaconda on Sun Feb 28 12:11:21 2021
#
Accessible filesystems, by reference, are maintained under '/dev/disk/'.
See manpages fstab(5), findfs(8), mount(8) and/orblkid(8) formoreinfo.
#
After editing this file, run 'systemctl daemon-reload'to update systemd
unitsgenerated from this file.
#
UUID=19cfb9c8-bd59-4c52-8403-70527758bf86 / xfs defaults 0 0
UUID=ccb9e34d-a43a-4276-a697-d8ce684cd699 /bootext4 defaults 1 2
UUID=759de453-b2ff-4553-8e01-e830d2f2468f /dataxfs defaults 0 0
UUID=84faeb9d-3694-40bb-b0c9-f55047d09799 swap swap defaults 0 0
五、处理/etc/fstab路径,使用sed命令取出其目录名和基名
[root@CentOS8 ~]#echo "/etc/fstab" |sed -r 's#(^/.*/)([^/]+/?)#\1#'
/etc/
[root@CentOS8 ~]#echo "/etc/fstab" | sed -rn 's#(.*)/([^/]+)/?#\2#p'
fstab