RPM命令管理软件包需要手动解决软件包之间依赖关系
命令格式:rpm 选项... 软件包全名
常用选项:
#挂载iso镜像文件 [root@localhost ~]# mkdir /mnt/centos [root@localhost ~]# mount /dev/cdrom /mnt/centos/ #实现永久挂载,查看iso镜像文件系统类型 [root@localhost ~]# df -hT [root@localhost ~]# vim /etc/fstab ... /dev/cdrom /mnt/centos iso9660 defaults 0 0 #重新加载 [root@localhost ~]# mount -a #查询软件包是否安装 [root@localhost centos]# rpm -q vsftpd 未安装软件包 vsftpd #安装vsftpd软件包 [root@localhost centos]# rpm -i Packages/vsftpd-3.0.2-25.el7.x86_64.rpm #查询系统中以安装的所有软件 [root@localhost centos]# rpm -qa [root@localhost centos]# rpm -qa | grep vsftpd vsftpd-3.0.2-25.el7.x86_64 #查询软件包详细的信息 [root@localhost centos]# rpm -qi vsftpd Name : vsftpd #软件包名 Version : 3.0.2 #版本 Release : 25.el7 #适合安装的系统版本 Architecture: x86_64 #适合安装的CPU架构 Install Date: 2021年05月04日 星期二 14时47分06秒 #安装时间 Group : System Environment/Daemons #软件包属于哪个群组 Size : 361335 #软件包大小 License : GPLv2 with exceptions Signature : RSA/SHA256, 2018年11月12日 星期一 22时48分54秒, Key ID 24c6a8a7f4a80eb5 Source RPM : vsftpd-3.0.2-25.el7.src.rpm Build Date : 2018年10月31日 星期三 03时45分10秒 Build Host : x86-01.bsys.centos.org Relocations : (not relocatable) Packager : CentOS BuildSystem <http://bugs.centos.org> Vendor : CentOS URL : https://security.appspot.com/vsftpd.html #软件包官网地址 Summary : Very Secure Ftp Daemon Description : #描述信息 vsftpd is a Very Secure FTP daemon. It was written completely from scratch. [root@localhost centos]# which ls alias ls='ls --color=auto' /usr/sbin/ls #查询文件由哪个软件包产生 [root@localhost centos]# rpm -qf /usr/bin/ls coreutils-8.22-23.el7.x86_64 [root@localhost centos]# which vim /usr/bin/vim [root@localhost centos]# rpm -qf /usr/bin/vim vim-enhanced-7.4.160-5.el7.x86_64 [root@localhost centos]# rpm -qi vim-enhanced #查询软件包自带的文件与目录安装路径 [root@localhost centos]# rpm -ql vsftpd [root@localhost centos]# rpm -qf /usr/bin/vim vim-enhanced-7.4.160-5.el7.x86_64 [root@localhost centos]# rpm -ql vim-enhanced /etc/profile.d/vim.csh /etc/profile.d/vim.sh /usr/bin/rvim /usr/bin/vim /usr/bin/vimdiff /usr/bin/vimtutor [root@localhost centos]# rpm -q vsftpd vsftpd-3.0.2-25.el7.x86_64 #卸载软件包 [root@localhost centos]# rpm -e vsftpd [root@localhost centos]# rpm -q vsftpd 未安装软件包 vsftpd #安装vsftpd软件包 [root@localhost centos]# rpm -ivh Packages/vsftpd-3.0.2-25.el7.x86_64.rpm 警告:Packages/vsftpd-3.0.2-25.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY 准备中... ################################# [100%] 正在升级/安装... 1:vsftpd-3.0.2-25.el7 ################################# [100%] [root@localhost centos]# rpm -q vsftpd vsftpd-3.0.2-25.el7.x86_64 #升级安装软件包 [root@localhost centos]# rpm -Uvh Packages/vsftpd-3.0.2-25.el7.x86_64.rpm 警告:Packages/vsftpd-3.0.2-25.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY 准备中... ################################# [100%] 软件包 vsftpd-3.0.2-25.el7.x86_64 已经安装 #导入红帽签名文件 [root@localhost centos]# rpm --import RPM-GPG-KEY-CentOS-7 #安装软件包,查看是否还有警告信息 [root@localhost centos]# rpm -q vsftpd vsftpd-3.0.2-25.el7.x86_64 [root@localhost centos]# rpm -e vsftpd [root@localhost centos]# rpm -ivh Packages/vsftpd-3.0.2-25.el7.x86_64.rpm 准备中... ################################# [100%] 正在升级/安装... 1:vsftpd-3.0.2-25.el7 ################################# [100%] #安装httpd软件包 [root@localhost centos]# rpm -ivh Packages/httpd-(tab键) httpd-2.4.6-88.el7.centos.x86_64.rpm httpd-manual-2.4.6-88.el7.centos.noarch.rpm httpd-devel-2.4.6-88.el7.centos.x86_64.rpm httpd-tools-2.4.6-88.el7.centos.x86_64.rpm [root@localhost centos]# rpm -ivh Packages/httpd-2.4.6-88.el7.centos.x86_64.rpm 错误:依赖检测失败: /etc/mime.types 被 httpd-2.4.6-88.el7.centos.x86_64 需要 httpd-tools = 2.4.6-88.el7.centos 被 httpd-2.4.6-88.el7.centos.x86_64 需要 libapr-1.so.0()(64bit) 被 httpd-2.4.6-88.el7.centos.x86_64 需要 libaprutil-1.so.0()(64bit) 被 httpd-2.4.6-88.el7.centos.x86_64 需要 [root@localhost centos]# ls /etc/mime.types ls: 无法访问/etc/mime.types: 没有那个文件或目录 #解决依赖关系 [root@localhost centos]# rpm -ivh Packages/mailcap-2.1.41-2.el7.noarch.rpm 准备中... ################################# [100%] 正在升级/安装... 1:mailcap-2.1.41-2.el7 ################################# [100%] [root@localhost centos]# ls /etc/mime.types /etc/mime.types #解决依赖关系 [root@localhost centos]# rpm -ivh Packages/httpd-tools-2.4.6-88.el7.centos.x86_64.rpm 错误:依赖检测失败: libapr-1.so.0()(64bit) 被 httpd-tools-2.4.6-88.el7.centos.x86_64 需要 libaprutil-1.so.0()(64bit) 被 httpd-tools-2.4.6-88.el7.centos.x86_64 需要 #解决依赖关系(www.rpmfind.net官网查询提供libapr-1.so.0模块文件的软件包) [root@localhost centos]# rpm -ivh Packages/apr-(tab键) apr-1.4.8-3.el7_4.1.x86_64.rpm apr-util-1.5.2-6.el7.x86_64.rpm apr-devel-1.4.8-3.el7_4.1.x86_64.rpm apr-util-devel-1.5.2-6.el7.x86_64.rpm [root@localhost centos]# rpm -ivh Packages/apr-1.4.8-3.el7_4.1.x86_64.rpm 准备中... ################################# [100%] 正在升级/安装... 1:apr-1.4.8-3.el7_4.1 ################################# [100%] #解决依赖关系(www.rpmfind.net官网查询提供libaprutil-1.so.0模块文件的软件包) [root@localhost centos]# rpm -ivh Packages/apr-util-(tab键) apr-util-1.5.2-6.el7.x86_64.rpm apr-util-devel-1.5.2-6.el7.x86_64.rpm [root@localhost centos]# rpm -ivh Packages/apr-util- apr-util-1.5.2-6.el7.x86_64.rpm apr-util-devel-1.5.2-6.el7.x86_64.rpm [root@localhost centos]# rpm -ivh Packages/apr-util-1.5.2-6.el7.x86_64.rpm 准备中... ################################# [100%] 正在升级/安装... 1:apr-util-1.5.2-6.el7 ################################# [100%] #安装依赖关系 [root@localhost centos]# rpm -ivh Packages/httpd-tools-2.4.6-88.el7.centos.x86_64.rpm 准备中... ################################# [100%] 正在升级/安装... 1:httpd-tools-2.4.6-88.el7.centos ################################# [100%] #安装httpd主包 [root@localhost centos]# rpm -ivh Packages/httpd-(tab键) httpd-2.4.6-88.el7.centos.x86_64.rpm httpd-manual-2.4.6-88.el7.centos.noarch.rpm httpd-devel-2.4.6-88.el7.centos.x86_64.rpm httpd-tools-2.4.6-88.el7.centos.x86_64.rpm [root@localhost centos]# rpm -ivh Packages/httpd-2.4.6-88.el7.centos.x86_64.rpm 准备中... ################################# [100%] 正在升级/安装... 1:httpd-2.4.6-88.el7.centos ################################# [100%]
yum(软件仓库):提供众多软件包的仓库,并自动解决软件包之间复杂依赖关系
yum常用命令:
本地yum源配置(本地软件仓库)
[root@localhost ~]# vim /etc/yum.repos.d/local.repo [local] #仓库名称,名称自定义,但具有唯一性 name=local_centos #仓库描述,(类似于仓库解释),描述信息自定义,不具备唯一性 baseurl=file:///mnt/centos #指定软件仓库地址,file://用于指定本地软件包存放位置 enabled=1 #软件仓库是否启动,1启动,0不启动 gpgcheck=0 #是否检测软件包签名,0不检测,1检测 #检测仓库可用性 [root@localhost centos]# yum repolist 已加载插件:fastestmirror, langpacks 源标识 源名称 状态 local local_centos 4,021 repolist: 4,021 #查找指定的软件包 [root@localhost centos]# yum list gcc #安装软件包 [root@localhost centos]# yum install gcc ... Is this ok [y/d/N]: y (y安装/d下载到本地不安装/N不安装) [root@localhost centos]# rpm -q gcc gcc-4.8.5-36.el7.x86_64 [root@localhost centos]# rpm -qi gcc [root@localhost centos]# rpm -ql gcc #安装软件包并自动回答yes [root@localhost centos]# yum -y install gcc-c++ [root@localhost centos]# rpm -q gcc [root@localhost centos]# rpm -qi gcc [root@localhost centos]# rpm -ql gcc [root@localhost centos]# rpm -qf /usr/bin/ls [root@localhost centos]# yum provides /usr/bin/ls #下载挂载点 [root@localhost ~]# umount /mnt/centos/ [root@localhost ~]# ls /mnt/centos/ #查看仓库可用性 [root@localhost ~]# yum repolist 源标识 源名称 状态 local local_centos 4,021 repolist: 4,021 [root@localhost ~]# rpm -e vsftpd root@localhost ~]# yum -y install vsftpd Error downloading packages: vsftpd-3.0.2-25.el7.x86_64: [Errno 256] No more mirrors to try. [root@localhost ~]# yum clean all [root@localhost ~]# yum repolist 源标识 源名称 状态 local local_centos 0 repolist: 0 #挂载 [root@localhost ~]# mount -a mount: /dev/sr0 写保护,将以只读方式挂载
#下载wget工具 [root@localhost ~]# yum -y install wget #下载阿里Base源(基本软件仓库,解决rpm软件的依赖关系) [root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo #下载阿里epel源(额外软件仓库,包含许多基本软件仓库没有的软件包) [root@localhost ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo [root@localhost ~]# vim /etc/yum.repos.d/CentOS-Base.repo [base] name=CentOS-$releasever - Base - mirrors.aliyun.com failovermethod=priority #故障转移方法,默认优先 baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #配置清华大学开源镜象站 [root@localhost ~]# vim /etc/yum.repos.d/local.repo [local] name=local_centos baseurl=file:///mnt/centos/ enabled=1 gpgcheck=0 [tuna.tsinghua.edu.cn] name=tuna.tsinghua.edu.cn baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/ enabled=1 gpgcheck=0 #生成yum仓库缓存提高软件包下载速度 [root@localhost ~]# yum makecache ... 元数据缓存已建立
#设置本地yum为最高优先级 [root@localhost ~]# vim /etc/yum.repos.d/local.repo [local] name=local_centos baseurl=file:///mnt/centos enabled=1 gpgcheck=0 priority=1 #优先级为1-99之间,数字越小越优先
#从官网下载源码包 http://nginx.org/ #安装源码包依赖包 [root@localhost ~]# yum -y install gcc pcre-devel openssl-devel zlib #解压源码包并进入源码包路径 [root@localhost ~]# tar -xf nginx-1.20.0.tar.gz [root@localhost ~]# cd nginx-1.20.0/ [root@localhost nginx-1.20.0]# ls auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src #使用configure程序检查系统环境并指定安装参数 [root@localhost nginx-1.20.0]# ./configure --with-http_ssl_module --with-file-aio --with-http_realip_module nginx path prefix: "/usr/local/nginx" nginx binary file: "/usr/local/nginx/sbin/nginx" nginx modules path: "/usr/local/nginx/modules" nginx configuration prefix: "/usr/local/nginx/conf" nginx configuration file: "/usr/local/nginx/conf/nginx.conf" nginx pid file: "/usr/local/nginx/logs/nginx.pid" nginx error log file: "/usr/local/nginx/logs/error.log" nginx http access log file: "/usr/local/nginx/logs/access.log" nginx http client request body temporary files: "client_body_temp" nginx http proxy temporary files: "proxy_temp" nginx http fastcgi temporary files: "fastcgi_temp" nginx http uwsgi temporary files: "uwsgi_temp" nginx http scgi temporary files: "scgi_temp" #make将源码包转换成二进制 [root@localhost nginx-1.20.0]# make #make install安装源码包 [root@localhost nginx-1.20.0]# make install [root@localhost nginx-1.20.0]# cd /usr/local/nginx/ [root@localhost nginx]# ls conf html logs sbin
#启动nginx服务 [root@localhost nginx]# sbin/nginx #netstat|ss命令用于查看系统中启动的端口信息 -a 显示所有端口信息 -n 以数字格式显示端口号 -t 显示TCP连接的端口 -u 显示UDP连接的端口 -l 显示服务正在监听的端口信息 -p 显示监听端口的服务名称是什么(也就是程序名) #查看nginx服务端口信息 [root@localhost ~]# ss -anptul | grep nginx tcp LISTEN 0 128 *:80 #Nginx服务默认通过TCP 80 端口监听客户端请求 #查看系统所有服务占用的端口虚拟系 [root@localhost nginx]# ss -ntlp [root@localhost nginx]# ss -anptul | grep sshd [root@localhost nginx]# ss -anptul | grep vsftpd