linux_4

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

1.1 本地源

tep1 添加光驱并挂载

[root@CentOS7 ~]#mkdir applocation/Centos7 -p
[root@CentOS7 ~]#mount /dev/sr1 /applocation/Centos7
[root@CentOS7 ~]#lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   30G  0 disk 
├─sda1   8:1    0  300M  0 part /boot
├─sda2   8:2    0    2G  0 part [SWAP]
└─sda3   8:3    0 27.7G  0 part /
sr0     11:0    1  4.4G  0 rom  
sr1     11:1    1  723M  0 rom  /applocation/Centos7
#此时,光盘已经挂载到该目录下
[root@CentOS7 ~]#ls /applocation/Centos7
EFI  images  isolinux  LICENSE  TRANS.TBL

tep2 打开仓库配置文件

[root@CentOS7 ~]#ls /etc/yum.repos.d/
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo  CentOS-x86_64-kernel.repo
[root@CentOS7 ~]#mv *.repo bak;touch base.repo;vim base.repo

[Base]
name=Centos7
baseurl=file://applocation/Centos7      
gpgcheck=0

tep3 检查本地仓库状态

[root@CentOS7 ~]##yum repolist 
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: www
repo id            repo name         status                   
base/7/x86_64        Base            10,072 
#此时已完成本地源配置

1.2 网络源

  • 修改配置文件
[base]
name=base
baseurl=https://mirrors.cloud.tencent.com/centos/7/os/x86_64/
	https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/
	https://repo.huaweicloud.com/centos/7/os/x86_64/
gpgcheck=0

[epel]
name=epel
baseurl=https://mirrors.cloud.tencent.com/epel/7/x86_64/
        https://mirrors.huaweicloud.com/epel/7/x86_64/
        https://mirrors.tuna.tsinghua.edu.cn/epel/7/x86_64/

gpgcheck=1
gpgkey=https://mirrors.cloud.tencent.com/epel/RPM-GPG-KEY-EPEL-7
       https://mirrors.huaweicloud.com/epel/RPM-GPG-KEY-EPEL-7
       https://mirrors.tuna.tsinghua.edu.cn/epel/RPM-GPG-KEY-EPEL-7
enabled=1
[extras]
name=extras
baseurl=https://mirrors.cloud.tencent.com/centos/7/extras/x86_64/
        https://mirrors.huaweicloud.com/centos/7/extras/x86_64/
	https://mirrors.tuna.tsinghua.edu.cn/centos/7/extras/x86_64/
gpgcheck=1
gpgkey=https://repo.huaweicloud.com/centos/RPM-GPG-KEY-CentOS-7
enabled=1
  • 检查结果
[root@CentOS7 ~]#yum repolist 
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: repo.huaweicloud.com
 * epel: mirrors.cloud.tencent.com
 * extras: mirrors.cloud.tencent.com
repo id                                                               repo name                                                             status
base                                                                  base                                                                  10,072
epel                                                                  epel                                                                  13,665
extras                                                                extras                                                                   500
repolist: 24,237

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

  • 安装相关依赖包
[root@centos7 ~]yum -y install gcc make
  • 下载http2.4包,并解压
[root@centos7 ~]#tar xvf httpd-2.4.48.tar.gz 
  • 进入解压后的文件夹,运行configure文件
[root@10 httpd-2.4.49]yum -y install apr-devel APR-util-devel pcre-devel openssl-devel #安装好相关依赖包
[root@10 httpd-2.4.49]./configure --prefix=/apps/httpd24 --sysconfdir=/etc/httpd24/ --enable-ssl

  • 执行make 和make install
[root@10 httpd-2.4.49]make
[root@10 httpd-2.4.49]make install
  • 修改PATH变量
[root@10 httpd-2.4.49]cho ‘PATH=/apps/httpd24/bin:$PATH‘ > /etc/profile.d/httpd24.sh
[root@10 httpd-2.4.49]#. /etc/profile.d/httpd24.sh
  • 运行并检查结果
[root@10 httpd-2.4.49]#apachectl start
[root@10 httpd-2.4.49]#ps  aux
apache    21584  0.0  0.1 228312  2972 ?        S    21:30   0:00 httpd
apache    21585  0.0  0.1 228312  2972 ?        S    21:30   0:00 httpd
apache    21586  0.0  0.1 228312  2972 ?        S    21:30   0:00 httpd
apache    21587  0.0  0.1 228312  2972 ?        S    21:30   0:00 httpd
apache    21588  0.0  0.1 228312  2972 ?        S    21:30   0:00 httpd
apache    21589  0.0  0.1 228312  2972 ?        S    21:30   0:00 httpd

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

[root@CentOS7 ~]#ifconfig |sed -nr ‘2s@inet +(.*) +n.*@\1@p‘

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

[root@CentOS7 ~]#sed -r ‘s/^# +//p‘ /etc/fstab
[root@CentOS7 ~]#sed -r ‘s/^#[[:space:]]+//p‘ /etc/fstab

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

#取目录名

[root@CentOS7 ~]#echo /etc/fstab |sed -r ‘s/(^\/etc\/)fstab/\1/p‘
[root@CentOS7 ~]##echo /etc/fstab |grep "\/.*$"

#取基名

[root@CentOS7 ~]#echo /etc/fstab |sed -nr ‘s/^\/etc\/(fstab)/\1/p‘
[root@CentOS7 ~]#echo /etc/fstab |egrep -o ‘[^/]+$‘

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

  • 安装软件包
[root@CentOS7 ~]#apt install tree
  • 删除软件包
[root@CentOS7 ~]# apt remove tree
  • 列出仓库软件包
[root@CentOS7 ~]# apt list
  • 搜索软件包
[root@CentOS7 ~]# apt search nginx
  • 查看某个软件包的详细信息
[root@CentOS7 ~]# apt show nginx
  • 更新包索引
[root@CentOS7 ~]# apt update

linux_4

上一篇:学习SSM项目导入中mysql版本导入问题


下一篇:linux驱动之register_chrdev注册字符设备