第四周-练习

Posted N64_一只慵懒的猫

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了第四周-练习相关的知识,希望对你有一定的参考价值。

1、自建yum仓库,分别为网络源和本地源 自建网络源 1).先去官网下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/

链接:​centos​​​​阿里巴巴开源镜像站​​ 2).参照CentOS-Base.repo内容,注释AppStream.repo和BaseOS.repo原有的name及bashurl ,复制新增CentOS-Base.repo内的

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-8.5.2111 - Base - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/BaseOS/x86_64/os/
gpgcheck=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official

#additional packages that may be useful
[extras]
name=CentOS-8.5.2111 - Extras - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/extras/x86_64/os/
gpgcheck=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-8.5.2111 - Plus - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/centosplus/x86_64/os/
gpgcheck=0
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official

[PowerTools]
name=CentOS-8.5.2111 - PowerTools - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/PowerTools/x86_64/os/
gpgcheck=0
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official


[AppStream]
name=CentOS-8.5.2111 - AppStream - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/AppStream/x86_64/os/
gpgcheck=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official


[09:38:48 root@centos8 yum.repos.d][#cat CentOS-Linux-AppStream.repo
# CentOS-Linux-AppStream.repo
#
# The mirrorlist system uses the connecting IP address of the client and the
# update status of each mirror to pick current mirrors that are geographically
# close to the client. You should use this for CentOS updates unless you are
# manually picking other mirrors.
#
# If the mirrorlist does not work for you, you can try the commented out
# baseurl line instead.

[appstream]
name=CentOS-8.5.2111 - AppStream - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/AppStream/x86_64/os/
#name=CentOS Linux 8 - AppStream
#mirrorlist=http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$releasever/AppStream/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[09:39:36 root@centos8 yum.repos.d][#cat CentOS-Linux-BaseOS.repo
# CentOS-Linux-BaseOS.repo
#
# The mirrorlist system uses the connecting IP address of the client and the
# update status of each mirror to pick current mirrors that are geographically
# close to the client. You should use this for CentOS updates unless you are
# manually picking other mirrors.
#
# If the mirrorlist does not work for you, you can try the commented out
# baseurl line instead.

[baseos]
name=CentOS-8.5.2111 - Base - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/BaseOS/x86_64/os/
#name=CentOS Linux $releasever - BaseOS
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=BaseOS&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$releasever/BaseOS/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

3).运行 yum makecache 生成缓存

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

[12:23:43 root@centos8 ~][#dnf -y install gcc make autoconf apr-devel apr-util-devel pcre-devel openssl-devel redhat-rpm-config

去​​Download - The Apache HTTP Server Project​​下载安装包 ![image-20220327123358322](D:\\Lei\\SRE\\homework\\第四周\\第四周作业.assets\\image-20220327123358322.png) 然后放进虚拟机进行解压

[12:45:02 root@centos8 <sub>][#rz -E
rz waiting to receive.
[12:45:29 root@centos8 </sub>][#ls
anaconda-ks.cfg dead.letter file httpd-2.4.53.tar.bz2 mail.txt str.txt

#如果没有rz工具的话要先安装工具
yum -y install lrzsz

#解压
[14:42:03 root@centos8 ~][#tar xvf httpd-2.4.53.tar.bz2

#进入压缩目录
[14:45:03 root@centos8 httpd-2.4.53][#cd httpd-2.4.53/

#配置编译安装
[14:45:03 root@centos8 httpd-2.4.53][#./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd --enable-ssl
[14:47:38 root@centos8 httpd-2.4.53][#make -j 4 && make install

#配置环境
echo PATH=/apps/httpd/bin:$PATH > /etc
[15:03:52 root@centos8 httpd-2.4.53][#echo PATH=/apps/httpd/bin:$PATH > /etc/profile.d/httpd.sh
[15:03:52 root@centos8 httpd-2.4.53][#. /etc/profile.d/httpd.sh

#运行
[15:03:52 root@centos8 httpd-2.4.53][#apachectl start

![image-20220327151420873](D:\\Lei\\SRE\\homework\\第四周\\第四周作业.assets\\image-20220327151420873.png)

第四周-练习_centos

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

[15:43:35 root@centos8 ~][#ifconfig ens160 | sed -nr "2s/[^0-9]+([0-9.]+).*/\\1/p"

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

[16:05:32 root@centos8 ~][#sed -ri.bak s/^#[[:space:]]+(.*$)/\\1/g /etc/fstab

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

[16:19:37 root@centos8 <sub>][#echo "/etc/fstab" | sed -r s#(.*)/([^/]+/?)#\\1#
[16:19:42 root@centos8 </sub>][#echo "/etc/fstab" | sed -r s#(.*)/([^/]+/?)#\\2#

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

apt install     #安装软件包----------(常用)
apt remove #移除软件包
apt update #升级包
apt list #列出包含条件的包。包括已安装,可升级的包等
apt search #查看安装包的详细信息
apt update #更新本地软件包索引
apt upgrade #升级所有已安装的可升级新版本的软件包
apt full-upgrade #升级整个系统

以上是关于第四周-练习的主要内容,如果未能解决你的问题,请参考以下文章

第四周练习

寒假练习题解 第四周 2.8-2.14

第四周上机练习

第四周上级练习

第四周上级练习

第四周上机练习