理论:安装及管理程序------理论讲解

mac2024-03-30  28

文章目录

一:Linux应用程序基础1.1:应用程序与系统命令的关系1.2:典型应用程序的目录结构1.3:常见的软件包封装类型1.4RPM包管理工具 二:查询RPM软件包信息2.1:查询已安装的RPM软件信息2.2 查询未安装的RPM软件包文件中信息 三:安装、升级、卸载RPM软件包3.1:安装或升级RPM软件包3.2:卸载指定的RPM软件3.3 辅助选项 windows做共享3.4:维护RPM数据库3.5解决软件包依赖关系方法1)安装有依赖关系的多个软件时2)卸载有依赖关系的多个软件时3)忽略依赖关系 四:源代码编译安装4.1:源代码编译概述4.2:编译安装源代码包4.3:编译安装过程4.4 手工编译安装四步骤(1) tar解包(2)./configure 配置(3)make编译(make是转编译的过程)(4)make安装 手工编译安装步骤小结 前言: 了解Linux应用程序基础,学习如何查询RPM软件包信息了解安装、升级、卸载、 RPM软件包 ,如何与运用yum仓库,学习源代码编译安装

一:Linux应用程序基础

1.1:应用程序与系统命令的关系

方面系统命令应用程序文件位置一般在/bin和/bin目录中,或为Shell内部指令通常在/usr/和/usr/local目录中主要用途完成对系统的基本管理工作,例如IP配置工具(ifconfig)完成相对独立的其他辅助任务,例如网页浏览器,腾讯QQ适用环境一般只在字符操作界面中运行根据实际需要,有些程序可在图形界面中运行运行格式一般包括命令字、命令选项和命令参数通常没有固定的执行格式关系是独立的相对独立,多个文件支撑一个任务应用程序

1.2:典型应用程序的目录结构

–prefix=" 自定义安装" 用手动编译安装

/var/log 日志文件是共享的

1.3:常见的软件包封装类型

rpm:自动安装包,把安装过程的各种操作编译封装到里面,适合新手使用

deb:在乌班图(ubuntu,是界面)系统中使用,不在centos中使用

​ 题外话:1.LINUX家族,下面Redhat,红帽 三个认证(开源但是不是免费,基础服务免费)

​ 2.因为红帽的这个原因,有人不爽,就由此产生了社区(系统开发者,都是大佬),他们设计了centos

​ 服务器中用centos的多,政府不差钱,用的红帽的多

​ 有一个面向客户端的linux系统的是ubuntu系统(最好用),开源,纯免费,特别适用于软件开发人群

​ 全球中最好用,中国用不了,因为长城防火墙挡住了

​ 3.debian,是linux的早期版本系统,是乌版图的前身,服务端和客户端都具备功能后来衍生出了乌版图和kaili

​ 4.kaili是黑客专用的渗透工具,包括攻防攻击

​ kaili占用资源很少,通常是安装在树莓派中

​ 5.suse是德国的linux系统,被ISP运营商所使用(电信,移动,联通) 定制版

源代码软件包:原始代码,是人能看得懂的

jazz——————class,class看不懂,是机器能识别的

绿色免安装的软件包:解压后可以直接使用

1.4RPM包管理工具

yum可以解决RPM的依赖关系

红色是名字,版本号,发布次数

版本号第一个是大版本,第二个是小版本

i386,i686出现,就代表是32位系统

64位可以最大支持2t内存,瓶颈在于读写

现在已经有了内存数据库,redis

服务器只能插半高显卡

二:查询RPM软件包信息

2.1:查询已安装的RPM软件信息

rpm -q【子选项】 【软件名】

-q 查看基本信息,即是否安装

[root@localhost ~]# rpm -q httpd #查询httpd工具是否已安装 未安装软件包 httpd

常用选项

-qa 查看系统已安装的所有软件包

grep 过滤筛选

[root@localhost ~]# rpm -qa #查询当前系统已安装的所有软件包,显示过多,这里就不展示 [root@localhost ~]# rpm -qa | grep "mdadm" #后面加| grep筛选出想要查询的信息 mdadm-4.0-5.el7.x86_64

-qi 查看已安装的软件包的详细信息,-q已安装,-i(information),组合起来用

[root@localhost ~]# rpm -qi mdadm #查看mdadm的详细信息 Name : mdadm Version : 4.0 Release : 5.el7 Architecture: x86_64 Install Date: 2019年10月23日 星期三 13时36分47秒 Group : System Environment/Base Size : 1044798 License : GPLv2+ Signature : RSA/SHA256, 2017年08月11日 星期五 02时20分11秒, Key ID 24c6a8a7f4a80eb5 Source RPM : mdadm-4.0-5.el7.src.rpm Build Date : 2017年08月05日 星期六 05时44分20秒 Build Host : c1bm.rdu2.centos.org Relocations : (not relocatable) Packager : CentOS BuildSystem <http://bugs.centos.org> Vendor : CentOS URL : http://www.kernel.org/pub/linux/utils/raid/mdadm/ Summary : The mdadm program controls Linux md devices (software RAID arrays) Description : The mdadm program is used to create, manage, and monitor Linux MD (software RAID) devices. As such, it provides similar functionality to the raidtools package. However, mdadm is a single program, and it can perform almost all functions without a configuration file, though a configuration file can be used to help with some common tasks.

-ql 查看软件包安装的所有的文件列表(list)

[root@localhost ~]# rpm -ql mdadm /etc/cron.d/raid-check /etc/libreport/events.d/mdadm_event.conf /etc/sysconfig/raid-check /usr/lib/systemd/system-shutdown/mdadm.shutdown /usr/lib/systemd/system/mdadm-grow-continue@.service /usr/lib/systemd/system/mdadm-last-resort@.service /usr/lib/systemd/system/mdadm-last-resort@.timer /usr/lib/systemd/system/mdmon@.service /usr/lib/systemd/system/mdmonitor.service /usr/lib/tmpfiles.d/mdadm.conf /usr/lib/udev/rules.d/63-md-raid-arrays.rules /usr/lib/udev/rules.d/65-md-incremental.rules /usr/sbin/mdadm /usr/sbin/mdmon /usr/sbin/raid-check /usr/share/doc/mdadm-4.0 /usr/share/doc/mdadm-4.0/COPYING /usr/share/doc/mdadm-4.0/ChangeLog /usr/share/doc/mdadm-4.0/TODO /usr/share/doc/mdadm-4.0/mdadm.conf-example /usr/share/doc/mdadm-4.0/mdcheck /usr/share/doc/mdadm-4.0/syslog-events /usr/share/man/man4/md.4.gz /usr/share/man/man5/mdadm.conf.5.gz /usr/share/man/man8/mdadm.8.gz /usr/share/man/man8/mdmon.8.gz /var/run/mdadm

-qf 根据已知的文件,去查看它属于哪个软件包,由哪个软件包所安装

[root@localhost ~]# rpm -qf /usr/sbin/mdmon mdadm-4.0-5.el7.x86_64

-qc 查看软件包的所有配置文件 (配置文件后缀 conf,cnf,ini;前两个看得多,PHP的文件是inin)

[root@localhost ~]# rpm -qc mdadm /etc/cron.d/raid-check /etc/sysconfig/raid-check /usr/lib/tmpfiles.d/mdadm.conf

-qd 查看软件包的文档有哪些(what),在哪些位置(where)

[root@localhost ~]# rpm -qd mdadm /usr/share/doc/mdadm-4.0/COPYING /usr/share/doc/mdadm-4.0/ChangeLog /usr/share/doc/mdadm-4.0/TODO /usr/share/doc/mdadm-4.0/mdadm.conf-example /usr/share/doc/mdadm-4.0/mdcheck /usr/share/doc/mdadm-4.0/syslog-events /usr/share/man/man4/md.4.gz /usr/share/man/man5/mdadm.conf.5.gz /usr/share/man/man8/mdadm.8.gz /usr/share/man/man8/mdmon.8.gz

2.2 查询未安装的RPM软件包文件中信息

rpm -qp 【子选项】RPM包文件

常用选项

-qpi 查看未安装的软件包的详细信息

-qpl 查看未安装软件包的所有文件

-qpc 查看未安装软件包的所有配置文件 (配置文件后缀 conf,cnf,ini;前两个看得多,PHP的文件是inin)

-qpd 查看未安装软件包的文档 小结:未安装的命令选项就是在已安装的命令选项上多一个p,没有-a,-f子选项

三:安装、升级、卸载RPM软件包

3.1:安装或升级RPM软件包

安装或升级RPM软件

rpm 【选项】 RPM包文件

常用选项

-i install 安装软件包

-U 更新软件包,若没有该软件包,则自动安装该软件

-F 检查更新软件包,若没有该软件包,不会自动安装该软件

3.2:卸载指定的RPM软件

rpm -e 软件名

-e 卸载

3.3 辅助选项

–force 强制执行

–nodeps 解决依赖性关系(但是基本上没啥用,因为这个命令的作用是忽略依赖关系,直接安装,治标不治本)

-h 友好显示(即以#号键显示安装进度条)

-v 显示详细过程信息

例如:rpm -qd httpd 查看httpd的安装包的文档

yum remore httpd -y 重新安装httpd

rpm -ivh 安装并显示进度和详细过程

rpm -evh 卸载并显示进度和详细过程

windows做共享

1.用户和组配置

2.本地策略配置

开启来宾访问权限

安全选项,

3.高级共享设置

4.共享文件夹属性

smbclient -L //192.168.0.152/ 进入自身主机的共享中心

[root@localhost ~]# smbclient -L //192.168.0.152/ Enter SAMBA\root's password: OS=[Windows 10 Enterprise 10240] Server=[Windows 10 Enterprise 6.3] Sharename Type Comment --------- ---- ------- ADMIN$ Disk 远程管理 C$ Disk 默认共享 D$ Disk 默认共享 E$ Disk 默认共享 G$ Disk 默认共享 IPC$ IPC 远程 IPC linuxs Disk Users Disk Connection to 192.168.0.152 failed (Error NT_STATUS_RESOURCE_NAME_NOT_FOUND) NetBIOS over TCP disabled -- no workgroup available

最后的步骤:mount.cifs //192.168.0.152/linuxs /mnt,把共享文件夹linuxs挂载到mnt文件夹上

[root@localhost ~]# mount.cifs //192.168.0.152/linuxs /mnt Password for root@//192.168.0.152/linuxs: [root@localhost ~]# ls -l /mnt #查看挂载点内文件 总用量 7208 -rwxr-xr-x. 1 root root 982243 10月 31 08:52 apr-1.4.6.tar.gz -rwxr-xr-x. 1 root root 774770 10月 31 08:52 apr-util-1.4.1.tar.gz -rwxr-xr-x. 1 root root 5616185 10月 31 08:53 httpd-2.4.2.tar.gz

查看挂载:df -h,加上-T查看类型

[root@localhost ~]# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/mapper/centos-root 20G 3.3G 17G 17% / devtmpfs 977M 0 977M 0% /dev tmpfs 993M 0 993M 0% /dev/shm tmpfs 993M 9.1M 984M 1% /run tmpfs 993M 0 993M 0% /sys/fs/cgroup /dev/sda1 6.0G 161M 5.9G 3% /boot /dev/mapper/centos-home 10G 50M 10G 1% /home tmpfs 199M 12K 199M 1% /run/user/42 tmpfs 199M 0 199M 0% /run/user/0 /dev/md0 40G 33M 40G 1% /md0 //192.168.0.152/linuxs 455G 31G 425G 7% /mnt [root@localhost ~]# df -Th 文件系统 类型 容量 已用 可用 已用% 挂载点 /dev/mapper/centos-root xfs 20G 3.3G 17G 17% / devtmpfs devtmpfs 977M 0 977M 0% /dev tmpfs tmpfs 993M 0 993M 0% /dev/shm tmpfs tmpfs 993M 9.1M 984M 1% /run tmpfs tmpfs 993M 0 993M 0% /sys/fs/cgroup /dev/sda1 xfs 6.0G 161M 5.9G 3% /boot /dev/mapper/centos-home xfs 10G 50M 10G 1% /home tmpfs tmpfs 199M 12K 199M 1% /run/user/42 tmpfs tmpfs 199M 0 199M 0% /run/user/0 /dev/md0 xfs 40G 33M 40G 1% /md0 //192.168.0.152/linuxs cifs 455G 31G 425G 7% /mnt

解除挂载:umount /mnt 解除挂载点,也可以输入解除要挂载共享文件夹,怎么方便怎么来

[root@localhost ~]# umount /mnt [root@localhost ~]# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/mapper/centos-root 20G 3.3G 17G 17% / devtmpfs 977M 0 977M 0% /dev tmpfs 993M 0 993M 0% /dev/shm tmpfs 993M 9.1M 984M 1% /run tmpfs 993M 0 993M 0% /sys/fs/cgroup /dev/sda1 6.0G 161M 5.9G 3% /boot /dev/mapper/centos-home 10G 50M 10G 1% /home tmpfs 199M 12K 199M 1% /run/user/42 tmpfs 199M 0 199M 0% /run/user/0 /dev/md0 40G 33M 40G 1% /md0

3.4:维护RPM数据库

init 初始化的意思,rebuild重建 db(database)数据库

导入验证公共密钥 --import 导入的意思,仅作校验作用,没有其他作用

1.点开虚拟机,配置把镜像文件挂载进去,在右下角cd中,虚拟机设置,设备状态勾选已连接

有绿色亮点代表已经运行,接下来进行挂载

之前讲的是共享文件挂载

[root@localhost ~]# cd /dev [root@localhost dev]# ls agpgart log sda2 tty15 tty42 ttyS3 autofs loop-control sdb tty16 tty43 uhid block lp0 sdb1 tty17 tty44 uinput bsg lp1 sdc tty18 tty45 urandom btrfs-control lp2 sdc1 tty19 tty46 usbmon0 bus lp3 sdd tty2 tty47 usbmon1 cdrom mapper sdd1 tty20 tty48 usbmon2 centos mcelog sde tty21 tty49 vcs char md0 sde1 tty22 tty5 vcs1 console md1 sg0 tty23 tty50 vcs2 core md2 sg1 tty24 tty51 vcs3 cpu mem sg2 tty25 tty52 vcs4 cpu_dma_latency mqueue sg3 tty26 tty53 vcs5 crash net sg4 tty27 tty54 vcs6 disk network_latency sg5 tty28 tty55 vcsa dm-0 network_throughput shm tty29 tty56 vcsa1 dm-1 null snapshot tty3 tty57 vcsa2 dm-2 nvram snd tty30 tty58 vcsa3 dri oldmem sr0 tty31 tty59 vcsa4 fb0 port stderr tty32 tty6 vcsa5 fd ppp stdin tty33 tty60 vcsa6 full ptmx stdout tty34 tty61 vfio fuse pts tty tty35 tty62 vga_arbiter hidraw0 random tty0 tty36 tty63 vhci hpet raw tty1 tty37 tty7 vhost-net hugepages rfkill tty10 tty38 tty8 vmci hwrng rtc tty11 tty39 tty9 vsock initctl rtc0 tty12 tty4 ttyS0 zero input sda tty13 tty40 ttyS1 kmsg sda1 tty14 tty41 ttyS2

mout 设备名称 挂载点(本地目录)

mount /dev/sr0(光盘驱动设备) 或 /mnt/

[root@localhost dev]# mount /dev/sr0 /mnt mount: /dev/sr0 写保护,将以只读方式挂载 [root@localhost dev]# ls -l /mnt 总用量 664 -rw-rw-r--. 3 root root 14 9月 5 2017 CentOS_BuildTag drwxr-xr-x. 3 root root 2048 9月 5 2017 EFI -rw-rw-r--. 3 root root 227 8月 30 2017 EULA -rw-rw-r--. 3 root root 18009 12月 10 2015 GPL drwxr-xr-x. 3 root root 2048 9月 5 2017 images drwxr-xr-x. 2 root root 2048 9月 5 2017 isolinux drwxr-xr-x. 2 root root 2048 9月 5 2017 LiveOS drwxrwxr-x. 2 root root 641024 9月 5 2017 Packages drwxr-xr-x. 2 root root 4096 9月 5 2017 repodata -rw-rw-r--. 3 root root 1690 12月 10 2015 RPM-GPG-KEY-CentOS-7 -rw-rw-r--. 3 root root 1690 12月 10 2015 RPM-GPG-KEY-CentOS-Testing-7 -r--r--r--. 1 root root 2883 9月 6 2017 TRANS.TBL

RPM-GPG-KEY-CentOS-7就是光驱内的公钥 光驱里面的packages目录 专门存放软件包

bind没有安装,可以安装个bind(DNS方面的工具)软件

[root@localhost Packages]# rpm -q bind 未安装软件包 bind [root@localhost Packages]# rpm -ivh bind- #此时按两下tab键,可以把前面为bind的文件全部展示出来 bind-9.9.4-50.el7.x86_64.rpm bind-chroot-9.9.4-50.el7.x86_64.rpm bind-dyndb-ldap-11.1-3.el7.x86_64.rpm bind-libs-9.9.4-50.el7.x86_64.rpm bind-libs-lite-9.9.4-50.el7.x86_64.rpm bind-license-9.9.4-50.el7.noarch.rpm bind-pkcs11-9.9.4-50.el7.x86_64.rpm bind-pkcs11-libs-9.9.4-50.el7.x86_64.rpm bind-pkcs11-utils-9.9.4-50.el7.x86_64.rpm bind-utils-9.9.4-50.el7.x86_64.rpm [root@localhost Packages]# rpm -ivh bind-9.9.4-50.el7.x86_64.rpm 警告:bind-9.9.4-50.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY 准备中... ################################# [100%] 正在升级/安装... 1:bind-32:9.9.4-50.el7 ################################# [100%]

可以-q查看验证一下,还有-ql,-qc,-qf,-qd等选项可以试一试

[root@localhost Packages]# rpm -q bind bind-9.9.4-50.el7.x86_64

然后再试试卸载命令-e

[root@localhost Packages]# rpm -evh bind 准备中... ################################# [100%] 正在清理/删除... 1:bind-32:9.9.4-50.el7 ################################# [100%] [root@localhost Packages]# rpm -q bind #验证是否已卸载 未安装软件包 bind

bind没有依赖关系,httpd有依赖关系

[root@localhost Packages]# rpm -ivh httpd-2.4.6-67.el7.centos.x86_64.rpm 警告:httpd-2.4.6-67.el7.centos.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY 错误:依赖检测失败: /etc/mime.types 被 httpd-2.4.6-67.el7.centos.x86_64 需要 httpd-tools = 2.4.6-67.el7.centos 被 httpd-2.4.6-67.el7.centos.x86_64 需要 libapr-1.so.0()(64bit) 被 httpd-2.4.6-67.el7.centos.x86_64 需要 libaprutil-1.so.0()(64bit) 被 httpd-2.4.6-67.el7.centos.x86_64 需要

rpm自带解决依赖关系,但是基本上没啥用,yum仓库可以解决这种依赖关系

yum仓库分两种,一种是私网仓库,公网仓库(自建仓库,官方仓库),在没有网的情况下,自己搭建

先简单介绍一下yum公网仓库,就是在有互联网的情况下,电脑连接官网的一个平台,去下载安装软件 yum list,在有网的情况查看公网仓库

[root@localhost Packages]# yum list

使用yum安装bind

[root@localhost Packages]# yum install bind #安装bind 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.163.com * updates: ap.stykers.moe 正在解决依赖关系 #自动查找分析依赖关系 --> 正在检查事务 ---> 软件包 bind.x86_64.32.9.11.4-9.P2.el7 将被 安装 --> 正在处理依赖关系 bind-libs-lite(x86-64) = 32:9.11.4-9.P2.el7,它被软件包 32:bind-9.11.4-9.P2.el7.x86_64 需要 --> 正在处理依赖关系 bind-libs(x86-64) = 32:9.11.4-9.P2.el7,它被软件包 32:bind-9.11.4-9.P2.el7.x86_64 需要 --> 正在处理依赖关系 liblwres.so.160()(64bit),它被软件包 32:bind-9.11.4-9.P2.el7.x86_64 需要 --> 正在处理依赖关系 libisccfg.so.160()(64bit),它被软件包 32:bind-9.11.4-9.P2.el7.x86_64 需要 --> 正在处理依赖关系 libisccc.so.160()(64bit),它被软件包 32:bind-9.11.4-9.P2.el7.x86_64 需要 --> 正在处理依赖关系 libisc.so.169()(64bit),它被软件包 32:bind-9.11.4-9.P2.el7.x86_64 需要 --> 正在处理依赖关系 libdns.so.1102()(64bit),它被软件包 32:bind-9.11.4-9.P2.el7.x86_64 需要 --> 正在处理依赖关系 libbind9.so.160()(64bit),它被软件包 32:bind-9.11.4-9.P2.el7.x86_64 需要 --> 正在检查事务 ---> 软件包 bind-libs.x86_64.32.9.9.4-50.el7 将被 升级 --> 正在处理依赖关系 bind-libs = 32:9.9.4-50.el7,它被软件包 32:bind-utils-9.9.4-50.el7.x86_64 需要 --> 正在处理依赖关系 libbind9.so.90()(64bit),它被软件包 32:bind-utils-9.9.4-50.el7.x86_64 需要 --> 正在处理依赖关系 libdns.so.100()(64bit),它被软件包 32:bind-utils-9.9.4-50.el7.x86_64 需要 --> 正在处理依赖关系 libisc.so.95()(64bit),它被软件包 32:bind-utils-9.9.4-50.el7.x86_64 需要 --> 正在处理依赖关系 libisccc.so.90()(64bit),它被软件包 32:bind-utils-9.9.4-50.el7.x86_64 需要 --> 正在处理依赖关系 libisccfg.so.90()(64bit),它被软件包 32:bind-utils-9.9.4-50.el7.x86_64 需要 --> 正在处理依赖关系 liblwres.so.90()(64bit),它被软件包 32:bind-utils-9.9.4-50.el7.x86_64 需要 ---> 软件包 bind-libs.x86_64.32.9.11.4-9.P2.el7 将被 更新 --> 正在处理依赖关系 bind-license = 32:9.11.4-9.P2.el7,它被软件包 32:bind-libs-9.11.4-9.P2.el7.x86_64 需要 ---> 软件包 bind-libs-lite.x86_64.32.9.9.4-50.el7 将被 升级 --> 正在处理依赖关系 libdns-export.so.100()(64bit),它被软件包 12:dhclient-4.2.5-58.el7.centos.x86_64 需要 --> 正在处理依赖关系 libisc-export.so.95()(64bit),它被软件包 12:dhclient-4.2.5-58.el7.centos.x86_64 需要 ---> 软件包 bind-libs-lite.x86_64.32.9.11.4-9.P2.el7 将被 更新 --> 正在检查事务 ---> 软件包 bind-license.noarch.32.9.9.4-50.el7 将被 升级 ---> 软件包 bind-license.noarch.32.9.11.4-9.P2.el7 将被 更新 ---> 软件包 bind-utils.x86_64.32.9.9.4-50.el7 将被 升级 ---> 软件包 bind-utils.x86_64.32.9.11.4-9.P2.el7 将被 更新 ---> 软件包 dhclient.x86_64.12.4.2.5-58.el7.centos 将被 升级 ---> 软件包 dhclient.x86_64.12.4.2.5-77.el7.centos 将被 更新 --> 正在处理依赖关系 dhcp-libs(x86-64) = 12:4.2.5-77.el7.centos,它被软件包 12:dhclient-4.2.5-77.el7.centos.x86_64 需要 --> 正在处理依赖关系 dhcp-common = 12:4.2.5-77.el7.centos,它被软件包 12:dhclient-4.2.5-77.el7.centos.x86_64 需要 --> 正在处理依赖关系 libisc-export.so.169()(64bit),它被软件包 12:dhclient-4.2.5-77.el7.centos.x86_64 需要 --> 正在处理依赖关系 libdns-export.so.1102()(64bit),它被软件包 12:dhclient-4.2.5-77.el7.centos.x86_64 需要 --> 正在检查事务 ---> 软件包 bind-export-libs.x86_64.32.9.11.4-9.P2.el7 将被 安装 ---> 软件包 dhcp-common.x86_64.12.4.2.5-58.el7.centos 将被 升级 ---> 软件包 dhcp-common.x86_64.12.4.2.5-77.el7.centos 将被 更新 ---> 软件包 dhcp-libs.x86_64.12.4.2.5-58.el7.centos 将被 升级 ---> 软件包 dhcp-libs.x86_64.12.4.2.5-77.el7.centos 将被 更新 --> 解决依赖关系完成 依赖关系解决 #反馈依赖关系解决 ================================================================================= Package 架构 版本 源 大小 ================================================================================= 正在安装: bind x86_64 32:9.11.4-9.P2.el7 base 2.3 M 为依赖而安装: bind-export-libs x86_64 32:9.11.4-9.P2.el7 base 1.1 M 为依赖而更新: bind-libs x86_64 32:9.11.4-9.P2.el7 base 154 k bind-libs-lite x86_64 32:9.11.4-9.P2.el7 base 1.1 M bind-license noarch 32:9.11.4-9.P2.el7 base 88 k bind-utils x86_64 32:9.11.4-9.P2.el7 base 258 k dhclient x86_64 12:4.2.5-77.el7.centos base 285 k dhcp-common x86_64 12:4.2.5-77.el7.centos base 176 k dhcp-libs x86_64 12:4.2.5-77.el7.centos base 133 k 事务概要 ================================================================================= 安装 1 软件包 (+1 依赖软件包) 升级 ( 7 依赖软件包) #反馈将要安装 总下载量:5.6 M Is this ok [y/d/N]: y #询问是否安装 Downloading packages: No Presto metadata available for base 警告:/var/cache/yum/x86_64/7/base/packages/bind-9.11.4-9.P2.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY bind-9.11.4-9.P2.el7.x86_64.rpm 的公钥尚未安装 (1/9): bind-9.11.4-9.P2.el7.x86_64.rpm | 2.3 MB 00:00:00 (2/9): bind-export-libs-9.11.4-9.P2.el7.x86_64.rpm | 1.1 MB 00:00:00 (3/9): bind-license-9.11.4-9.P2.el7.noarch.rpm | 88 kB 00:00:00 (4/9): bind-utils-9.11.4-9.P2.el7.x86_64.rpm | 258 kB 00:00:00 (5/9): dhclient-4.2.5-77.el7.centos.x86_64.rpm | 285 kB 00:00:00 (6/9): dhcp-common-4.2.5-77.el7.centos.x86_64.rpm | 176 kB 00:00:00 (7/9): dhcp-libs-4.2.5-77.el7.centos.x86_64.rpm | 133 kB 00:00:00 (8/9): bind-libs-lite-9.11.4-9.P2.el7.x86_64.rpm | 1.1 MB 00:00:00 (9/9): bind-libs-9.11.4-9.P2.el7.x86_64.rpm | 154 kB 00:00:01 --------------------------------------------------------------------------------- 总计 4.0 MB/s | 5.6 MB 00:01 从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 检索密钥 #自动解决密钥问题 导入 GPG key 0xF4A80EB5: 用户ID : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>" 指纹 : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5 软件包 : centos-release-7-4.1708.el7.centos.x86_64 (@anaconda) 来自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 是否继续?[y/N]:y #询问是否继续 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在更新 : 12:dhcp-libs-4.2.5-77.el7.centos.x86_64 1/16 正在更新 : 32:bind-license-9.11.4-9.P2.el7.noarch 2/16 正在更新 : 32:bind-libs-lite-9.11.4-9.P2.el7.x86_64 3/16 正在更新 : 32:bind-libs-9.11.4-9.P2.el7.x86_64 4/16 正在更新 : 12:dhcp-common-4.2.5-77.el7.centos.x86_64 5/16 正在安装 : 32:bind-export-libs-9.11.4-9.P2.el7.x86_64 6/16 正在更新 : 12:dhclient-4.2.5-77.el7.centos.x86_64 7/16 正在更新 : 32:bind-utils-9.11.4-9.P2.el7.x86_64 8/16 正在安装 : 32:bind-9.11.4-9.P2.el7.x86_64 9/16 /var/tmp/rpm-tmp.bKHvbN:行59: /etc/selinux/mls/rpmbooleans.custom: 没有那个文件或目录 grep: /etc/selinux/mls/rpmbooleans.custom: 没有那个文件或目录 /var/tmp/rpm-tmp.bKHvbN:行72: /etc/selinux/mls/rpmbooleans.custom: 没有那个文件或目录 ValueError: 没有管理 SELinux 策略或者无法访问存储。 清理 : 12:dhclient-4.2.5-58.el7.centos.x86_64 10/16 清理 : 12:dhcp-common-4.2.5-58.el7.centos.x86_64 11/16 清理 : 32:bind-libs-lite-9.9.4-50.el7.x86_64 12/16 清理 : 32:bind-utils-9.9.4-50.el7.x86_64 13/16 清理 : 12:dhcp-libs-4.2.5-58.el7.centos.x86_64 14/16 清理 : 32:bind-libs-9.9.4-50.el7.x86_64 15/16 清理 : 32:bind-license-9.9.4-50.el7.noarch 16/16 验证中 : 32:bind-license-9.11.4-9.P2.el7.noarch 1/16 验证中 : 32:bind-export-libs-9.11.4-9.P2.el7.x86_64 2/16 验证中 : 32:bind-libs-9.11.4-9.P2.el7.x86_64 3/16 验证中 : 12:dhcp-common-4.2.5-77.el7.centos.x86_64 4/16 验证中 : 32:bind-libs-lite-9.11.4-9.P2.el7.x86_64 5/16 验证中 : 32:bind-utils-9.11.4-9.P2.el7.x86_64 6/16 验证中 : 32:bind-9.11.4-9.P2.el7.x86_64 7/16 验证中 : 12:dhclient-4.2.5-77.el7.centos.x86_64 8/16 验证中 : 12:dhcp-libs-4.2.5-77.el7.centos.x86_64 9/16 验证中 : 12:dhcp-libs-4.2.5-58.el7.centos.x86_64 10/16 验证中 : 12:dhcp-common-4.2.5-58.el7.centos.x86_64 11/16 验证中 : 32:bind-license-9.9.4-50.el7.noarch 12/16 验证中 : 32:bind-libs-lite-9.9.4-50.el7.x86_64 13/16 验证中 : 32:bind-utils-9.9.4-50.el7.x86_64 14/16 验证中 : 32:bind-libs-9.9.4-50.el7.x86_64 15/16 验证中 : 12:dhclient-4.2.5-58.el7.centos.x86_64 16/16 已安装: bind.x86_64 32:9.11.4-9.P2.el7 作为依赖被安装: bind-export-libs.x86_64 32:9.11.4-9.P2.el7 作为依赖被升级: bind-libs.x86_64 32:9.11.4-9.P2.el7 bind-libs-lite.x86_64 32:9.11.4-9.P2.el7 bind-license.noarch 32:9.11.4-9.P2.el7 bind-utils.x86_64 32:9.11.4-9.P2.el7 dhclient.x86_64 12:4.2.5-77.el7.centos dhcp-common.x86_64 12:4.2.5-77.el7.centos dhcp-libs.x86_64 12:4.2.5-77.el7.centos 完毕!

-q查询一下

[root@localhost Packages]# rpm -q bind bind-9.11.4-9.P2.el7.x86_64 #显示已安装

yum remove 卸载

[root@localhost Packages]# yum remove bind #卸载bind 已加载插件:fastestmirror, langpacks 正在解决依赖关系 --> 正在检查事务 ---> 软件包 bind.x86_64.32.9.11.4-9.P2.el7 将被 删除 --> 解决依赖关系完成 依赖关系解决 ================================================================================= Package 架构 版本 源 大小 ================================================================================= 正在删除: bind x86_64 32:9.11.4-9.P2.el7 @base 5.4 M 事务概要 ================================================================================= 移除 1 软件包 安装大小:5.4 M 是否继续?[y/N]:y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction 正在删除 : 32:bind-9.11.4-9.P2.el7.x86_64 1/1 grep: /etc/selinux/mls/rpmbooleans.custom: 没有那个文件或目录 ValueError: 没有管理 SELinux 策略或者无法访问存储。 警告:%postun(bind-32:9.11.4-9.P2.el7.x86_64) 脚本执行失败,退出状态码为 1 Non-fatal POSTUN scriptlet failure in rpm package 32:bind-9.11.4-9.P2.el7.x86_64 验证中 : 32:bind-9.11.4-9.P2.el7.x86_64 1/1 删除: bind.x86_64 32:9.11.4-9.P2.el7 完毕!

再次使用安装bind,后面跟-y,可以提前确定y,省去了中间确认的时间

[root@localhost Packages]# yum install bind -y 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.163.com * updates: ap.stykers.moe 正在解决依赖关系 --> 正在检查事务 ---> 软件包 bind.x86_64.32.9.11.4-9.P2.el7 将被 安装 --> 解决依赖关系完成 依赖关系解决 ================================================================================= Package 架构 版本 源 大小 ================================================================================= 正在安装: bind x86_64 32:9.11.4-9.P2.el7 base 2.3 M 事务概要 ================================================================================= 安装 1 软件包 总下载量:2.3 M 安装大小:5.4 M Downloading packages: bind-9.11.4-9.P2.el7.x86_64.rpm | 2.3 MB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在安装 : 32:bind-9.11.4-9.P2.el7.x86_64 1/1 /var/tmp/rpm-tmp.L9NQI8:行59: /etc/selinux/mls/rpmbooleans.custom: 没有那个文件或目录 grep: /etc/selinux/mls/rpmbooleans.custom: 没有那个文件或目录 /var/tmp/rpm-tmp.L9NQI8:行72: /etc/selinux/mls/rpmbooleans.custom: 没有那个文件或目录 ValueError: 没有管理 SELinux 策略或者无法访问存储。 验证中 : 32:bind-9.11.4-9.P2.el7.x86_64 1/1 已安装: bind.x86_64 32:9.11.4-9.P2.el7 完毕!

删除的话,用rpm -e删除

[root@localhost Packages]# rpm -evh bind 准备中... ################################# [100%] 正在清理/删除... 1:bind-32:9.11.4-9.P2.el7 ################################# [100%] grep: /etc/selinux/mls/rpmbooleans.custom: 没有那个文件或目录 ValueError: 没有管理 SELinux 策略或者无法访问存储。 警告:%postun(bind-32:9.11.4-9.P2.el7.x86_64) 脚本执行失败,退出状态码为 1 [root@localhost Packages]# rpm -q bind #删除掉了 未安装软件包 bind [root@localhost Packages]# yum remove bind 已加载插件:fastestmirror, langpacks 参数 bind 没有匹配 不删除任何软件包

接下来再介绍一下在没网络下如何搭建本地的yum仓库

这里需要把公网的yum缓存先清理掉,yum clean all

[root@localhost ~]# yum clean all '清理yum缓存' 已加载插件:fastestmirror, langpacks 正在清理软件源: base extras updates Cleaning up everything Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos Cleaning up list of fastest mirrors

也有可能出现这个情况,这是因为yum已被占用,需要把被锁定的pid给强制删除

[root@localhost ~]# yum clean all 已加载插件:fastestmirror, langpacks /var/run/yum.pid 已被锁定,PID 为 2597 的另一个程序正在运行。 '被占用' Another app is currently holding the yum lock; waiting for it to exit... 另一个应用程序是:PackageKit 内存:158 M RSS (570 MB VSZ) 已启动: Tue Nov 5 08:30:41 2019 - 02:08之前 状态 :睡眠中,进程ID:2597 Another app is currently holding the yum lock; waiting for it to exit... 另一个应用程序是:PackageKit 内存:158 M RSS (570 MB VSZ) 已启动: Tue Nov 5 08:30:41 2019 - 02:10之前 状态 :睡眠中,进程ID:2597 [root@localhost ~]# rm -f /var/run/yum.pid '强行删除/var/run/yum.pid' [root@localhost ~]# yum clean all '再次启用yum clean all' 已加载插件:fastestmirror, langpacks 正在清理软件源: base extras updates Cleaning up everything Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos Cleaning up list of fastest mirrors

打开配置文件目录/etc/yum.repos.d 这个目录就相当于仓库,默认情况下是公网仓库,如果使用私网仓库就需要对其进行相关的配置修改(后缀是repo的就是 yum配置文件)

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

新建一个bak目录,把公网yum数据放进bak中,然后再重新创建一个配置文件abc,写入信息

[root@localhost yum.repos.d]# yum clean all '清除之前公网仓库的缓存' [root@localhost yum.repos.d]# yum list '再次查看' 已加载插件:fastestmirror, langpacks Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误" One of the configured repositories failed (未知), and yum doesn't have enough cached data to continue. At this point the only safe thing yum can do is fail. There are a few ways to work "fix" this: 1. Contact the upstream for the repository and get them to fix the problem. 2. Reconfigure the baseurl/etc. for the repository, to point to a working upstream. This is most often useful if you are using a newer distribution release than is supported by the repository (and the packages for the previous distribution release still work). 3. Run the command with the repository temporarily disabled yum --disablerepo=<repoid> ... 4. Disable the repository permanently, so yum won't use it by default. Yum will then just ignore the repository until you permanently enable it again or use --enablerepo for temporary usage: yum-config-manager --disable <repoid> or subscription-manager repos --disable=<repoid> 5. Configure the failing repository to be skipped, if it is unavailable. Note that yum will try to contact the repo. when it runs most commands, so will have to try and fail each time (and thus. yum will be be much slower). If it is a very temporary problem though, this is often a nice compromise: yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true Cannot find a valid baseurl for repo: base/7/x86_64 [root@localhost yum.repos.d]# ls '查看当前文件夹内容' CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo [root@localhost yum.repos.d]# mkdir bak '创建文件夹bak' [root@localhost yum.repos.d]# mv CentOS-* bak/ '把当前所有配置文件移动到bak中' [root@localhost yum.repos.d]# ls bak [root@localhost yum.repos.d]# mount /dev/sr0 /mnt '挂载镜像文件' mount: /dev/sr0 写保护,将以只读方式挂载 [root@localhost yum.repos.d]# vim abc.repo '重新创建yum配置文件' [abc] '描述信息' name=test '名字叫test' baseurl=file:///mnt '文件包地址为/mnt,镜像文件的挂载点' enabled=1 '启用软件仓库,0就是不开启' gpgcheck=0 '不检查验证密钥' ~ ~ :wq '保存退出' [root@localhost yum.repos.d]# ls bak abc.repo [root@localhost yum.repos.d]# yum list '再次查看' 已加载插件:fastestmirror, langpacks abc | 3.6 kB 00:00 (1/2): abc/group_gz | 156 kB 00:00 (2/2): abc/primary_db | 3.1 MB 00:00 Determining fastest mirrors '有反应了' 已安装的软件包 GConf2.x86_64 3.2.6-8.el7 @anaconda GeoIP.x86_64 1.5.0-11.el7 @anaconda ...... ...... yum-plugin-versionlock.noarch 1.1.31-42.el7 abc zlib-devel.x86_64 1.2.7-17.el7 abc zsh.x86_64 5.0.2-28.el7 abc zziplib.x86_64 0.13.62-5.el7 abc

安装bind,yum install bind -y

[root@localhost yum.repos.d]# yum install bind -y '提前确定,免交互' 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile 正在解决依赖关系 --> 正在检查事务 ---> 软件包 bind.x86_64.32.9.9.4-50.el7 将被 安装 --> 解决依赖关系完成 依赖关系解决 ================================================================================ Package 架构 版本 源 大小 ================================================================================ 正在安装: bind x86_64 32:9.9.4-50.el7 abc 1.8 M 事务概要 ================================================================================ 安装 1 软件包 总下载量:1.8 M 安装大小:4.3 M Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction 正在安装 : 32:bind-9.9.4-50.el7.x86_64 1/1 验证中 : 32:bind-9.9.4-50.el7.x86_64 1/1 已安装: bind.x86_64 32:9.9.4-50.el7 完毕!

安装httpd yum install httpd -y

[root@localhost yum.repos.d]# yum install httpd -y 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile 正在解决依赖关系 --> 正在检查事务 ---> 软件包 httpd.x86_64.0.2.4.6-67.el7.centos 将被 安装 --> 正在处理依赖关系 httpd-tools = 2.4.6-67.el7.centos,它被软件包 httpd-2.4.6-67.el7.centos.x86_64 需要 --> 正在处理依赖关系 /etc/mime.types,它被软件包 httpd-2.4.6-67.el7.centos.x86_64 需要 --> 正在处理依赖关系 libaprutil-1.so.0()(64bit),它被软件包 httpd-2.4.6-67.el7.centos.x86_64 需要 --> 正在处理依赖关系 libapr-1.so.0()(64bit),它被软件包 httpd-2.4.6-67.el7.centos.x86_64 需要 --> 正在检查事务 ---> 软件包 apr.x86_64.0.1.4.8-3.el7 将被 安装 ---> 软件包 apr-util.x86_64.0.1.5.2-6.el7 将被 安装 ---> 软件包 httpd-tools.x86_64.0.2.4.6-67.el7.centos 将被 安装 ---> 软件包 mailcap.noarch.0.2.1.41-2.el7 将被 安装 --> 解决依赖关系完成 依赖关系解决 ================================================================================ Package 架构 版本 源 大小 ================================================================================ 正在安装: httpd x86_64 2.4.6-67.el7.centos abc 2.7 M 为依赖而安装: apr x86_64 1.4.8-3.el7 abc 103 k apr-util x86_64 1.5.2-6.el7 abc 92 k httpd-tools x86_64 2.4.6-67.el7.centos abc 87 k mailcap noarch 2.1.41-2.el7 abc 31 k 事务概要 ================================================================================ 安装 1 软件包 (+4 依赖软件包) 总下载量:3.0 M 安装大小:10 M Downloading packages: -------------------------------------------------------------------------------- 总计 54 MB/s | 3.0 MB 00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在安装 : apr-1.4.8-3.el7.x86_64 1/5 正在安装 : apr-util-1.5.2-6.el7.x86_64 2/5 正在安装 : httpd-tools-2.4.6-67.el7.centos.x86_64 3/5 正在安装 : mailcap-2.1.41-2.el7.noarch 4/5 正在安装 : httpd-2.4.6-67.el7.centos.x86_64 5/5 验证中 : httpd-2.4.6-67.el7.centos.x86_64 1/5 验证中 : mailcap-2.1.41-2.el7.noarch 2/5 验证中 : apr-1.4.8-3.el7.x86_64 3/5 验证中 : httpd-tools-2.4.6-67.el7.centos.x86_64 4/5 验证中 : apr-util-1.5.2-6.el7.x86_64 5/5 已安装: httpd.x86_64 0:2.4.6-67.el7.centos 作为依赖被安装: apr.x86_64 0:1.4.8-3.el7 apr-util.x86_64 0:1.5.2-6.el7 httpd-tools.x86_64 0:2.4.6-67.el7.centos mailcap.noarch 0:2.1.41-2.el7 完毕!

取消本地yum仓库,思路是把之前创建的文件删掉,放到bak的文件恢复原来路径

[root@localhost yum.repos.d]# ls '查看' abc.repo bak [root@localhost yum.repos.d]# rm -rf abc.repo '删除私网配置文件' [root@localhost yum.repos.d]# mv bak/CentOS-* ./ '将原有文件归位' [root@localhost yum.repos.d]# ls bak CentOS-Debuginfo.repo CentOS-Sources.repo CentOS-Base.repo CentOS-fasttrack.repo CentOS-Vault.repo CentOS-CR.repo CentOS-Media.repo [root@localhost yum.repos.d]# rm -rf bak '删掉bak' [root@localhost yum.repos.d]# ls CentOS-Base.repo CentOS-fasttrack.repo CentOS-Vault.repo CentOS-CR.repo CentOS-Media.repo CentOS-Debuginfo.repo CentOS-Sources.repo

之后再连上网络的情况下,去看公网仓库,yum list 每切换一次仓库,就需要清空一次yum缓存 yum clean all

[root@localhost yum.repos.d]# systemctl restart network '重启网卡' [root@localhost yum.repos.d]# yum clean all '清理当前yum缓存' 已加载插件:fastestmirror, langpacks 正在清理软件源: base extras updates Cleaning up everything Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos Cleaning up list of fastest mirrors [root@localhost yum.repos.d]# yum list '查看yum仓库'

3.5解决软件包依赖关系方法

1)安装有依赖关系的多个软件时

被依赖的软件包需要先安装

可同时指定多个.rpm包文件进行安装

2)卸载有依赖关系的多个软件时

依赖其他程序的软件包需要先卸载

可同时指定多个软件名进行卸载

3)忽略依赖关系

结合“–nodeps”选项,但可能导致软件异常

重点记住:

使用rpm命令查询RPM软件信息的常用选项

使用rpm命令安装、升级、卸载RPM软件包的常用选项

典型应用程序的目录结构

常见的软件包封装类型

四:源代码编译安装

4.1:源代码编译概述

1)使用源代码安装软件的优点

获得最新的软件版本,及时修复bug

根据用户需要,灵活定制软件功能

2)应用场合举例

安装较新版本的应用程序时

当前安装的程序无法满足需要时

需要为应用程序添加新的功能时

源代码安装模式可以视为iDIY模式,可以自定义自己的需要安装,依据官方发布的对应版本的软件手册操作

4.2:编译安装源代码包

1)Tarball封包

.tar.gz和.tar.bz2格式居多

软件素材参考:http://sourceforge.net

2)完整性校验

md5sum 校验工具命令

除此之外还有zip压缩包, unzip 解压命令 -d 指定解压为位置

unzip 软件包名 -d 解压至指定路径

mount.cifs //192.168.254.10/linuxs /abc 挂载

[root@localhost ~]# mkdir /abc [root@localhost ~]# mount.cifs //192.168.254.10/linuxs /abc Password for root@//192.168.254.10/linuxs: [root@localhost /]# cd /abc [root@localhost abc]# ls apr-1.4.6.tar.gz apr-util-1.4.1.tar.gz httpd-2.4.2.tar.gz

解压三个gz压缩包

[root@localhost abc]# tar -xzvf apr-util-1.4.1.tar.gz -C /opt 'tar -x解压 -z指gzip格式 -v显示详细过程 -f 执行 压缩包 -C 指定解压目标路径' [root@localhost abc]# tar -xzvf apr-1.4.6.tar.gz -C /opt [root@localhost abc]# tar -xzvf httpd-2.4.2.tar.gz -C /opt

yum install gcc gcc-c++ 使用yum自动安装gcc gcc-c++ 编译器

[root@localhost abc]# yum install gcc gcc-c++

4.3:编译安装过程

4.4 手工编译安装四步骤

(1) tar解包

1)习惯上将软件包释放到/usr/src/目录

2)解包后的软代码文件位置:

/usr/stc/软件名-版本号/

3)实例

(2)./configure 配置

1)使用源码目录中的configure脚本

2)执行“./configure 00help”可查看帮助

3)典型的配置选项

–prefix=软件安装目录

4)示例

(3)make编译(make是转编译的过程)

执行make命令

(4)make安装

执行make install 命令

示例

安装后的测试、应用、维护软件

使用前

启动Apa’che

运行lynx 127.0.0.1查看本机Apache运行状态 (httpd.conf httpd 配置文件 apachectl start 启动apache)

手工编译安装步骤小结

1:找到源码包

先挂载,在宿主机共享目录内找到要安装的压缩包

[root@localhost ~]# mkdir /abc [root@localhost ~]# mount.cifs //192.168.254.10/linuxs /abc Password for root@//192.168.254.10/linuxs: [root@localhost /]# cd /abc [root@localhost abc]# ls apr-1.4.6.tar.gz apr-util-1.4.1.tar.gz httpd-2.4.2.tar.gz 2:解压源码包到指定位置 [root@localhost abc]# tar -xzvf apr-util-1.4.1.tar.gz -C /opt 'tar -x解压 -z指gzip格式 -v显示详细过程 -f 执行 压缩包 -C 指定解压目标路径' [root@localhost abc]# tar -xzvf apr-1.4.6.tar.gz -C /opt [root@localhost abc]# tar -xzvf httpd-2.4.2.tar.gz -C /opt

接下来把apr-1.4.6和apr-until-1.4.1放入到httpd对应的目录内

[root@localhost abc]# cd /opt '切换到/opt' [root@localhost opt]# ls apr-1.4.6 apr-util-1.4.1 httpd-2.4.2 rh [root@localhost opt]# mv apr-1.4.6/ httpd-2.4.2/srclib/apr [root@localhost opt]# mv apr-util-1.4.1/ httpd-2.4.2/srclib/apr-until [root@localhost opt]# cd httpd-2.4.2/srclib/ [root@localhost srclib]# ls apr apr-until Makefile.in [root@localhost srclib]# cd ../../

软件包整理完毕,接下来进行配置

3:configure配置 先提前安装下编译软件,先安装环境包,即编译器等相关软件

pcre作用在网页当中的语言

zlib是网页压缩处理的图片传输

[root@localhost opt]# yum install gcc gcc-c++ pcre pcre-devel zlib-devel -y 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.cn99.com * updates: mirrors.163.com 软件包 gcc-4.8.5-39.el7.x86_64 已安装并且是最新版本 软件包 gcc-c++-4.8.5-39.el7.x86_64 已安装并且是最新版本 软件包 pcre-8.32-17.el7.x86_64 已安装并且是最新版本 正在解决依赖关系 --> 正在检查事务 ---> 软件包 pcre-devel.x86_64.0.8.32-17.el7 将被 安装 ---> 软件包 zlib-devel.x86_64.0.1.2.7-18.el7 将被 安装 --> 正在处理依赖关系 zlib = 1.2.7-18.el7,它被软件包 zlib-devel-1.2.7-18.el7.x86_64 需要 --> 正在检查事务 ---> 软件包 zlib.x86_64.0.1.2.7-17.el7 将被 升级 ---> 软件包 zlib.x86_64.0.1.2.7-18.el7 将被 更新 --> 解决依赖关系完成 依赖关系解决 ======================================================================================== Package 架构 版本 源 大小 ======================================================================================== 正在安装: pcre-devel x86_64 8.32-17.el7 base 480 k zlib-devel x86_64 1.2.7-18.el7 base 50 k 为依赖而更新: zlib x86_64 1.2.7-18.el7 base 90 k 事务概要 ======================================================================================== 安装 2 软件包 升级 ( 1 依赖软件包) 总下载量:619 k Downloading packages: No Presto metadata available for base (1/3): zlib-devel-1.2.7-18.el7.x86_64.rpm | 50 kB 00:00:00 (2/3): pcre-devel-8.32-17.el7.x86_64.rpm | 480 kB 00:00:00 (3/3): zlib-1.2.7-18.el7.x86_64.rpm | 90 kB 00:00:00 ---------------------------------------------------------------------------------------- 总计 1.2 MB/s | 619 kB 00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在更新 : zlib-1.2.7-18.el7.x86_64 1/4 正在安装 : zlib-devel-1.2.7-18.el7.x86_64 2/4 正在安装 : pcre-devel-8.32-17.el7.x86_64 3/4 清理 : zlib-1.2.7-17.el7.x86_64 4/4 验证中 : pcre-devel-8.32-17.el7.x86_64 1/4 验证中 : zlib-1.2.7-18.el7.x86_64 2/4 验证中 : zlib-devel-1.2.7-18.el7.x86_64 3/4 验证中 : zlib-1.2.7-17.el7.x86_64 4/4 已安装: pcre-devel.x86_64 0:8.32-17.el7 zlib-devel.x86_64 0:1.2.7-18.el7 作为依赖被升级: zlib.x86_64 0:1.2.7-18.el7 完毕!

configure配置

[root@localhost httpd-2.4.2]# ./configure --prefix=/usr/local/httpd --enable-deflate --enable-so --enable-rewrite --enable-charset-lite -enable-cgi 4:make编译 [root@localhost httpd-2.4.2]# make '编译,进入目录' /opt/httpd-2.4.2/srclib/apr/libtool --silent --mode=link gcc -std=gnu99 -g -O2 -pthread -o mod_alias.la -rpath /usr/local/httpd/modules -module -avoid-version mod_alias.lo /opt/httpd-2.4.2/srclib/apr/libtool --silent --mode=compile gcc -std=gnu99 -g -O2 -pthread -D_REENTRANT -D_GNU_SOURCE -I. -I/opt/httpd-2.4.2/os/unix -I/opt/httpd-2.4.2/include -I/opt/httpd-2.4.2/srclib/apr/include -I/opt/httpd-2.4.2/srclib/apr-util/include -I/opt/httpd-2.4.2/srclib/apr-util/xml/expat/lib -I/opt/httpd-2.4.2/modules/aaa -I/opt/httpd-2.4.2/modules/cache -I/opt/httpd-2.4.2/modules/core -I/opt/httpd-2.4.2/modules/database -I/opt/httpd-2.4.2/modules/filters -I/opt/httpd-2.4.2/modules/ldap -I/opt/httpd-2.4.2/modules/loggers -I/opt/httpd-2.4.2/modules/lua -I/opt/httpd-2.4.2/modules/proxy -I/opt/httpd-2.4.2/modules/session -I/opt/httpd-2.4.2/modules/ssl -I/opt/httpd-2.4.2/modules/test -I/opt/httpd-2.4.2/server -I/opt/httpd-2.4.2/modules/arch/unix -I/opt/httpd-2.4.2/modules/dav/main -I/opt/httpd-2.4.2/modules/generators -I/opt/httpd-2.4.2/modules/mappers -prefer-pic -c mod_rewrite.c && touch mod_rewrite.slo /opt/httpd-2.4.2/srclib/apr/libtool --silent --mode=link gcc -std=gnu99 -g -O2 -pthread -o mod_rewrite.la -rpath /usr/local/httpd/modules -module -avoid-version mod_rewrite.lo make[4]: 离开目录“/opt/httpd-2.4.2/modules/mappers” make[3]: 离开目录“/opt/httpd-2.4.2/modules/mappers” make[2]: 离开目录“/opt/httpd-2.4.2/modules” make[2]: 进入目录“/opt/httpd-2.4.2/support” make[2]: 离开目录“/opt/httpd-2.4.2/support” make[1]: 离开目录“/opt/httpd-2.4.2”

中间可能会出现一些报错问题:环境包问题,配置格式问题,功能性方面问题(软件版本,是否支持功能),这些就需要仔细排查,缺什么补什么

5:make安装

make install 命令

[root@localhost httpd-2.4.2]# make install '安装' Installing icons mkdir /usr/local/httpd/icons mkdir /usr/local/httpd/logs Installing CGIs mkdir /usr/local/httpd/cgi-bin Installing header files Installing build system files Installing man pages and online manual mkdir /usr/local/httpd/man mkdir /usr/local/httpd/man/man1 mkdir /usr/local/httpd/man/man8 mkdir /usr/local/httpd/manual make[1]: 离开目录“/opt/httpd-2.4.2”

配置httpd的conf属性

[root@localhost httpd-2.4.2]# cd /usr/local '进入到安装路径' [root@localhost local]# ls bin etc games httpd include lib lib64 libexec sbin share src [root@localhost local]# cd httpd/ [root@localhost httpd]# ls bin cgi-bin error icons lib man modules build conf htdocs include logs manual [root@localhost httpd]# cd conf/ [root@localhost conf]# ls extra httpd.conf magic mime.types original 安装完成后优化,即测试、应用维护软件

1:找到服务配置文件,修改功能 conf配置文件

[root@localhost conf]# vim httpd.conf '配置httpd。conf' :set nu '显示行数' /Listen ’查找Listen‘ 46 # directive. 47 # 48 # Change this to Listen on specific IP addresses as shown below to 49 # prevent Apache from glomming onto all bound IP addresses. 50 # 51 #Listen 12.34.56.78:80 52 Listen 80 53 54 # 55 # Dynamic Shared Object (DSO) Support 56 #

修改IP地址(在这里每一行的前面若是有#键,则代表是注释行,不发挥功能,若要发挥功能,则要取消注释#键)

# Listen: Allows you to bind Apache to specific IP addresses and/or # ports, instead of the default. See also the <VirtualHost> # directive. # # Change this to Listen on specific IP addresses as shown below to # prevent Apache from glomming onto all bound IP addresses. # Listen 192.168.139.147:80 '去掉前面#号键,后面加端口号' #Listen 80 '开启前面#号键' # # Dynamic Shared Object (DSO) Support

搜索Server

# it explicitly to prevent problems during startup. # # If your host doesn't have a registered DNS name, enter its IP address here. # #ServerName www.example.com:80 '修改网址' # # Deny access to the entirety of your server's filesystem. You must # it explicitly to prevent problems during startup. # # If your host doesn't have a registered DNS name, enter its IP address here. # ServerName www.kgc.com:80 '关掉前面#号键' # # Deny access to the entirety of your server's filesystem. You must :wq '保存退出'

查看对应80端口是否启用

关闭防火墙

[root@localhost bin]# ./apachectl start '开启apachctl' [root@localhost bin]# netstat -ntap |grep 80 tcp 0 0 192.168.139.147:80 0.0.0.0:* LISTEN 73721/httpd [root@localhost bin]# systemctl stop firewalld.service '关闭防火墙' [root@localhost bin]# setenforce 0 [root@localhost bin]# cd .. [root@localhost httpd]# ls bin cgi-bin error icons lib man modules build conf htdocs include logs manual

htdocs 网页目录,修改首页index配置

[root@localhost httpd]# cd htdocs/ [root@localhost htdocs]# ls index.html [root@localhost htdocs]# vim index.html

vim index.html

<html><body><h1>this is test 咸蛋超人</h1></body></html> ~ ~ ~ ~ ~

打开之前输入的ip地址

中文显示不出来,是因为没有开启转换

2:找到服务启动脚本,启动服务 可以被systemctl或者service直接管理

例如:service network restart /etc/init.d/network

​ systemctl restart network.service /lib/systemd/system/network.service

最新回复(0)