1.自建yum倉庫蝶俱,分別為網(wǎng)絡(luò)源和本地源俊鱼。
阿里云鏡像網(wǎng)站:https://developer.aliyun.com/mirror/centos?spm=a2c6h.13651102.0.0.3e221b11c8B5ge
# 先備份系統(tǒng)默認(rèn)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]#
## 配置網(wǎng)絡(luò)源:
[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称勋,實(shí)現(xiàn)可以正常訪問,并將編譯步驟和結(jié)果提交帆阳。
http 官網(wǎng): https://httpd.apache.org/
### 查看系統(tǒng)自帶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 ~]#
### 編譯安裝官網(wǎng)最新 http2.4.46
1. 從官網(wǎng)下載 源碼包
[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
##觀察編譯過程無錯(cuò)誤提示针贬。通過$0的值為0來確認(rèn)成功
[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
啟動服務(wù):
[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]#
## 當(dāng)前提示缺少某個(gè)包時(shí)击费,只需按照提示缺少的包名后面加上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命令中本機(jī)的IPv4地址
[root@bogon ~]# ifconfig | sed -n '2s/^.*inet //p'| sed -n 's/ netmask.*//p'
192.168.78.128
[root@bogon ~]#
4蔫巩、刪除/etc/fstab文件中所有以#開頭,后面至少跟一個(gè)空白字符的行的行首的#和空白字符
[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 ~]#