Work·第四周

1、自建yum仓库,分别为网络源和本地源

网络源:
1、将系统现有的备份到bak目录

[root@localhost yum.repos.d]# ls bak/
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo  docker-ce.repo

2、新建base.repo文件,添加网络源

[root@localhost yum.repos.d]# cat base.repo 
[base]
name=CentOS
baseurl=https://mirrors.aliyun.com/centos/$releasever/os/$basearch
        https://mirrors.cloud.tencent.com/centos/$releasever/os/$basearch
        https://repo.huaweicloud.com/centos/$releasever/os/$basearch
        https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch
gpgcheck=0

[extras]
name=extras
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch
        https://mirrors.huaweicloud.com/centos/$releasever/extras/$basearch
        https://mirrors.cloud.tencent.com/centos/$releasever/extras/$basearch
        https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch
gpgcheck=0
enabled=1

[epel]
name=EPEL
baseurl=https://mirrors.aliyun.com/epel/$releasever/$basearch
        https://mirrors.cloud.tencent.com/epel/$releasever/$basearch
        https://mirrors.huaweicloud.com/epel/$releasever/$basearch
        https://mirrors.tuna.tsinghua.edu.cn/epel/$releasever/$basearch
gpgcheck=0
enabled=1

[root@localhost yum.repos.d]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.tuna.tsinghua.edu.cn
 * epel: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.tuna.tsinghua.edu.cn
repo id                                                    repo name                                        status
base/7/x86_64                                              CentOS                                           10,072
epel/7/x86_64                                              EPEL                                             13,728
!extras/7/x86_64                                           extras                                              500
repolist: 24,300

#尝试安装软件,rzsz
[root@localhost yum.repos.d]# yum install -y lrzsz

本地源:
1、挂载镜像,添加后重新扫描
在这里插入图片描述
重新扫描

[root@localhost ~]# cat scandisk.sh 
#!/bin/sh
num=`ls -alh /sys/class/scsi_host/host*|wc -l`
for ((i=0;i<${num};i++))
do
    echo "- - -" > /sys/class/scsi_host/host${i}/scan
done

2、关闭防火墙和selinux

systemctl disable --now firewalld
sed -ri 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

3、安装httpd

yum install -y httpd

4、创建目录

[root@localhost html]# cd /var/www/html/ 
[root@localhost html]# mkdir centos/7 
[root@localhost html]# tree centos/
centos/
└── 7

5、光盘挂载指定目录-centos源

[root@localhost yum.repos.d]# mount /dev/sr1 /var/www/html/centos/7/

6、修改yum配置文件-centos源

[root@localhost yum.repos.d]# cat base.repo 
[base]
name=CentOS
baseurl=http://10.0.0.151/centos/$releasever
#baseurl=https://mirrors.aliyun.com/centos/$releasever/os/$basearch
#       https://mirrors.cloud.tencent.com/centos/$releasever/os/$basearch
#       https://repo.huaweicloud.com/centos/$releasever/os/$basearch
#       https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch
gpgcheck=0

#查看
[root@localhost yum.repos.d]# yum repolist  
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * epel: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.tuna.tsinghua.edu.cn
repo id                                                    repo name                                        status
base/7                                                     CentOS                                           10,072
epel/7/x86_64                                              EPEL                                             13,728
!extras/7/x86_64                                           extras                                              500
repolist: 24,300

[root@localhost yum.repos.d]# yum install -y vsftpd
……

Installed:
  vsftpd.x86_64 0:3.0.2-22.el7                                                                                    

Complete!

7、下载extras、epel,制作私有yum源

[root@localhost yum.repos.d]# reposync --repoid=extras --download-metadata -p /var/www/html/centos/
[root@localhost yum.repos.d]# reposync --repoid=epel --download-metadata -p /var/www/html/
#生成medata
[root@localhost yum.repos.d]# createrepo /var/www/html/epel/
[root@localhost yum.repos.d]# createrepo /var/www/html/centos/extras/

8、修改base.repo文件

[root@localhost yum.repos.d]# cat base.repo 
[extras]
name=extras
baseurl=http://10.0.0.151/centos/extras
[epel]
name=EPEL
baseurl=http://10.0.0.151/epel

9、清理yum缓存

[root@localhost yum.repos.d]# yum clean all
[root@localhost yum.repos.d]# yum makecache

2、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。

1、安装相关包
[root@localhost ~]# yum install -y gcc make autoconf apr-devel apr-util-devel pcre-devel openssl-devel redhat-rpm-config
2、下载并解压
[root@localhost ~]# wget --no-check-certificate https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.4.51.tar.bz2
#安装bzip2,如果有可忽略
[root@localhost ~]# yum -y install bzip2 
#解压
[root@localhost ~]# tar xvf httpd-2.4.51.tar.bz2 -C /usr/local/src 
3、配置
[root@localhost httpd-2.4.51]# ./configure --prefix=/app/httpd --enable-ssl
4、编译
[root@localhost httpd-2.4.51]# make -j 2
5、安装
[root@localhost httpd-2.4.51]# make install
6、配置环境变量
[root@localhost httpd]# echo 'PATH=/app/httpd/bin:$PATH' > /etc/profile.d/httpd.sh
[root@localhost httpd]# . /etc/profile.d/httpd.sh                                 
7、运行,直接使用apachectl start,提示找不到httpd.conf,改用以下方式启动
[root@localhost httpd]# apachectl -f /app/httpd/conf/httpd.conf -k start

在这里插入图片描述

3、利用sed 取出ifconfig命令中本机的IPv4地址

[root@localhost ~]# ifconfig ens32|sed -rn '2s/^[^0-9]+([0-9.]+)  .*$/\1/p'
10.0.0.151

4、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符

[root@localhost ~]# cp /etc/fstab fstab

[root@localhost ~]# sed -rn 's/^#[ :space: ]+(.*$)/\1/p' fstab 
/etc/fstab
Created by anaconda on Thu Feb 10 01:43:25 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

[root@localhost ~]# sed -ri 's/^#[ :space: ]+(.*$)/\1/g' fstab 
[root@localhost ~]# cat fstab 

#
/etc/fstab
Created by anaconda on Thu Feb 10 01:43:25 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
#
/dev/mapper/centos-root /                       xfs     defaults        0 0
UUID=7f60160b-2a6c-4829-8ebc-bb6cc242968a /boot                   xfs     defaults        0 0
/dev/mapper/centos-swap swap 

5、处理/etc/fstab路径,使用sed命令取出其目录名和基名

[root@localhost etc]# echo "/etc/fstab" |sed -r 's#(^/.*/)([^/]+/?)#\1#' 
/etc/
[root@localhost etc]# echo "/etc/fstab" |sed -r 's#(^/.*/)([^/]+/?)#\2#'
fstab

6、列出ubuntu软件管理工具apt的一些用法(自由总结)

apt install 安装软件包
apt remove 移除软件包
apt purge 删除软件包及配置文件
apt update 刷新存储库索引
apt upgrade 升级所有可升级的软件包
apt autoremove 自动删除不需要的包
apt full-upgrade 升级软件包时自动关联依赖关系
apt search 搜索应用
apt show 显示安装细节
apt list 列出包含条件的包
apt edit-sources 编辑源列表
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值