第六周作业
1、自建yum仓库,分别为网络源和本地源
cat >> /etc/yum.repo.d/ali.repo <<-EOF
#net阿里源
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-8
EOF
cat >> /etc/yum.repo.d/local.repo <<-EOF
#cenos8local源
[BaseOS]
name=BaseOS
baseurl=file:///media/centos/img/BaseOS/
gpgcheck=0
[AppStream]
name=AppStream
baseurl=file:///media/centos/img/AppStream/
gpgcheck=0
EOF
2、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。
2.1,前往官网http://httpd.apache.org/download.cgi#apache24下载源码包
[root@explore ~]# wget https://mirrors.bfsu.edu.cn/apache//httpd/httpd-2.4.46.tar.bz2
2.2,配置yum源后安装编译工具及常用工具包
[root@explore ~]# yum install -y gcc make autoconf gcc-c++ glibc glibc-devel pcre pcre-devel openssl openssl-devel systemd-devel zlib-devel vim lrzsz tree tmux lsof tcpdump wget net-tools iotop bc bzip2 zip unzip nfs-utils man-pages
2.3,解压源码包
[root@explore ~]# tar xf httpd-2.4.46.tar.bz2
2.4,进入该目录,进行编译
[root@explore httpd-2.4.46]# ./configure --sysconfdir=/etc/httpd/ --prefix=/data/httpd/ --enable-ssl
checking for APR... no
configure: error: APR not found. Please read the documentation.
[root@explore httpd-2.4.46]#
#报错安装对应依赖包
[root@explore ~]# yum install apr apr-util apr-devel -y
#报错
checking for APR-util... no
configure: error: APR-util not found. Please read the documentation.
#解决
yum install -y apr-util-devel.x86_64
#再次执行
[root@explore httpd-2.4.46]# ./configure --sysconfdir=/etc/httpd/ --prefix=/data/httpd/ --enable-ssl
#完成
config.status: executing default commands
configure: summary of build options:
Server Version: 2.4.46
Install prefix: /data/httpd/
C compiler: gcc -std=gnu99
CFLAGS: -pthread
CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE
LDFLAGS:
LIBS:
C preprocessor: gcc -E
2.5,编译
[root@explore httpd-2.4.46]# make && make install
Installing configuration files
mkdir /etc/httpd
mkdir /etc/httpd/extra
mkdir /etc/httpd/original
mkdir /etc/httpd/original/extra
Installing HTML documents
mkdir /data/httpd/htdocs
Installing error documents
mkdir /data/httpd/error
Installing icons
mkdir /data/httpd/icons
mkdir /data/httpd/logs
Installing CGIs
mkdir /data/httpd/cgi-bin
Installing header files
mkdir /data/httpd/include
Installing build system files
mkdir /data/httpd/build
Installing man pages and online manual
mkdir /data/httpd/man
mkdir /data/httpd/man/man1
mkdir /data/httpd/man/man8
mkdir /data/httpd/manual
make[1]: Leaving directory `/root/httpd-2.4.46'
2.6,配置环境变量
[root@explore httpd-2.4.46]# echo "PATH=/data/httpd/bin/:$PATH" >> /etc/profile.d/httpd.sh
2.7,配置man帮助手册
vim /etc/man_db.conf
ANDATORY_MANPATH /data/httpd/man
2.8,运行
[root@explore httpd-2.4.46]# . /etc/profile.d/httpd.sh
[root@explore httpd-2.4.46]# apachectl
#报错httpd: Could not reliably determine the server's fully qualified domain name,
#讲httpd.com中的此行注释ServerAdmin you@example.com
2.9,访问

3、利用sed 取出ifconfig命令中本机的IPv4地址
[root@explore httpd-2.4.46]# ifconfig | sed -nE 's@inet (([[:digit:]]|\.)*).*@\1@p'
4、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符
[root@explore httpd-2.4.46]# sed -Ei.ba 's@(^#[[:space:]])(.*)+@\2@' /etc/fstab
[root@explore httpd-2.4.46]# cat /etc/fstab
1233121
#
/etc/fstab
Created by anaconda on Mon Dec 14 16:49:57 2020
#
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
#
UUID=499b30df-feee-4dfd-83cb-537b28f62e11 / xfs defaults 0 0
UUID=d6010ed1-d508-4ace-8f9e-5ef958eecd5b /boot xfs defaults 0 0
UUID=65b0f8d3-87fa-4c40-a17c-44b911fe69a6 /home xfs defaults 0 0
UUID=4fdab4d6-af34-4b77-b620-6f534ab3e761 swap swap defaults 0 0
/dev/cdrom /mnt/ iso9660 defaults 0 0
5、处理/etc/fstab路径,使用sed命令取出其目录名和基名
#目录名
[root@exploere2 ~]# echo /etc/fstab | sed -nE "s@(/.*/+)(.*)@\1@p"
#基名
[root@exploere2 ~]# echo /etc/fstab | sed -nE "s@(/.*/+)(.*)@\2@p"

浙公网安备 33010602011771号