第四周作业
1、自建yum仓库,分别为网络源和本地源
网络源: 可以粘贴阿里云,腾讯云,华为云等链接。由于CNETOS8 官方服务已经停更,相关的源链接也都移除,可用centos-stream 源链接替代。
本地源: - 挂载本地CD光盘到/mnt下,
mount /dev/sr0/ /mnt/cdrom
那么baseurl=file:///mnt/cdrom/
或者执行#rpm -q autofs || yum -y install autofs
#systemctl enable --now autofs 那么baseurl=file:///misc/cd/
创建/etc/yum.repos.d/Base.repo文件: (CENTOS8 环境) 我一个文件里分别创建了BaseOS仓库、AppsStream仓库、Extras仓库、EPEL仓库。
`
[BaseOS]
name=BaseOS
baseurl=file:///misc/cd/BaseOS
https://mirrors.aliyun.com/centos/8-stream/BaseOS/x86_64/os/
https://repo.huaweicloud.com/centos/8-stream/BaseOS/x86_64/os/
https://mirrors.cloud.tencent.com/centos/8.5.2111/BaseOS/x86_64/os/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[AppsStream]
name=AppStream
baseurl=file:///misc/cd/AppStream
https://repo.huaweicloud.com/centos/8-stream/AppStream/x86_64/os/
https://mirrors.cloud.tencent.com/centos/8.5.2111/AppStream/x86_64/os/
https://mirrors.aliyun.com/centos/8-stream/AppStream/x86_64/os/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[Extras]
name=extras
baseurl=https://mirrors.cloud.tencent.com/centos/8.5.2111/extras/x86_64/os/
https://mirrors.aliyun.com/centos/8-stream/extras/x86_64/os/
https://repo.huaweicloud.com/centos/8-stream/extras/x86_64/os/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[EPEL]
name=epel
baseurl=https://mirrors.huaweicloud.com/epel/8/Everything/x86_64/
https://mirrors.aliyun.com/epel/8/Everything/x86_64/
http://mirrors.cloud.tencent.com/epel/8/Everything/x86_64/
gpgcheck=0
gpgkey=http://mirrors.cloud.tencent.com/epel/RPM-GPG-KEY-EPEL-8
`
2、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。
`
1 官网上下载包
wget https://dlcdn.apache.org/httpd/httpd-2.4.53.tar.bz2
2 解压
tar xvf httpd-2.4.53.tar.bz2 -C /usr/local/src
3 定位到包位置
cd /usr/local/src/httpd-2.4.53/
4 编译前下载所需的包,否则编译过程中会报错提示缺少所需的包:
yum install gcc make apr-devel apr-util-devel pcre-devel openssl-devel redhat-rpm-config
5 配置,安装到/apps/httpd 路径下,配置文件存放到/etc/httpd下,加密
./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd --enable-ssl
6 编译
make -j 2 && make install
7 配置环境,将/apps/httpd/bin/apachectl 命令加到PATH 下,执行比较方便
echo 'PATH=/apps/httpd/bin/:$PATH' > /etc/profile.d/httpd.sh
./etc/profile.d/httpd.sh
8 运行
apache start
9 指定用户apache 运行
useradd -r -u 48 -g apache -s /sbin/nologin -d /var/www -c Apacahe apache
vi /etc/httpd/httpd.conf
** User apache
Group apache**
10 重启apache 服务
apachectl -k stop
apachectl -k start
11 查看进程
ps -aux
12 用浏览器打开界面如下:
`
3、利用sed 取出ifconfig命令中本机的IPv4地址
`
# ifconfig | sed -n -r '2s/^[^[:digit:]]+([0-9.]+).*/\1/p'
10.0.0.181
`
4、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符
`
# sed -n -r 's/^# +(.*)/\1/p ' /etc/fstab
/etc/fstab
Created by anaconda on Mon May 9 02:58:26 2022
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.
`
5、处理/etc/fstab路径,使用sed命令取出其目录名和基名
`
# echo /etc/fstab/ | sed -n -r 's@(/.*/)([a-z]+)/@\1@p'
/etc/
# echo /etc/fstab/ | sed -n -r 's@(/.*/)([a-z]+)/@\2@p'
fstab
`
6、列出ubuntu软件管理工具apt的一些用法(自由总结)
apt 类似与centos 的yum 功能。可以在线安装所需软件包。apt 在安装软件时有可能会显示未找到该软件,通常需要apt-get update 一下就可以解决。
Debian 使用apt 工具集来管理包系统,apt-get 是其中一个常用的命令行工具,另外一款较为流行的命
令行与 GUI 兼顾的工具是 aptitude ,之前最常用的 Linux 包管理命令都被分散在了 apt-get、aptcache
和 apt-config 这三条命令中
在 2014 年apt 命令发布第一个稳定版,Ubuntu 16.04 引入新特性之一便是 apt 命令,apt 命令解决了
命令过于分散的问题,它包括 apt-get 命令出现以来使用最广泛的功能选项,以及 apt-cache 和 aptconfig
命令中很少用到的功能。在使用 apt 命令时,用户不必再由 apt-get 转到 apt-cache 或 aptconfig,
提供管理软件包所需的必要选项
apt 相当于 apt-get、apt-cache 和 apt-config 中最常用命令选项的集合
apt 具有更精减但足够的命令选项,而且参数选项的组织方式更为有效。此外,启用的几个特性也非常
有帮助。例如:可以在使用 apt 命令安装或删除程序时看到进度条,apt 还会在更新存储库数据库时提示
用户可升级的软件包个数
apt 与 apt-get 有一些类似的命令选项,但它并不能完全向下兼容 apt-get 命令,也即可用 apt 替换部分
apt-get 系列命令,但不是全部
**apt 常用命令功能**
apt install 安装软件包
apt remove e 移除软件包
apt purge 移除软件包及配置文件
apt update 刷新存储库索引
apt upgrade 升级所有可升级的软件包
apt autoremove 自动删除不需要的包
apt full-upgrade 在升级软件包时自动处理依赖关系
apt search 搜索应用程序
apt show 显示安装细节