1、自建yum仓库,分别为网络源和本地源
[root@localhost ~]# mount /dev/sr0 /mnt/
[root@localhost yum.repos.d]# vim BaseOS.repo
[BaseOS]
name=BaseOS
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/8/BaseOS/x86_64/os/
baseurl=file:///mnt/BaseOS/
enable=1
gpgcheck=0
2、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。
#1 安装准备
[root@localhost data]# yum -y install gcc make pcre-devel openssl-devel expat-devel
[root@localhost data]# ls
apr-1.7.0.tar.bz2 apr-util-1.6.1.tar.bz2 httpd-2.4.46.tar.bz2
[root@localhost data]# tar xf apr-1.7.0.tar.bz2
[root@localhost data]# tar xf apr-util-1.6.1.tar.bz2
[root@localhost data]# tar xf httpd-2.4.46.tar.bz2
#2 将apr和apr-util源码与httpd源码合并
[root@localhost data]# mv apr-1.7.0 httpd-2.4.46/srclib/apr
[root@localhost data]# mv apr-util-1.6.1 httpd-2.4.46/srclib/apr-util
[root@localhost data]# ls httpd-2.4.46/srclib/
apr apr-util Makefile.in
#3 将三者合并编译并安装
[root@localhost data]#cd httpd-2.4.46/
[root@localhost httpd-2.4.46]# ./configure \
--prefix=/app/httpd24 \
--enable-so \
--enable-ssl \
--enable-cgi \
--enable-rewrite \
--with-zlib \
--with-pcre \
--with-included-apr \
--enable-modules=most \
--enable-mpms-shared=all \
--with-mpm=prefork
[root@localhost httpd-2.4.46]# make -j 4 && make install
#4 创建专用用户修改配置文件
[root@localhost ~]# useradd -s /sbin/nologin -r apache
[root@localhost ~]# sed -i.bak 's/^User .*/User apache/' /app/httpd24/conf/httpd.conf
[root@localhost ~]# sed -i 's/^Group .*/Group apache/' /app/httpd24/conf/httpd.conf
#5 配置环境变量
[root@localhost ~]# echo "PATH=/app/httpd24/bin:$PATH" >/etc/profile.d/httpd24.sh
#6 配置开机启动
[root@localhost ~]# echo /app/httpd24/bin/apachectl start >> /etc/rc.d/rc.local
[root@localhost ~]# chmod +x /etc/rc.d/rc.local
#7 启动服务
[root@localhost ~]# /app/httpd24/bin/apachectl start
#测试
[root@localhost ~]# curl 172.16.0.38
<html><body><h1>It works!</h1></body></html>
3、利用sed 取出ifconfig命令中本机的IPv4地址
[root@localhost ~]# ifconfig | sed -nr 's/.*inet (([0-9]+\.?){4}) .*/\1/p'
[root@localhost ~]# ip addr | awk -F"[ /]" '/ *inet /{print $6}'
4、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符
[root@localhost ~]# sed -i.bak '/^# /d' /etc/fstab
5、处理/etc/fstab路径,使用sed命令取出其目录名和基名
[root@localhost ~]# ls /etc/fstab | sed -nr 's#(/etc)/fstab#\1#p'
/etc
[root@localhost ~]# ls /etc/fstab | sed -nr 's#/etc/(fstab)#\1#p'
fstab