1、自建yum仓库,分别为网络源和本地源
网络源: [root@centos8 yum.repos.d]# cat 163.repo [AppStream] name=Appstream_163 baseurl=http://mirrors.163.com/centos/8/AppStream/x86_64/os gpgcheck=0 [Extras] name=Extras_163 baseurl=http://mirrors.163.com/centos/8/extras/x86_64/os gpgcheck=0 [BaseOS] name=BaseOS_163 baseurl=http://mirrors.163.com/centos/8/BaseOS/x86_64/os gpgcheck=0 [root@centos8 yum.repos.d]# yum repolist repo id repo name AppStream Appstream_163 BaseOS BaseOS_163 Extras Extras_163 [root@centos8 yum.repos.d]# yum list |wc -l 6937 -------------------------------------------------------------------------------------------------------------- 本地源: [root@centos8 yum.repos.d]# mkdir /mnt/cdrom //创建挂载路径文件夹 [root@centos8 yum.repos.d]# mount /dev/cdrom /mnt/cdrom //临时挂载光盘文件,永久挂载需写入fstab文件 mount: /mnt/cdrom: WARNING: device write-protected, mounted read-only. [root@centos8 yum.repos.d]# cd /mnt/cdrom/ [root@centos8 cdrom]# ls AppStream BaseOS EFI images isolinux LICENSE media.repo TRANS.TBL [root@centos8 yum.repos.d]# cat cdrom.repo [BaseOS] name=BaseOS baseurl=file:///mnt/cdrom/BaseOS enabled=1 gpgcheck=0 [AppStream] name=AppStream baseurl=file:///mnt/cdrom/AppStream enabled=1 gpgcheck=0 [root@centos8 yum.repos.d]# yum clean all 0 files removed [root@centos8 yum.repos.d]# yum repolist repo id repo name AppStream AppStream BaseOS BaseOS [root@centos8 cdrom]# yum list |wc -l 6680
2、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。
[root@centos8 test]# tar -xvf httpd-2.4.46.tar.bz2 -C . //解压文件到当前目录下 [root@centos8 httpd-2.4.46]# ./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd //运行 configure --prefix制定程序存放路径 --sysconfdir 配置文件路径 [root@centos8 httpd-2.4.46]# ./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd //编译文件 checking for chosen layout... Apache checking for working mkdir -p... yes checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking target system type... x86_64-pc-linux-gnu configure: configure: Configuring Apache Portable Runtime library... configure: checking for APR... no configure: error: APR not found. Please read the documentation. //编译报错 [root@centos8 httpd-2.4.46]# yum search apr* //搜索带ARP的包,一般缺失devel 和 util-devel包 Repository BaseOS is listed more than once in the configuration Repository AppStream is listed more than once in the configuration Last metadata expiration check: 0:14:13 ago on Sat 17 Apr 2021 01:19:53 PM CST. ======================================================== Name & Summary Matched: apr* ======================================================== apr-devel.i686 : APR library development kit apr-devel.x86_64 : APR library development kit apr-util-bdb.i686 : APR utility library Berkeley DB driver apr-util-bdb.x86_64 : APR utility library Berkeley DB driver apr-util-devel.i686 : APR utility library development kit apr-util-devel.x86_64 : APR utility library development kit apr-util-ldap.x86_64 : APR utility library LDAP support apr-util-mysql.x86_64 : APR utility library MySQL DBD driver apr-util-odbc.x86_64 : APR utility library ODBC DBD driver apr-util-openssl.i686 : APR utility library OpenSSL crypto support apr-util-openssl.x86_64 : APR utility library OpenSSL crypto support apr-util-pgsql.x86_64 : APR utility library PostgreSQL DBD driver apr-util-sqlite.x86_64 : APR utility library SQLite DBD driver ============================================================= Name Matched: apr* ============================================================= apr.i686 : Apache Portable Runtime library apr.x86_64 : Apache Portable Runtime library apr-util.i686 : Apache Portable Runtime Utility library apr-util.x86_64 : Apache Portable Runtime Utility library [root@centos8 httpd-2.4.46]# ./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd //再次执行编译文件,不出意外会在次报错,报错pcre,同样是缺失devel 和 util-devel包 再次安装pcre-devel和pcre-util-devel即可 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]# make -j 4 && make install //make安装 报错 gcc: error: /usr/lib/rpm/redhat/redhat-hardened-ld: No such file or directory make[4]: *** [/data/test/httpd-2.4.46/modules/aaa/modules.mk:6: mod_authn_anon.la] Error 1 make[4]: *** Waiting for unfinished jobs.... gcc: error: /usr/lib/rpm/redhat/redhat-hardened-ld: No such file or directory make[4]: *** [/data/test/httpd-2.4.46/modules/aaa/modules.mk:2: mod_authn_file.la] Error 1 gcc: error: /usr/lib/rpm/redhat/redhat-hardened-ld: No such file or directory make[4]: *** [/data/test/httpd-2.4.46/modules/aaa/modules.mk:4: mod_authn_dbm.la] Error 1 make[4]: Leaving directory '/data/test/httpd-2.4.46/modules/aaa' make[3]: *** [/data/test/httpd-2.4.46/build/rules.mk:117: shared-build-recursive] Error 1 make[3]: Leaving directory '/data/test/httpd-2.4.46/modules/aaa' make[2]: *** [/data/test/httpd-2.4.46/build/rules.mk:117: shared-build-recursive] Error 1 make[2]: Leaving directory '/data/test/httpd-2.4.46/modules' make[1]: *** [/data/test/httpd-2.4.46/build/rules.mk:117: shared-build-recursive] Error 1 make[1]: Leaving directory '/data/test/httpd-2.4.46' make: *** [/data/test/httpd-2.4.46/build/rules.mk:75: all-recursive] Error 1 [root@centos8 httpd-2.4.46]# yum search redhat* //搜索redhat开头的包 发现缺失 Repository BaseOS is listed more than once in the configuration Repository AppStream is listed more than once in the configuration Last metadata expiration check: 0:23:42 ago on Sat 17 Apr 2021 01:19:53 PM CST. =========================================================== Name Matched: redhat* ============================================================ redhat-lsb.x86_64 : Implementation of Linux Standard Base specification redhat-lsb-core.i686 : LSB Core module support redhat-lsb-core.x86_64 : LSB Core module support redhat-lsb-cxx.i686 : LSB CXX module support redhat-lsb-cxx.x86_64 : LSB CXX module support redhat-lsb-desktop.i686 : LSB Desktop module support redhat-lsb-desktop.x86_64 : LSB Desktop module support redhat-lsb-languages.i686 : LSB Languages module support redhat-lsb-languages.x86_64 : LSB Languages module support redhat-lsb-printing.i686 : LSB Printing module support redhat-lsb-printing.x86_64 : LSB Printing module support redhat-lsb-submod-multimedia.i686 : LSB Multimedia submodule support redhat-lsb-submod-multimedia.x86_64 : LSB Multimedia submodule support redhat-lsb-submod-security.i686 : LSB Security submodule support redhat-lsb-submod-security.x86_64 : LSB Security submodule support redhat-menus.noarch : Configuration and data files for the desktop menus redhat-rpm-config.noarch : CentOS specific rpm configuration files redhat-support-lib-python.noarch : Red Hat Support Software Development Library redhat-support-tool.noarch : Tool for console access to Red Hat subscriber services [root@centos8 httpd-2.4.46]# yum provides /usr/lib/rpm/redhat/redhat-hardened-ld //搜索包 Repository BaseOS is listed more than once in the configuration Repository AppStream is listed more than once in the configuration Last metadata expiration check: 0:29:04 ago on Sat 17 Apr 2021 01:19:53 PM CST. redhat-rpm-config-123-1.el8.noarch : CentOS specific rpm configuration files Repo : AppStream Matched from: Filename : /usr/lib/rpm/redhat/redhat-hardened-ld [root@centos8 httpd-2.4.46]# yum -y install redhat-rpm-config-123-1.el8.noarch //安装 [root@centos8 httpd-2.4.46]# make -j 4 && make install //再次安装 make[1]: Leaving directory '/data/test/httpd-2.4.46' [root@centos8 httpd]# ls bin build cgi-bin error htdocs icons include logs man manual modules [root@centos8 httpd]# cd bin/ [root@centos8 bin]# ls ab apxs dbmmanage envvars-std htcacheclean htdigest httpd logresolve apachectl checkgid envvars fcgistarter htdbm htpasswd httxt2dbm rotatelogs [root@centos8 bin]# ./apachectl start //启动 之后可以访问
3、sed命令取ip地址
[root@centos8 test]# ifconfig ens33|sed -En "s/.*[[:space:]]([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})[[:space:]]{1,2}net.*/\1/p" 10.0.0.108
4、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符
[root@centos8 data]# sed -i.bak -En '/^#[[:space:]]+/d' fstab [root@centos8 data]# cat fstab [root@centos8 data]# cp fstab.bak fstab cp: overwrite 'fstab'? y [root@centos8 data]# sed -i.bak -E '/^#[[:space:]]+/d' fstab [root@centos8 data]# cat fstab # # # # UUID=5ba2a66b-0e07-41b7-883d-bbf2e80fdc15 / xfs defaults 0 0 UUID=3907332c-a026-4f30-8e74-bec273aafa9b /boot xfs defaults 0 0 UUID=6aebae13-df28-479a-8510-a2b6db90b9e6 /data xfs defaults 0 0 UUID=483f2853-7e93-425a-80a1-e8145be813d5 none swap defaults 0 0 UUID=1852dc2c-4ab0-49b2-a6c5-9d76e10ee6ff /data/mysql xfs defaults,noatime 0 0
5、处理/etc/fstab路径,使用sed命令取出其目录名和基名
[root@centos8 data]# echo '/etc/fstab'|sed -En "s#^/(.*)/(.*)#\1#p" etc [root@centos8 data]# echo '/etc/fstab'|sed -En "s#^/(.*)/(.*)#\2#p" fstab