1、自建yum倉庫,分別為網(wǎng)絡(luò)源和本地源
[root@Top ~]# cat /etc/yum.repos.d/centos8.repo #yum本地光盤源
[AppStream]
name=appstream
gpgcheck=1
baseurl=file:///mnt/AppStream
gpgkey=/etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
yum -y install httpd #安裝httpd,搭建yum倉庫網(wǎng)絡(luò)源
systemctl enable --now httpd #啟動服務(wù)
mkdir /var/www/html/centos/8 -pv
mount /dev/sr0 /mnt/
cp -a /mnt/* /var/www/html/centos/8/ #cp光盤源到http自建目錄里
? 15:31:40-root:/etc/yum.repos.d# cat local.repo #編輯yum源配置文件,路徑指向遠(yuǎn)程服務(wù)器
[AppStream]
name=AppStream
baseurl=http://10.0.0.8/centos/8/AppStream/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[BaseOS]
name=BaseOS
baseurl=http://10.0.0.8/centos/8/BaseOS/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
2、編譯安裝http2.4,實(shí)現(xiàn)可以正常訪問,并將編譯步驟和結(jié)果提交
3324 14:38:14 2021-01-02 root tar xvf httpd-2.4.46.tar.bz2
3326 14:38:26 2021-01-02 root cd httpd-2.4.46/
3328 14:38:39 2021-01-02 root cat README
3329 14:38:57 2021-01-02 root cat INSTALL
3331 14:43:09 2021-01-02 root ./configure --prefix=/usr/local/src/http-2.4.46 --sysconfdir=/etc/http-2.4.46 --enable-ssl
3332 14:43:18 2021-01-02 root dnf list ARP
3333 14:43:24 2021-01-02 root dnf list arp
3334 14:43:34 2021-01-02 root dnf search arp
3335 14:43:56 2021-01-02 root yum -y install arpack-devel.x86_64
3341 14:47:01 2021-01-02 root yum search arp
3342 14:47:13 2021-01-02 root yum provides arp
3343 14:47:48 2021-01-02 root yum -y install net-tools-2.0-0.52.20160912git.el8.x86_64
3344 14:48:00 2021-01-02 root ./configure --prefix=/usr/local/src/http-2.4.46 --sysconfdir=/etc/http-2.4.46 --enable-ssl
3345 14:48:24 2021-01-02 root cat README
3346 14:48:34 2021-01-02 root cat README|grep *apr
3347 14:48:45 2021-01-02 root yum search apr
3348 14:49:13 2021-01-02 root yum -y install apr-util-devel.x86_64
3349 14:49:28 2021-01-02 root ./configure --prefix=/usr/local/src/http-2.4.46 --sysconfdir=/etc/http-2.4.46 --enable-ssl
3350 14:49:43 2021-01-02 root yum search PCRE
3351 14:50:05 2021-01-02 root yum -y install pcre-devel
3352 14:50:13 2021-01-02 root ./configure --prefix=/usr/local/src/http-2.4.46 --sysconfdir=/etc/http-2.4.46 --enable-ssl
3353 14:50:49 2021-01-02 root yum search OpenSSL
3354 14:51:06 2021-01-02 root yum -y install openssl-devel
3355 14:51:32 2021-01-02 root ./configure --prefix=/usr/local/src/http-2.4.46 --sysconfdir=/etc/http-2.4.46 --enable-ssl
3356 14:51:43 2021-01-02 root echo $?
3357 14:51:51 2021-01-02 root sync
3358 14:51:54 2021-01-02 root history
3359 14:52:10 2021-01-02 root cd ..
3360 14:52:16 2021-01-02 root rm -rf httpd-2.4.46
3361 14:52:26 2021-01-02 root tar xf httpd-2.4.46.tar.bz2
3362 14:52:29 2021-01-02 root cd httpd-2.4.46/
3363 14:52:30 2021-01-02 root ll
3364 14:52:36 2021-01-02 root ./configure --prefix=/usr/local/src/http-2.4.46 --sysconfdir=/etc/http-2.4.46 --enable-ssl
3365 14:52:45 2021-01-02 root make
3366 14:53:22 2021-01-02 root yum provides redhat-hardened-ld
3375 14:56:39 2021-01-02 root yum -y install redhat-rpm-config
3376 14:56:48 2021-01-02 root make
3377 14:57:43 2021-01-02 root echo $?
3378 14:57:59 2021-01-02 root cd ..
3379 14:58:04 2021-01-02 root rm -rf httpd-2.4.46
3380 14:58:10 2021-01-02 root tar xf httpd-2.4.46.tar.bz2
3381 14:58:14 2021-01-02 root cd httpd-2.4.46/
3383 14:58:34 2021-01-02 root ./configure --prefix=/usr/local/src/http-2.4.46 --sysconfdir=/etc/http-2.4.46 --enable-ssl;echo $?
3384 14:58:54 2021-01-02 root make;echo$?
3385 15:00:04 2021-01-02 root cat INSTALL
3386 15:00:17 2021-01-02 root make install
3387 15:00:36 2021-01-02 root echo $?
3396 15:08:52 2021-01-02 root ./apachectl start
? 15:22:18-root:/usr/local/src/http-2.4.46/htdocs# vim index.html #編輯html頁面
驗(yàn)證如下:

image-20210102152634372.png
3、利用sed 取出ifconfig命令中本機(jī)的IPv4地址
? 21:09:02-root:/date# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.0.8 netmask 255.255.255.0 broadcast 10.0.0.255
inet6 fe80::20c:29ff:fed1:8fd8 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:d1:8f:d8 txqueuelen 1000 (Ethernet)
RX packets 69652 bytes 41271637 (39.3 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 38677 bytes 5856322 (5.5 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
? 21:09:08-root:/date# ifconfig eth0|sed -rn '2s/^[^0-9]+([0-9.]+) .*/\1/p'
10.0.0.8
4、刪除/etc/fstab文件中所有以#開頭,后面至少跟一個空白字符的行的行首的#和空白字符
? 23:01:11-root:/date# sed -ri.bak 's/(^# )+(.*)/\2/p' fstab
? 23:03:00-root:/date# cat -A fstab
$
#$
/etc/fstab$
/etc/fstab$
Created by anaconda on Sun Nov 8 13:09:51 2020$
Created by anaconda on Sun Nov 8 13:09:51 2020$
#$
Accessible filesystems, by reference, are maintained under '/dev/disk/'.$
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.$
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$
After editing this file, run 'systemctl daemon-reload' to update systemd$
units generated from this file.$
units generated from this file.$
#$
/dev/mapper/cl-root / xfs defaults 0 0$
UUID=29090182-4327-42a5-8b5e-1593be1da80e /boot ext4 defaults 1 2$
/dev/mapper/cl-date /date xfs defaults 0 0$
/dev/mapper/cl-swap swap swap defaults 0 0$
5、處理/etc/fstab路徑,使用sed命令取出其目錄名和基名
? 22:21:54-root:/date# echo /etc/fstab |sed -r 's#(^/.*/)([^/]+/?)#\1#'
/etc/
? 22:22:03-root:/date# echo /etc/fstab |sed -r 's#(^/.*/)([^/]+/?)#\2#'
fstab
#以下是我看到別的師兄寫的取基民和目錄名,很好理解,就是簡單把一個文件路徑分為(.*/)(.*)兩部分,想要哪部分,就留哪部分。很清晰,便于理解(實(shí)測發(fā)現(xiàn),^可以不要,也能實(shí)現(xiàn))
? 22:26:16-root:/date# echo /etc/sysconfig/network-scripts/ifcfg-eth1-test | sed -r 's#(^.*)/(.*)#\1#'
/etc/sysconfig/network-scripts
? 22:29:21-root:/date# echo /etc/sysconfig/network-scripts/ifcfg-eth1-test | sed -r 's#(^.*)/(.*)#\2#'
ifcfg-eth1-test