第六周
1、自建yum仓库,分别为网络源和本地源
[root@repo-server ~]# cat /etc/yum.repos.d/baseOS.repo
[base]
name=BaseOS
baseurl=file:///misc/cd/BaseOS
https://mirrors.aliyun.com/centos/8/BaseOS/x86_64/os/
gpgcheck=0
[AppStream]
name=AppStream
baseurl=file:///misc/cd/AppStream
https://mirrors.aliyun.com/centos/8/AppStream/x86_64/os/
gpgcheck=0
[root@repo-server ~]#
2、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。
- 从官网下载软件包到本地目录/usr/local/src
wget -P /usr/local/src https://ftp.wayne.edu/apache//httpd/httpd-2.4.46
- 由于是最小化安装,编译是缺少必要的包,需要安装
dnf -y install apr-devel apr-util-devel
yum -y install pcre-devel
dnf install -y openssl-devel
- 选择安装目录在/apps/httpd,配置文件目录/etc/httpd,启用ssl.(查看configure的选项,可以运行
./configure --help
)
./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd --enable-ssl
配置成功后显示
configure: summary of build options:
Server Version: 2.4.46
Install prefix: /apps/httpd
C compiler: gcc
CFLAGS: -pthread
CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE
LDFLAGS:
LIBS:
C preprocessor: gcc -E
[root@centos8 httpd-2.4.46] \$echo \$?
0
[root@centos8 httpd-2.4.46]$
- 开始编译,-j选择是选择多个线程
make -j 4 && make install
有报错gcc: error: /usr/lib/rpm/redhat/redhat-hardened-ld: No such file or directory
//查询缺少的文件属于哪个包文件
[root@centos8 httpd-2.4.46]$yum provides /usr/lib/rpm/redhat/redhat-hardened-ld
Last metadata expiration check: 0:25:46 ago on Sun 03 Jan 2021 10:06:35 AM CST.
redhat-rpm-config-120-1.el8.noarch : CentOS specific rpm configuration files
Repo : MyAppStream
Matched from:
Filename : /usr/lib/rpm/redhat/redhat-hardened-ld
//安装缺少的包
[root@centos8 httpd-2.4.46]$yum -y install redhat-rpm-config-120-1.el8.noarch
//继续安装
[root@centos8 httpd-2.4.46]make -j 4 && make install
- 根据INSTALL文件提示,要运行PREFIX/bin/apachectl start,安装完成。
$ ./configure --prefix=PREFIX
$ make
$ make install
$ PREFIX/bin/apachectl start
[root@centos8 bin]$./apachectl start
[root@centos8 bin]$ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
[root@centos8 bin]$curl http://localhost
<html><body><h1>It works!</h1></body></html>
3、利用sed 取出ifconfig命令中本机的IPv4地址
[root@centos8 data]$ifconfig eth0 |sed -En '2s/(^ *inet )([0-9.]*)( .*$)/\2/p'
10.0.0.8
4、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符
[root@centos8 data]$cat /etc/fstab|sed -E 's/(^# )(.*)/\2/'
#
/etc/fstab
Created by anaconda on Tue Oct 27 17:54:45 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.
#
After editing this file, run 'systemctl daemon-reload' to update systemd
units generated from this file.
#
UUID=c970ffb7-8e3a-4b64-8014-c21e125be6d5 / xfs defaults 0 0
UUID=81f38a9b-5532-4606-9147-44ab13b72f13 /boot ext4 defaults 1 2
UUID=b2c38bd9-642f-4660-8115-d50f51450d3a /data xfs defaults 0 0
UUID=498e6700-939f-4a48-8f6a-6f7708c7a902 swap swap defaults 0 0
5、处理/etc/fstab路径,使用sed命令取出其目录名和基名
root@centos8 data]$echo '/etc/fstab'|sed -E 's@(^/.*/)([^/]+/?)@\2@'
fstab
[root@centos8 data]$echo '/etc/fstab'|sed -E 's@(^/.*/)([^/]+/?)@\1@'
/etc/