第四周 1、自建yum仓库,分别为网络源和本地源

1.安装httpd 
[root@lib yum.repos.d]#yum install httpd
2. 将光驱挂载到/var/www/html/centos 下,通过df 查看挂载情况。
[root@lib yum.repos.d]#df
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 997940 0 997940 0% /dev
tmpfs 1013948 14724 999224 2% /dev/shm
tmpfs 1013948 27072 986876 3% /run
tmpfs 1013948 0 1013948 0% /sys/fs/cgroup
/dev/sda2 104806400 4453716 100352684 5% /
/dev/sda5 52403200 32992 52370208 1% /data
/dev/sda1 999320 142836 787672 16% /boot
tmpfs 202792 36 202756 1% /run/user/1000
tmpfs 202792 0 202792 0% /run/user/0
/dev/sr0 9961428 9961428 0 100% /var/www/html/centos

3.通过浏览器查看

第四周_apache

4.编辑/etc/yum.repos.d/Centos-Base.repo
[base]
name=CentOS-8.5.2111 - Base - bendi
baseurl=http://10.0.0.150/centos/BaseOS/
# http://mirrors.aliyun.com/centos-vault/8.5.2111/BaseOS/$basearch/os/
# http://mirrors.aliyuncs.com/centos-vault/8.5.2111/BaseOS/$basearch/os/
# http://mirrors.cloud.aliyuncs.com/centos-vault/8.5.2111/BaseOS/$basearch/os/
gpgcheck=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official

[AppStream]
name=appstream
baseurl=http://10.0.0.150/centos/AppStream/
enabled=1
gpgcheck=0

5.查库
[root@lib yum.repos.d]#yum repolist -v
Loaded plugins: builddep, changelog, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, groups-manager, kpatch, needs-restarting, playground, repoclosure, repodiff, repograph, repomanage, reposync
YUM version: 4.7.0
cachedir: /var/cache/dnf
Repository extras is listed more than once in the configuration
CentOS-8.5.2111 - Base - bendi 74 MB/s | 2.6 MB 00:00
appstream 81 MB/s | 7.5 MB 00:00
Repo-id : AppStream
Repo-name : appstream
Repo-revision : 8.5.2111
Repo-distro-tags : [cpe:/o:centos:centos:8]: , 8, C, O, S, e, n, t
Repo-updated : Sat 13 Nov 2021 09:02:30 AM CST
Repo-pkgs : 6,165
Repo-available-pkgs: 5,281
Repo-size : 8.0 G
Repo-baseurl : http://10.0.0.150/centos/AppStream/
Repo-expire : 172,800 second(s) (last: Tue 29 Mar 2022 09:41:53 PM CST)
Repo-filename : /etc/yum.repos.d/CentOS-Base.repo

Repo-id : base
Repo-name : CentOS-8.5.2111 - Base - bendi
Repo-revision : 8.5.2111
Repo-distro-tags : [cpe:/o:centos:centos:8]: , 8, C, O, S, e, n, t
Repo-updated : Sat 13 Nov 2021 09:02:30 AM CST
Repo-pkgs : 1,709
Repo-available-pkgs: 1,707
Repo-size : 1.2 G
Repo-baseurl : http://10.0.0.150/centos/BaseOS/
Repo-expire : 172,800 second(s) (last: Tue 29 Mar 2022 09:41:53 PM CST)
Repo-filename : /etc/yum.repos.d/CentOS-Base.repo
Total packages: 7,874

2、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。

1.下载软件包
[root@lib data]#wget https://dlcdn.apache.org/httpd/httpd-2.4.53.tar.bz2
2.解压
[root@lib data]#tar xvf httpd-2.4.53.tar.bz2
3.进入软件目录,执行./configure
[root@lib httpd-2.4.53]#./configure
4.执行make 和make install
[root@lib httpd-2.4.53]#make && make install
5.设置命令apache2ctl 全局执行
[root@lib bin]#ln -s /usr/local/apache2/bin/apachectl /usr/local/bin/
[root@lib httpd-2.4.53]#cd /usr/local/bin
[root@lib bin]#ll
total 132
lrwxrwxrwx. 1 root root 32 Mar 29 11:41 apachectl -> /usr/local/apache2/bin/apachectl
-rwxr-xr-x. 1 root root 56544 Mar 29 09:14 cmatrix
-rwxr-xr-x. 1 root root 76808 Mar 29 08:07 tree
6.开启
[root@lib bin]#apachectl -k start

7.通过浏览器查看

第四周_centos_02

3、利用sed 取出ifconfig命令中本机的IPv4地址

[root@lib test]#ifconfig ens160|sed -nr '/mask/s/\s+\S+ ([0-9.]+).*/\1/gp'
10.0.0.154
[root@lib test]#ifconfig ens160|sed -nr '/mask/s/\s+\S+ ([0-9.]+).*/\1/p'
10.0.0.154

4、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符

[root@lib test]#cat /etc/fstab|sed -r 's/^#\s+(.*)/\1/p'

#
/etc/fstab
/etc/fstab
Created by anaconda on Wed Mar 2 09:46:31 2022
Created by anaconda on Wed Mar 2 09:46:31 2022
#
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.
#
UUID=295d1329-ef7b-4130-9b96-62600cc02edf / xfs defaults 0 0
UUID=0bcb6cf0-6ac6-4063-bf04-3662fa917e69 /boot ext4 defaults 1 2
UUID=003e3455-695e-4b06-a191-f489a66af92f /data xfs defaults 0 0
UUID=db3bca8c-0e62-402c-82e0-ec58908dd050 none swap defaults 0 0
[root@lib test]#

5、处理/etc/fstab路径,使用sed命令取出其目录名和基名

[root@lib test]#echo "/etc/fstab"|sed -nr 's#(.*)/([^/]+$)#\1\/#p'
/etc/
[root@lib test]#echo "/etc/fstab"|sed -nr 's#(.*)/([^/]+$)#\2#p'
fstab

6、列出ubuntu软件管理工具apt的一些用法(自由总结) apt 与 yum

第四周_sed_03