第六周
1、自建yum倉(cāng)庫(kù),分別為網(wǎng)絡(luò)源和本地源
[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,實(shí)現(xiàn)可以正常訪問(wèn),并將編譯步驟和結(jié)果提交。
- 從官網(wǎng)下載軟件包到本地目錄/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的選項(xiàng),可以運(yùn)行
./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]$
- 開(kāi)始編譯,-j選擇是選擇多個(gè)線程
make -j 4 && make install
有報(bào)錯(cuò)gcc: error: /usr/lib/rpm/redhat/redhat-hardened-ld: No such file or directory
//查詢?nèi)鄙俚奈募儆谀膫€(gè)包文件
[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
//繼續(xù)安裝
[root@centos8 httpd-2.4.46]make -j 4 && make install
- 根據(jù)INSTALL文件提示,要運(yùn)行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命令中本機(jī)的IPv4地址
[root@centos8 data]$ifconfig eth0 |sed -En '2s/(^ *inet )([0-9.]*)( .*$)/\2/p'
10.0.0.8
4、刪除/etc/fstab文件中所有以#開(kāi)頭,后面至少跟一個(gè)空白字符的行的行首的#和空白字符
[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/