yum: 上层软件管理工具,最重要的功能是可以解决软件的依赖性 yum能够投入使用的前提是必须要有yum源头,以及配置源指向文件
配置yum源: 1.从网络上下载与本机系统版本匹配的iso镜像文件 rhel-server-7.0-x86_64-dvd.iso
2.把rhel-server-7.0-x86_64-dvd.iso挂载到/mnt以便系统访问镜像文件 mount rhel-server-7.0-x86_64-dvd.iso /mnt (确定目录里不存在重要文件和目录,可以自己新建目录) 3.配置本机yum源指向 rm -fr /etc/yum.repos.d/* vim /etc/yum.repos.d/yum.repo
加入如下: [server] ##可以任意更改 name=rhel7.0 baseurl=file:///mnt gpgcheck=0 ##表示不检测gpgkey gpgkey表示软件的出品logo 4.测试安装软件 yum clean all yum install httpd -y
############# Apache(web服务器) ssh:22 apache:80 httpd是Apache超文本传输协议(KTTp)服务器的主程序
5.安装资源共享服务 yum install httpd -y systemctl stop firewalld systemctl disable firewalld systemctl start httpd systemctl enable httpd
6.建立共享目录,并挂载镜像文件到共享目录上 cd /var/www/html mkdir rhel7.0 umount /mnt(解除之前的挂载) mount rhel-server-7.0-x86_64-dvd.iso /var/www/html/rhel7.0
7.测试(前提:虚拟机和真机能够彼此ping通) 在真机浏览器中输入http://虚拟机ip/rhel7.0 可以看到镜像中的内容 8.修改本机的yum源指向 vim /etc/yum.repos.d/yum.repo
加入: [Server] name=rhel7.0 baseruerl=http://ip/rhel7.0 gpgcheck=0
9.测试 修改另一台机子的yum源地址 vim /etc/yum.repos.d/yum.repo
加入: [Server] name=rhel7.0 baseruerl=http://ip/rhel7.0 gpgcheck=0
10.开机自动挂载在iso vim /etc/rc.d/rc.local 加入:mount /root/Desktop/rhel-server-7.0-x86_64-dvd.iso /var/www/html/rhel7.0 chmod +x /etc/rc.d/rc.local
############################### 如何安装软件 rpm rpm -ivh name.rpm ##安装软件 -v:显示过程 -h:指定加密方式为hash rpm -e name.rpm ##卸载 rpm -ql name #查看软件生成的文件 rpm -qlp name.rpm #查询软件安装后会生成什么文件 rpm -qa #查询系统中安装的所有软件名称 用法举例一个:rpm -qa | grep wps rpm -pq name.rpm #查询软件包安装后的名字 rpm -ivh name.rpm --force #强制安装,但是不能忽略依赖性 rpm -ivh name.rpm --nodeps --force #强制安装,忽略依赖性 rpm -qi name #查看软件的信息 rpm -qp name.rpm --scripts #检测软件在安装或卸载过程中执行的动作 第三方源的搭建 把所有的rpm软件包放到一个目录中,这个目录只能存在.rpm文件 createrepo -v /rpm存放目录
####yum命令 yum install softwarename -y ##安装软件 yum repolist ##列出设定yum源设定 yum remove softwarename ##卸载软件 yum list all ##列出所有软件的名称 yum list softwarename ##查看软件源中是否有该软件 yum list installd softwarename ##是否安装该软件 yum list available ##列出可以用yum安装的软件名称 yum clean all ##清空yum缓存 yum search softwareinfo ##根据软件信息搜索软件名 yum whatprovides filename ##在yum源中查找包含fileman文件的软件包 yum update ##更新系统 yum history ##查看系统软件改变历史 yum reinstall softwarename ##重现安装软件