第四周作业
自建yum仓库,分别为网络源和本地源
[base]
name=base
baseurl=file:///mnt/package
https://mirrors.cloud.tencent.com/centos/$releasever/os/x86_64/
https://repo.huaweicloud.com/centos/$releasever/os/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
https://mirrors.cloud.tencent.com/centos/$releasever/os/x86_64/RPM-GPG-KEY-CentOS-7
https://repo.huaweicloud.com/centos/$releasever/os/x86_64/RPM-GPG-KEY-CentOS-7
[epel]
name=epel
baseurl=file:///var/www/html/epel
http://mirrors.cloud.tencent.com/epel/$releasever/x86_64/
https://mirrors.huaweicloud.com/epel/7/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
http://mirrors.cloud.tencent.com/epel/RPM-GPG-KEY-EPEL-7
https://mirrors.huaweicloud.com/epel/RPM-GPG-KEY-EPEL-7
[root@ansible ~]# yum repolist 已加载插件:fastestmirror, langpacks Determining fastest mirrors * base: * epel: base | 2.9 kB 00:00:00 epel | 2.9 kB 00:00:00 (1/2): base/7/primary_db | 3.2 MB 00:00:00 (2/2): epel/7/primary_db | 6.9 MB 00:00:00 源标识 源名称 状态 base/7 base 4,070 epel/7 epel 13,743 repolist: 17,813
编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交
将编译过程写成脚本
#!/bin/bash
core=`lscpu | sed -rn '/^CPU\(/s/.*: +(.*)/\1/p'`
sed -i '/0/a\[epel]\nname=epel\nbaseurl=http://10.0.6.25/epel\nenabled=1\ngpgcheck=0' /etc/yum.repos.d/local.repo
yum clean all
yum install -y wget bzip2 apr-devle apr-util-devel gcc pcre-devel
wget https://dlcdn.apache.org//httpd/httpd-2.4.52.tar.bz2 --no-check-certificate || { echo "下载失败,重试" ; exit; }
tar jxvf httpd-2.4.52.tar.bz2
cd httpd-2.4.52
./configure
make -j$core
make install
echo 'PATH=/usr/local/apache2/bin/:$PATH' > /etc/profile.d/httpd.sh
. /etc/profile.d/httpd.sh
groupadd -g 1020 -r apache5
useradd -g apache5 -u 1020 -s /sbin/nologin apache5
sed -i -e 's#User daemon#User apache5#' -e 's#Group daemon#Group apache5#' /usr/local/apache2/conf/httpd.conf
apachectl -k start
apachectl -k restart
firewall-cmd --zone=public --add-port=80/tcp --permanent
systemctl restart firewalld
编译成功,可以访问


利用sed 取出ifconfig命令中本机的IPv4地址
ifconfig eth0 | sed -rn 's/inet +(.*) +n.*/\1/p'
10.0.6.25
删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符
[root@ansible srete]# sed '/^#/d;/^$/d' /etc/fstab /dev/mapper/centos-root / xfs defaults 0 0 UUID=fa726e04-47d9-4081-a349-8f4e16c83ff0 /boot xfs defaults 0 0 /dev/mapper/centos-swap swap swap defaults 0 0
处理/etc/fstab路径,使用sed命令取出其目录名和基名
[root@ansible ~]# echo /etc/fstab | sed -rn 's@/(.*)/(.*)@\1 \2@p' etc fstab
列出ubuntu软件管理工具apt的一些用法(自由总结)
apt命令用法和yum类似,可以实现ubuntu系统下,软件的安装,卸载查看等功能
个人常用的apt命令有
apt install:用来安装ubuntu软件,和yum install类似,跟上--reinstall参数可以重新安装指定的包 apt remove:卸载软件,和yum remove类似,删除后会保留软件配置文件,若想完全删除需跟 -purge选项 apt update:更新apt缓存,更换过apt源之后需要使用此命令更新apt缓存,centos使用yum clean all来清空yum缓存 apt list --upgradable:查看可以更新的软件包 和yum check-update类似,apt list后可以跟软件包名,查看软件包名称和有无安装 apt show xxx:查看软件包信息和yum info xxx类似 apt upgrade:更新已安装的包,和yum update类似 apt clean:删除下载的包文件
这是个人经常使用的apt功能,通过man 8 apt可以查看apt详细使用说明

浙公网安备 33010602011771号