1、自建yum仓库,分别为网络源和本地源
[root@repo-client ~]#vim /etc/yum.repos.d/CentOS-Base.repo
[BaseOS]
name=BaseOS
baseurl=file:///misc/cd/
https://mirrors.aliyun.com/centos/$releasever/os/$basearch
gpgcheck=0
[epel]
name=epel
baseurl=https://mirrors.aliyun.com/epel/$releasever/$basearch
gpgcheck=1
pgpkey=https://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-7
[extras]
name=extras
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch
pgpcheck=0
2、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。
#安装前准备:关闭防火墙和SELinux
#1 安装包
[root@centos8 ~]#dnf install gcc make apr-devel apr-util-devel pcre-devel openssl-devel redhat-rpm-config bzip2 lsof
#进入想要安装包的路径
[root@centos8 src]cd /usr/local/src
#下载安装包
[root@centos8 src]#wget https://mirrors.bfsu.edu.cn/apache//httpd/httpd-2.4.46.tar.bz2
#2 下载并解压缩包,-C指定安装路径
[root@centos8 ~]#tar xvf httpd-2.4.43.tar.bz2 -C /usr/local/src
#3 配置
[root@centos8 ~]#cd /usr/local/src/httpd-2.4.43/
[root@centos8 httpd-2.4.43]#./configure --prefix=/apps/httpd24 --sysconfdir=/etc/httpd24 --enable-ssl
#4 编译并安装
[root@centos8 httpd-2.4.43]#make -j 4 && make install
#5 配置环境
[root@centos8 ~]#echo 'PATH=/apps/httpd24/bin:$PATH' > /etc/profile.d/httpd24.sh
[root@centos8 ~]#. /etc/profile.d/httpd24.sh
#6运行
[root@centos8 ~]#apachectl
#如果出现端口被占用情况,找出占用端口的进程杀死
[root@Centos7 httpd-2.4.46]# lsof -i :80
[root@Centos7 httpd-2.4.46]# kill -9 1304
#7 指定用apache用户运行
[root@centos8 ~]#useradd -r -s /sbin/nologin -d /var/www -c Apache -u 48 apache
[root@centos8 ~]#vim /etc/httpd24/httpd.conf
user apache
group apache
#8生效和验证
[root@centos8 ~]#apachectl restart
#查看
[root@centos8 ~]#ps aux
验证结果:
3、利用sed 取出ifconfig命令中本机的IPv4地址
[root@Centos7 ~]# ifconfig | sed -nr '2s/(.*inet )([0-9].*)( netmask.*)/\2/p'
10.154.119.140
4、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符
[root@Centos7 ~]# sed -n '/^#/s/^#//!p' /etc/fstab
UUID=3089f417-1bba-4347-8f21-a4581fce760a / xfs defaults 0 0
UUID=71afae2d-2416-4c68-8375-e27437e32fa3 /boot xfs defaults 0 0
UUID=bb537f14-b824-402e-81c3-63b87a82052a /data xfs defaults 0 0
UUID=bb38c0b6-b4b3-41b8-96f9-30af2315226c swap swap defaults 0 0
5、处理/etc/fstab路径,使用sed命令取出其目录名和基名
#取目录名
[root@Centos7 ~]# echo /etc/fstab |sed -r 's#(^/.*/)([^/]+/?)#\1#'
/etc/
#取基名
[root@Centos7 ~]# echo /etc/fstab |sed -r 's#(^/.*/)([^/]+/?)#\2#'
fstab