第六周作业
1、自建yum仓库,分别为网络源和本地源
本地
vim /etc/yum.repos.d/base.repo
[root@centos8 ~]# yum -y install autofs
[root@centos8 ~]# systemctl enable autofs --now
[root@centos8 ~]#vim /etc/yum.repos.d/base.repo
[base]
name=cdrom base
baseurl=file:///misc/cd
gpgcheck=1
gpgkey=file:///misc/cd/RPM-GPG-KEY-Centos-7
网络
yum仓库配置
[root@centos8 ~]#yum -y install httpd
[root@centos8 ~]#systemctl enable --now httpd
[root@centos8 ~]#mkdir /var/www/html/centos/8 -pv
[root@centos8 ~]#mount /dev/sr0 /mnt/
[root@centos8 ~]#cp -a /mnt/* /var/www/html/centos/8
客户端配置
[root@repo-client ~]#vim /etc/yum.repos.d/test.repo
[BaseOS]
name=BaseOS
baseurl=http://10.0.0.8/centos/8/BaseOS
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[AppStream]
name=Appstream
baseurl=http://10.0.0.8/centos/8/AppStream/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
#yum clean all
#yum makecache
#yum repolist
2、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。
安装前准备:关闭防火墙和SELinux
安装包
[root@centos8 ~]#dnf install gcc make apr-devel apr-util-devel pcre-devel openssl-devel redhat-rpm-config
下载并解压缩包
[root@centos8 ~]#tar xvf httpd-2.4.43.tar.bz2 -C /usr/local/src
配置
[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
编译并安装
[root@centos8 httpd-2.4.43]#make -j 4 && make install
配置环境
[root@centos8 ~]#echo 'PATH=/apps/httpd24/bin:$PATH' > /etc/profile.d/httpd24.sh
[root@centos8 ~]#. /etc/profile.d/httpd24.sh
运行
[root@centos8 ~]#apachectl
指定用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
生效和验证
[root@centos8 ~]#apachectl restart
查看
[root@centos8 ~]#ps aux
3、利用sed 取出ifconfig命令中本机的IPv4地址
[18:47:59 root@etcd3 ~]#ifconfig ens33 |sed -nr "2s/[^0-9]+([0-9.]+).*/\1/p"
10.0.0.28
4、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符
[19:05:08 root@etcd3 ~]#cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Thu Feb 4 20:15:42 2021
#
# 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.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
UUID=642d007c-6670-4c6f-828f-054866c78a31 / xfs defaults 0 0
UUID=d748f17d-7af2-4187-a919-bcbdfc3267e3 /boot ext4 defaults 1 2
#UUID=5847e7d9-47ab-4d4a-8179-ffd024a2fa99 swap swap defaults 0 0
[19:05:32 root@etcd3 ~]#cat /etc/fstab |sed -r 's/^#\ ?(.*)/\1/'|sed '/^$/d'
/etc/fstab
Created by anaconda on Thu Feb 4 20:15:42 2021
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.
After editing this file, run 'systemctl daemon-reload' to update systemd
units generated from this file.
UUID=642d007c-6670-4c6f-828f-054866c78a31 / xfs defaults 0 0
UUID=d748f17d-7af2-4187-a919-bcbdfc3267e3 /boot ext4 defaults 1 2
UUID=5847e7d9-47ab-4d4a-8179-ffd024a2fa99 swap swap defaults 0 0
[19:05:46 root@etcd3 ~]#
5、处理/etc/fstab路径,使用sed命令取出其目录名和基名
取目录名
[19:07:37 root@etcd3 ~]#echo "/etc/fstab" |sed -r 's#(^/.*/)([^/]+/?)#\1#'
/etc/
取基名
[19:05:46 root@etcd3 ~]#echo "/etc/fstab" |sed -r 's#(^/.*/)([^/]+/?)#\2#'
fstab