第四周homework
作者:互联网
一、自建yum仓库,分别为网络源和本地源
1、备份当前yum源配置文件
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
CentOS-Base.repo CentOS-fasttrack.repo CentOS-Vault.repo mysql-community.repo
CentOS-CR.repo CentOS-Media.repo CentOS-x86_64-kernel.repo mysql-community-source.repo
CentOS-Debuginfo.repo CentOS-Sources.repo docker-ce.repo zabbix.repo
[root@localhost yum.repos.d]# cp CentOS-Base.repo CentOS-Base.repo.bak
[root@localhost yum.repos.d]# ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Sources.repo docker-ce.repo zabbix.repo
CentOS-Base.repo.bak CentOS-fasttrack.repo CentOS-Vault.repo mysql-community.repo
CentOS-CR.repo CentOS-Media.repo CentOS-x86_64-kernel.repo mysql-community-source.repo
[root@localhost yum.repos.d]#
2、 编辑CentOS-Base.repo
[root@localhost yum.repos.d]# cat 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 = cdrom base
baseurl = file:///misc/cd
gpgcheck = 0
[base]
name=CentOS-$releasever
baseurl=https://mirrors.aliyun.com/centos/$releasever/os/$basearch/
https://mirrors.cloud.tencent.com/centos/$releasever/os/$basearch/
https://repo.huaweicloud.com/centos/$releasever/os/$basearch/
https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
https://mirrors.cloud.tencent.com/centos/$releasever/updates/$basearch/
https://repo.huaweicloud.com/centos/centos/$releasever/updates/$basearch/
https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
https://mirrors.cloud.tencent.com/centos/$releasever/extras/$basearch/
https://repo.huaweicloud.com/centos/$releasever/extras/$basearch/
https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
https://mirrors.cloud.tencent.com/centos/$releasever/centosplus/$basearch/
https://repo.huaweicloud.com/centos/$releasever/centosplus/$basearch/
https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
https://mirrors.cloud.tencent.com/centos/$releasever/contrib/$basearch/
https://repo.huaweicloud.com/centos/$releasever/contrib/$basearch/
https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
3、yum源建立之后如果想要立刻使用,需要清空之前yum源的缓存,重新建立新yum源缓存
3.1、yum clean all #清空缓存
3.2、yum makecache #建立新缓存
3.3、yum repolist #查看yum源列表
二、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。
1、下载
wget http://mirror.sohu.com/apache/httpd-2.4.49.tar.gz
2、解压
tar -zxvf httpd-2.4.49.tar.gz
3、移动到httpd24目录
mv httpd-2.4.49 httpd24
4、安装依赖包
yum install gcc openssl-devel pcre-devel apr-devel apr-util-devel -y
5、配置
./configure --prefix=/home/app/httpd --sysconfdir=/etc/httpd --enable-ssl --enable-so
6、编译&&安装
make && make install
7、设置全局变量
echo 'PATH=/home/app/httpd/bin:$PATH' > /etc/profile.d/httpd.sh
. /etc/profile.d/httpd.sh
8、启动服务
apachectl start
9、修改httpd.conf服务器ip地址
10、验证服务
三、利用sed 取出ifconfig命令中本机的IPv4地址
ifconfig ens33 | sed -n '/inet /s#\(.*inet \)\(.*\)\( n.*\)#\2#gp'
4、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符
sed 's@^#[[:space:]]\+@@' /etc/fstab
5、处理/etc/fstab路径,使用sed命令取出其目录名和基名
echo "/etc/fstab" |sed -r 's#^/(.*)/(.*)#\1#'
etc
echo "/etc/fstab" |sed -r 's#^/(.*)/(.*)#\2#'
fstab
6、列出ubuntu软件管理工具apt的一些用法
安装软件包:apt-get install <Package Name>
删除软件包:apt-get remove <Package Name>
更新软件包列表:apt-get update
升级有可用更新的系统(慎用):apt-get upgrade
搜索:apt-get search <Package Name>
获取包信息:apt-get show <Package Name>
删除包及配置文件:apt-get remove <Package Name> --purge
了解使用依赖:apt-get depends <Package Name>
查看被那些包依赖:apt-cache rdepends <Package Name>
安装相关的编译环境:apt-get build-dep <Package Name>
下载源代码:apt-get source <Package Name>
标签:CentOS,centos,mirrors,basearch,repo,releasever,四周,homework 来源: https://www.cnblogs.com/starsong007/p/15334542.html