1.自建yum仓库,分别为网络源和本地源。
阿里云镜像网站:https://developer.aliyun.com/mirror/centos?spm=a2c6h.13651102.0.0.3e221b11c8B5ge
# 先备份系统默认yum文件
[root@bogon yum.repos.d]# mkdir bak
[root@bogon yum.repos.d]# mv ./*.repo bak/
[root@bogon yum.repos.d]# yum repolist
No repositories available
[root@bogon yum.repos.d]#
## 配置网络源:
[root@bogon yum.repos.d]# cat network.repo
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
http://mirrors.aliyuncs.com/centos/$releasever/BaseOS/$basearch/os/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/BaseOS/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/os/
http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/os/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/os/
http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/os/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
[PowerTools]
name=CentOS-$releasever - PowerTools - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/PowerTools/$basearch/os/
http://mirrors.aliyuncs.com/centos/$releasever/PowerTools/$basearch/os/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/PowerTools/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
[AppStream]
name=CentOS-$releasever - AppStream - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/
http://mirrors.aliyuncs.com/centos/$releasever/AppStream/$basearch/os/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/AppStream/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
[root@bogon yum.repos.d]#
### 本地 镜像源配置:
[root@bogon ~]# mkdir /media/cdrom
[root@bogon ~]# mount /dev/cdrom /media/cdrom/
[root@bogon yum.repos.d]# cat >> local.repo <<EOF
> [local]
> name=centos8
> baseurl=file:///media/cdrom
> enabled=1
> gpgkey=0
> EOF
[root@bogon yum.repos.d]# yum repolist
repo id repo name
epel epel8
local centos8
network Base Repo
[root@bogon yum.repos.d]#
- 编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。
http 官网: https://httpd.apache.org/
### 查看系统自带httpd包的版本为 2.4.37
[root@bogon ~]# yum info httpd
Last metadata expiration check: 0:08:59 ago on Wed 30 Dec 2020 12:05:58 AM CST.
Available Packages
Name : httpd
Version : 2.4.37
Release : 30.module_el8.3.0+561+97fdbbcc
Architecture : x86_64
Size : 1.7 M
Source : httpd-2.4.37-30.module_el8.3.0+561+97fdbbcc.src.rpm
Repository : AppStream
Summary : Apache HTTP Server
URL : https://httpd.apache.org/
License : ASL 2.0
Description : The Apache HTTP Server is a powerful, efficient, and extensible
: web server.
[root@bogon ~]#
### 编译安装官网最新 http2.4.46
1. 从官网下载 源码包
[root@bogon software]# ls
httpd-2.4.46.tar.gz
2. 解压:
[root@bogon software]# tar -zxf httpd-2.4.46.tar.gz
httpd-2.4.46 httpd-2.4.46.tar.gz
[root@bogon software]#
## 编译安装第一步,指定安装路径为/app/httpd. 配置文件安装在/etc/httpd 目录下,启用ssl加密功能
[root@bogon httpd-2.4.46]# ./configure --prefix=/app/httpd \
> --sysconfdir=/etc/httpd/ \
> --enable-ssl
### 编译完成:
config.status: executing default commands
configure: summary of build options:
Server Version: 2.4.46
Install prefix: /app/httpd
C compiler: gcc
CFLAGS: -pthread
CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE
LDFLAGS:
LIBS:
C preprocessor: gcc -E
##观察编译过程无错误提示。通过$0的值为0来确认成功
[root@bogon httpd-2.4.46]# echo $?
0
[root@bogon httpd-2.4.46]#
编译安装第二步:
[root@bogon httpd-2.4.46]# make -j 2 && make install
启动服务:
[root@bogon httpd]# /app/httpd/bin/apachectl start
访问:
[root@bogon httpd]# curl 127.0.0.1
<html><body><h1>It works!</h1></body></html>
[root@bogon httpd]#
## 当前提示缺少某个包时,只需按照提示缺少的包名后面加上devel 组成的包即可。
configure: error: APR not found:
[root@bogon httpd-2.4.46]# yum install -y -q apr-devel
configure: error: APR-util not found:
[root@bogon httpd-2.4.46]# yum install -y -q apr-util-devel gcc
configure: error: pcre-config for libpcre not found:
[root@bogon httpd-2.4.46]# yum install -y -q pcre-devel
checking for OpenSSL version >= 0.9.8a... FAILED
configure: WARNING: OpenSSL version is too old:
[root@bogon httpd-2.4.46]# yum install -y -q openssl-devel
解决 g++ error:/usr/lib/rpm/redhat/redhat-hardened-cc1 No that file and directory
[root@bogon httpd-2.4.46]# yum install redhat-rpm-config
3、利用sed 取出ifconfig命令中本机的IPv4地址
[root@bogon ~]# ifconfig | sed -n '2s/^.*inet //p'| sed -n 's/ netmask.*//p'
192.168.78.128
[root@bogon ~]#
4、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符
[root@bogon ~]# sed -i '/^#/s/^# //' /etc/fstab-bak
[root@bogon ~]# diff /etc/fstab /etc/fstab-bak
3,4c3,4
< # /etc/fstab
< # Created by anaconda on Tue Dec 29 09:51:15 2020
---
> /etc/fstab
> Created by anaconda on Tue Dec 29 09:51:15 2020
6,7c6,7
< # 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.
---
> 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.
9,10c9,10
< # After editing this file, run 'systemctl daemon-reload' to update systemd
< # units generated from this file.
---
> After editing this file, run 'systemctl daemon-reload' to update systemd
> units generated from this file.
[root@bogon ~]#
5、处理/etc/fstab路径,使用sed命令取出其目录名和基名
## 取目录名
[root@bogon ~]# ls /etc/fstab | sed -nr 's#(.*)/([^/]+)/?#\1#p'
/etc
[root@bogon ~]#
## 取基名
[root@bogon ~]# ls /etc/fstab | sed -nr 's#(.*)/([^/]+)/?#\2#p'
fstab
[root@bogon ~]#