Linux基础2

文章目录

  • RHCSA课程回顾
            • 注:自动化的前提是标准化、规范化。
      • 1.网卡命令的步骤:
      • 2.ifconfig命令操作
      • 3.IP命令及操作
      • 4.ss命令操作
      • 5.网卡的配置
      • 6.硬盘命令
      • 7.fdisk 命令及操作
      • 8.格式化
      • 9挂载
      • 10.永久挂载
      • 11.计划任务
      • 12.日志服务与管理
      • 13.httpd编译安装
            • apr-util安装
            • http安装
            • http安装

RHCSA课程回顾


注:自动化的前提是标准化、规范化。

网卡回归 传统命名一般是:eth0、eth1、eth2等等,每一台主机的网卡名字不一样,也可能是ens33或者ens34,因机而已。

1.网卡命令的步骤:

  • 修改网卡配置文件的名字并改其内容。
  • 编辑/etc/default/grub, 在grub前面加上net.ifname=0 biosdevname=0
  • 生成配置文件grub2-mkconfig -o /etc/grub2.cfg
  • 最后重启:reboot

实际操作参考:

首先我们进入到里面去编辑网卡ip,以及网卡各项内容,编辑完之后我们出来修改网卡的名字。操作如下。

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens160 
TYPE=Ethernet
BOOTPROTO=static
NAME=eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.100.10
PREFIX=24
GATEWAY=192.168.100.10
DNS1=114.114.114.114
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# ls
ifcfg-ens160
[root@localhost network-scripts]# mv ifcfg-ens160 ifcfg-eth0
[root@localhost network-scripts]# ls
ifcfg-eth0
[root@localhost network-scripts]# 

我们还可以修改。/etc/default/grub里面的配置文件, 来修改网卡的名字,操作如下。

[root@localhost ~]# cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap net.ifnames=0 biosdevname=0 rhgb quiet"     //这句话在rhgb的前面加上net.ifname=0  biosdevname=0
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true
[root@localhost ~]# 

[root@localhost ~]#  grub2-mkconfig -o /etc/grub2.cfg  /执行这条命令
Generating grub configuration file ...
done   //在这里我们看到done说明已经成功了
[root@localhost ~]# reboot   //然后我们重启
[root@localhost ~]# ip addr show eth0   //重启之后我们使用命令查看一下网卡名是否修改成功。
2: eth0:  mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:0c:29:b7:3c:08 brd ff:ff:ff:ff:ff:ff
    inet 192.168.100.10/24 brd 192.168.100.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:feb7:3c08/64 scope link 
       valid_lft forever preferred_lft forever
[root@localhost ~]# 

2.ifconfig命令操作


ifconfig格式:

​ ifconfig 网卡名 【选项】

ifconfig在日常生活中常见的参数

  • down //断开指定的网络设备
  • up //和上面相反,启动指定的网络
  • ip地址 //指定网络设备的ip地址

ifconfig实际操作


显示网络设备信息

[root@localhost ~]# ifconfig
eth0: flags=4163  mtu 1500
        inet 192.168.100.10  netmask 255.255.255.0  broadcast 192.168.100.255
        inet6 fe80::20c:29ff:feb7:3c08  prefixlen 64  scopeid 0x20
        ether 00:0c:29:b7:3c:08  txqueuelen 1000  (Ethernet)
        RX packets 6370  bytes 527153 (514.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 11012  bytes 2379596 (2.2 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 36  bytes 3572 (3.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 36  bytes 3572 (3.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@localhost ~]# 

关闭指定网卡


[root@localhost ~]# ifconfig   lo down
[root@localhost ~]# ifconfig  //断开成功之后我们可以用ifconfig查看
eth0: flags=4163  mtu 1500
        inet 192.168.100.10  netmask 255.255.255.0  broadcast 192.168.100.255
        inet6 fe80::20c:29ff:feb7:3c08  prefixlen 64  scopeid 0x20
        ether 00:0c:29:b7:3c:08  txqueuelen 1000  (Ethernet)
        RX packets 10490  bytes 866804 (846.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 17984  bytes 3821464 (3.6 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@localhost ~]# 

启动指定网卡


[root@localhost ~]# ifconfig lo up
[root@localhost ~]# ifconfig
eth0: flags=4163  mtu 1500
        inet 192.168.100.10  netmask 255.255.255.0  broadcast 192.168.100.255
        inet6 fe80::20c:29ff:feb7:3c08  prefixlen 64  scopeid 0x20
        ether 00:0c:29:b7:3c:08  txqueuelen 1000  (Ethernet)
        RX packets 12080  bytes 997656 (974.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 20620  bytes 4352440 (4.1 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 44  bytes 4364 (4.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 44  bytes 4364 (4.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@localhost ~]# 

修改ip地址命令


(这条命令不是很常用,所以不建议大家用这条命令修改ip地址)。

[root@localhost ~]# ifconfig eth0
eth0: flags=4163  mtu 1500
        inet 192.168.100.10  netmask 255.255.255.0  broadcast 192.168.100.255
        inet6 fe80::20c:29ff:feb7:3c08  prefixlen 64  scopeid 0x20
        ether 00:0c:29:b7:3c:08  txqueuelen 1000  (Ethernet)
        RX packets 14691  bytes 1212324 (1.1 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 24932  bytes 5189452 (4.9 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@localhost ~]# ifconfig eth0 192.168.100.20
[root@localhost ~]# ifconfig eth0
eth0: flags=4163  mtu 1500
        inet 192.168.100.20  netmask 255.255.255.0  broadcast 192.168.100.255
        inet6 fe80::20c:29ff:feb7:3c08  prefixlen 64  scopeid 0x20
        ether 00:0c:29:b7:3c:08  txqueuelen 1000  (Ethernet)
        RX packets 471  bytes 42008 (41.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 620  bytes 141237 (137.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@localhost ~]# 

3.IP命令及操作


查看网卡信息命令(一共有三种查看的方法)

[root@localhost ~]# ip addr show eth0    //这是第一种
2: eth0:  mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:0c:29:b7:3c:08 brd ff:ff:ff:ff:ff:ff
    inet 192.168.100.20/24 brd 192.168.100.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:feb7:3c08/64 scope link 
       valid_lft forever preferred_lft forever
[root@localhost ~]# 
[root@localhost ~]#   ip a s eth0    //这种是简写查看的方法
2: eth0:  mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:0c:29:b7:3c:08 brd ff:ff:ff:ff:ff:ff
    inet 192.168.100.20/24 brd 192.168.100.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:feb7:3c08/64 scope link 
       valid_lft forever preferred_lft forever
[root@localhost ~]# 
[root@localhost ~]# ip a     //这是第三种/
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:0c:29:b7:3c:08 brd ff:ff:ff:ff:ff:ff
    inet 192.168.100.20/24 brd 192.168.100.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:feb7:3c08/64 scope link 
       valid_lft forever preferred_lft forever
[root@localhost ~]# 

禁用网卡lo


[root@localhost ~]# ip a s lo
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
[root@localhost ~]# ip link set lo down
[root@localhost ~]# ip a s lo
1: lo:  mtu 65536 qdisc noqueue state DOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
[root@localhost ~]# 

启用网卡lo


[root@localhost ~]# ip a s lo
1: lo:  mtu 65536 qdisc noqueue state DOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
[root@localhost ~]# ip link set lo up
[root@localhost ~]# ip a s lo
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
[root@localhost ~]# 

显示网络设备的运行状态

[root@localhost ~]# ip link list
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0:  mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether 00:0c:29:b7:3c:08 brd ff:ff:ff:ff:ff:ff
[root@localhost ~]# 

4.ss命令操作


格式:ss 【参数】

常用参数

  • -n 不解析服务名称。以数字方式显示
  • -a 显示所有套接字
  • -l 显示处于监听状态的套接字
  • -e 显示详细的套接字信息
  • -m 显示套接字的内存使用情况
  • -p 显示使用套接字的进程

命令操作参考

显示tcp套接字

[root@localhost ~]# ss -ant
State          Recv-Q         Send-Q                  Local Address:Port                  Peer Address:Port         
LISTEN         0              128                           0.0.0.0:22                         0.0.0.0:*            
ESTAB          0              0                      192.168.100.20:22                   192.168.100.1:59259        
ESTAB          0              36                     192.168.100.20:22                   192.168.100.1:59258        
LISTEN         0              128                              [::]:22                            [::]:*            
[root@localhost ~]# 

显示当前正在监听的tcp端口

[root@localhost ~]# ss -antl
State          Recv-Q         Send-Q                 Local Address:Port                   Peer Address:Port         
LISTEN         0              128                          0.0.0.0:22                          0.0.0.0:*            
LISTEN         0              128                             [::]:22                             [::]:*            
[root@localhost ~]# 

显示监听的tcp端口运行在那个服务

[root@localhost ~]# ss -antlp
State     Recv-Q    Send-Q       Local Address:Port         Peer Address:Port                                       
LISTEN    0         128                0.0.0.0:22                0.0.0.0:*        users:(("sshd",pid=1094,fd=5))    
LISTEN    0         128                   [::]:22                   [::]:*        users:(("sshd",pid=1094,fd=7))    
[root@localhost ~]# 

5.网卡的配置


网卡配置文件最简配置如下:(九条命令缺一不可, 这就是最简化配置)

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 
TYPE=Ethernet
BOOTPROTO=static     //静态ip  
NAME=eth0    //网卡名字
DEVICE=eth0   //网卡名字
ONBOOT=yes     //开机是否启动该网卡
IPADDR=192.168.100.20   //ip地址
PREFIX=24   //子网掩码
GATEWAY=192.168.100.2    //网关
DNS1=114.114.114.114

[root@localhost ~]# 
、

6.硬盘命令


常见的硬盘类型

IDE硬盘 hd开头{a|b|c|d|e…}以此内推

SCSI硬盘 sd开头和上面一样

虚拟化硬盘 vd开头和上面一样

分区

MBR分区(最多只能有4 个主分区):

  • 主分区 P: Primary 主要的 分区号1-4
  • 常用分区类型:1P1ENL、2P1ENL、3P1ENL
  • 扩展分区 E: Extend 扩展的 分区号2-4
  • 逻辑分区 L: Lofical 逻辑的 分区号5以后

7.fdisk 命令及操作


格式:fdisk 【必要参数】【可选择参数】
必要参数:

  1. -l 列出所有分区表
  2. -u 与"-l"搭配使用,显示分区数目

选择 参数

  1. -v 查看版本信息

命令操作参考

显示当前分区情况

[root@localhost ~]# fdisk -l
Disk /dev/sdb:100 GiB,107374182400 字节,209715200 个扇区
单元:扇区 / 1 * 512 = 512 字节
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x39e2d767

设备       启动  起点      末尾      扇区  大小 Id 类型
/dev/sdb1        2048 209715199 209713152  100G 83 Linux

查看硬盘的下有那东西,可以使用lsblk

[root@localhost ~]# lsblk
NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda             8:0    0  100G  0 disk 
├─sda1          8:1    0    1G  0 part /boot
└─sda2          8:2    0   99G  0 part 
  ├─rhel-root 253:0    0   50G  0 lvm  /
  ├─rhel-swap 253:1    0    4G  0 lvm  [SWAP]
  └─rhel-home 253:2    0   45G  0 lvm  /home
sdb             8:16   0  100G  0 disk 
└─sdb1          8:17   0  100G  0 part /shen
sr0            11:0    1  7.9G  0 rom  
[root@localhost ~]# 

8.格式化


注:格式化:目的是为了创建文件系统mkfs(MaKe FileSystem)

常见的格式化文件系统:fat32(单个文件不能超过4G)
ntfs(单个文件可以超过4G,兼容性差)
exfat(单个文件超过4G,兼容性好)
常见格式化命令:ext2、ext3、ext4、xfs、brfs

9挂载


格式:mount 【参数】

常用参数:

  1. -a 加载文件"/etc/fstab"中描述的所有文件系统
  2. -t 指定挂载类型
  3. -l 显示已加载的文件系统列表

挂载命令操作参考

[root@localhost ~]# df -h    //查看挂载
文件系统               容量  已用  可用 已用% 挂载点
devtmpfs               1.9G     0  1.9G    0% /dev
tmpfs                  1.9G     0  1.9G    0% /dev/shm
tmpfs                  1.9G  9.0M  1.9G    1% /run
tmpfs                  1.9G     0  1.9G    0% /sys/fs/cgroup
/dev/mapper/rhel-root   50G  1.9G   49G    4% /
/dev/sdb1              100G  746M  100G    1% /shen
/dev/mapper/rhel-home   46G  354M   45G    1% /home
/dev/sda1             1014M  179M  836M   18% /boot
tmpfs                  376M     0  376M    0% /run/user/0
[root@localhost ~]# 
[root@localhost ~]# mount /dev/sr0 /mnt   //这里是挂载
mount: /mnt: WARNING: device write-protected, mounted read-only.
[root@localhost ~]# 
[root@localhost ~]# df -h    //挂载之后查看能看见后面有/dev/sr0
文件系统               容量  已用  可用 已用% 挂载点
devtmpfs               1.9G     0  1.9G    0% /dev
tmpfs                  1.9G     0  1.9G    0% /dev/shm
tmpfs                  1.9G  9.0M  1.9G    1% /run
tmpfs                  1.9G     0  1.9G    0% /sys/fs/cgroup
/dev/mapper/rhel-root   50G  1.9G   49G    4% /
/dev/sdb1              100G  746M  100G    1% /shen
/dev/mapper/rhel-home   46G  354M   45G    1% /home
/dev/sda1             1014M  179M  836M   18% /boot
tmpfs                  376M     0  376M    0% /run/user/0
/dev/sr0               7.9G  7.9G     0  100% /mnt
[root@localhost ~]# 

取消挂载命令操作参考

[root@localhost ~]# df -h   
文件系统               容量  已用  可用 已用% 挂载点
devtmpfs               1.9G     0  1.9G    0% /dev
tmpfs                  1.9G     0  1.9G    0% /dev/shm
tmpfs                  1.9G  9.0M  1.9G    1% /run
tmpfs                  1.9G     0  1.9G    0% /sys/fs/cgroup
/dev/mapper/rhel-root   50G  1.9G   49G    4% /
/dev/sdb1              100G  746M  100G    1% /shen
/dev/mapper/rhel-home   46G  354M   45G    1% /home
/dev/sda1             1014M  179M  836M   18% /boot
tmpfs                  376M     0  376M    0% /run/user/0
/dev/sr0               7.9G  7.9G     0  100% /mnt
[root@localhost ~]# umount /mnt   //取消挂载
[root@localhost ~]# df -h
文件系统               容量  已用  可用 已用% 挂载点
devtmpfs               1.9G     0  1.9G    0% /dev
tmpfs                  1.9G     0  1.9G    0% /dev/shm
tmpfs                  1.9G  9.0M  1.9G    1% /run
tmpfs                  1.9G     0  1.9G    0% /sys/fs/cgroup
/dev/mapper/rhel-root   50G  1.9G   49G    4% /
/dev/sdb1              100G  746M  100G    1% /shen
/dev/mapper/rhel-home   46G  354M   45G    1% /home
/dev/sda1             1014M  179M  836M   18% /boot
tmpfs                  376M     0  376M    0% /run/user/0
[root@localhost ~]# 

10.永久挂载


永久挂载就是我们挂载之后, 关机再开机依然属于挂载状态。

[root@localhost ~]# vi /etc/fstab
[root@localhost ~]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Thu Jul  8 22:52:26 2021
#
# 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.
#
/dev/mapper/rhel-root   /                       xfs     defaults        0 0
UUID=9e0bf194-9b0e-4078-963d-805fadb6ab97 /boot                   xfs     defaults        0 0
/dev/mapper/rhel-home   /home                   xfs     defaults        0 0
/dev/mapper/rhel-swap   swap                    swap    defaults        0 0
UUID="2db18667-024d-43d0-bee9-41fe46f5c13e" /shen xfs defaults 0 0   //最好用uuid挂载。
[root@localhost ~]# 
[root@localhost ~]# mount -a
[root@localhost ~]# df -h
文件系统               容量  已用  可用 已用% 挂载点
devtmpfs               1.9G     0  1.9G    0% /dev
tmpfs                  1.9G     0  1.9G    0% /dev/shm
tmpfs                  1.9G  9.0M  1.9G    1% /run
tmpfs                  1.9G     0  1.9G    0% /sys/fs/cgroup
/dev/mapper/rhel-root   50G  1.9G   49G    4% /
/dev/sdb1              100G  746M  100G    1% /shen   //这里我们可以看见挂载成功
/dev/mapper/rhel-home   46G  354M   45G    1% /home
/dev/sda1             1014M  179M  836M   18% /boot
tmpfs                  376M     0  376M    0% /run/user/0
[root@localhost ~]# 

11.计划任务


格式:分、时、日、月、周 任务

  • */2 每两分钟
  • 1-10 每小时的第1到10分钟
  • 1,10 每小时的第1和第10分钟

命令操作参考(-e是写入)

[root@localhost ~]# crontab -l
*/5 * * * *  /bin/bash
[root@localhost ~]# 

12.日志服务与管理


rsyslog特点:

  • 支持多线程
  • 支持TCP、SSL、TLS、RELP等协议
  • 强大的过滤器,可实现过滤日志信息中的任意部分
  • 支持自定义输出格式
  • 适用于企业级别日志记录需求
  • 模块化

13.httpd编译安装


源码编辑安装三部曲:

  • ./configure
  • make
  • make install

命令操作参考


[root@localhost ~]# yum -y install openssl-devel pcre-devel expat-devel  //安装运行环境 
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
上次元数据过期检查:0:00:20 前,执行于 2021年07月11日 星期日 05时45分43秒。
依赖关系解决。
=================================================
 软件包         架构   版本         仓库    大小
=================================================
安装:
 expat-devel    x86_64 2.2.5-3.el8  BaseOS  55 k
 openssl-devel  x86_64 1:1.1.1c-15.el8
                                    BaseOS 2.3 M
 pcre-devel     x86_64 8.42-4.el8   BaseOS 551 k
安装依赖关系:
 keyutils-libs-devel
[root@localhost ~]# wget -c        //下载并安装apr和apr-util      https://mirrors.tuna.tsinghua.edu.cn/apache/apr/apr-1.7.0.tar.gz
[root@localhost ~]# wget -c  https://mirrors.tuna.tsinghua.edu.cn/apache/apr/apr-util-1.6.1.tar.gz
--2021-07-11 05:49:38--  https://mirrors.tuna.tsinghua.edu.cn/apache/apr/apr-util-1.6.1.tar.gz
正在解析主机 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.8.193, 2402:f000:1:408:8100::1
正在连接 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:554301 (541K) [application/octet-stream]
正在保存至: “apr-util-1.6.1.tar.gz”

apr-util-1.6.1.tar.gz        100%[==============================================>] 541.31K  2.37MB/s  用时 0.2s    

2021-07-11 05:49:38 (2.37 MB/s) - 已保存 “apr-util-1.6.1.tar.gz” [554301/554301])
[root@localhost ~]# 
[root@localhost ~]# ls
anaconda-ks.cfg   apr-util-1.6.1.tar.gz  shen
apr-1.7.0.tar.gz  liuqiangchishi
[root@localhost ~]# tar xf apr-util-1.6.1.tar.gz 
[root@localhost ~]# tar xf apr-1.7.0.tar.gz 
[root@localhost ~]# ls
anaconda-ks.cfg   apr-util-1.6.1         shen
apr-1.7.0         apr-util-1.6.1.tar.gz
apr-1.7.0.tar.gz  liuqiangchishi
[root@localhost ~]#
[root@localhost ~]# cd apr-1.7.0
[root@localhost apr-1.7.0]# 
[root@localhost apr-1.7.0]# vi configure
    cfgfile=${ofile}T
    trap "$RM \"$cfgfile\"; exit 1" 1 2 15
    #$RM "$cfgfile"  //利用查找命令找到这一行,并且注释掉。

[root@localhost apr-1.7.0]# ./configure --prefix=/usr/local/apr
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
Configuring APR library
Platform: x86_64-pc-linux-gnu
checking for working mkdir -p... yes
APR Version: 1.7.0
checking for chosen layout... apr
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/root/apr-1.7.0':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
[root@localhost apr-1.7.0]# 
[root@localhost ~]# yum -y install gcc-c++ -y   //安装编译器
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscrip
tion Management. You can use subscription-manager
 to register.
完毕!
[root@localhost ~]# yum -y install gcc
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscrip
tion Management. You can use subscription-manager
 to register.
上次元数据过期检查:0:13:54 前,执行于 2021年07月
11日 星期日 05时45分43秒。
[root@localhost apr-1.7.0]# ./configure  
略过
[root@localhost apr-1.7.0]# make
略过
[root@localhost apr-1.7.0]# make   install    //安装
make[1]: 进入目录“/root/apr-1.7.0”
make[1]: 对“local-all”无需做任何事。
make[1]: 离开目录“/root/apr-1.7.0”
/root/apr-1.7.0/build/mkdir.sh /usr/local/apr/lib /usr/local/apr/bin /usr/local/apr/build-1 \
             /usr/local/apr/lib/pkgconfig /usr/local/apr/include/apr-1
/usr/bin/install -c -m 644 /root/apr-1.7.0/include/apr.h /usr/local/apr/include/apr-1
for f in /root/apr-1.7.0/include/apr_*.h; do \
    /usr/bin/install -c -m 644 ${f} /usr/local/apr/include/apr-1; \
done
/bin/sh /root/apr-1.7.0/libtool --mode=install /usr/bin/install -c -m 755 libapr-1.la /usr/local/apr/lib
libtool: install: /usr/bin/install -c -m 755 .libs/libapr-1.so.0.7.0 /usr/local/apr/lib/libapr-1.so.0.7.0
libtool: install: (cd /usr/local/apr/lib && { ln -s -f libapr-1.so.0.7.0 libapr-1.so.0 || { rm -f libapr-1.so.0 && ln -s libapr-1.so.0.7.0 libapr-1.so.0; }; })
libtool: install: (cd /usr/local/apr/lib && { ln -s -f libapr-1.so.0.7.0 libapr-1.so || { rm -f libapr-1.so && ln -s libapr-1.so.0.7.0 libapr-1.so; }; })
libtool: install: /usr/bin/install -c -m 755 .libs/libapr-1.lai /usr/local/apr/lib/libapr-1.la
libtool: install: /usr/bin/install -c -m 755 .libs/libapr-1.a /usr/local/apr/lib/libapr-1.a
libtool: install: chmod 644 /usr/local/apr/lib/libapr-1.a
libtool: install: ranlib /usr/local/apr/lib/libapr-1.a
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/sbin" ldconfig -n /usr/local/apr/lib
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/apr/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the 'LD_RUN_PATH' environment variable
     during linking
   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to '/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
/usr/bin/install -c -m 644 apr.exp /usr/local/apr/lib/apr.exp
/usr/bin/install -c -m 644 apr.pc /usr/local/apr/lib/pkgconfig/apr-1.pc
for f in libtool shlibtool; do \
    if test -f ${f}; then /usr/bin/install -c -m 755 ${f} /usr/local/apr/build-1; fi; \
done
/usr/bin/install -c -m 755 /root/apr-1.7.0/build/mkdir.sh /usr/local/apr/build-1
for f in make_exports.awk make_var_export.awk; do \
    /usr/bin/install -c -m 644 /root/apr-1.7.0/build/${f} /usr/local/apr/build-1; \
done
/usr/bin/install -c -m 644 build/apr_rules.out /usr/local/apr/build-1/apr_rules.mk
/usr/bin/install -c -m 755 apr-config.out /usr/local/apr/bin/apr-1-config
[root@localhost apr-1.7.0]# 

apr-util安装
[root@localhost ~]# cd apr-util-1.6.1
[root@localhost apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
root@localhost apr-util-1.6.1]# make
root@localhost apr-util-1.6.1]# make  install
http安装
[root@localhost ~]# wget -c  https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.4.48.tar.gz
[root@localhost ~]# tar xf httpd-2.4.48.tar.gz
[root@localhost ~]# cd httpd-2.4.48/
[root@localhost httpd-2.4.48]# ./configure --prefix=/usr/local/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
[root@localhost httpd-2.4.48]# make
[root@localhost httpd-2.4.48]# make  install

//编辑安装完成之后启动httpd服务

root@localhost ~]# /usr/local/httpd/bin/apachectl start

il安装

[root@localhost ~]# cd apr-util-1.6.1
[root@localhost apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
root@localhost apr-util-1.6.1]# make
root@localhost apr-util-1.6.1]# make  install
http安装
[root@localhost ~]# wget -c  https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.4.48.tar.gz
[root@localhost ~]# tar xf httpd-2.4.48.tar.gz
[root@localhost ~]# cd httpd-2.4.48/
[root@localhost httpd-2.4.48]# ./configure --prefix=/usr/local/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
[root@localhost httpd-2.4.48]# make
[root@localhost httpd-2.4.48]# make  install

//编辑安装完成之后启动httpd服务

root@localhost ~]# /usr/local/httpd/bin/apachectl start

你可能感兴趣的:(linux)