当前位置: 首页 > news >正文

linux软件安装与管理

一、rpm安装

rpm参数 参数说明
  -i 安装软件
  -t 测试安装,不是真的安装
  -p 显示安装进度
  -f 忽略任何错误
  -U 升级安装
  -v 检测套件是否正确安装

1.1、rpm -qa 查看系统中已安装的所有rpm软件包

格式:rpm  -q[子选项]  [软件名]

常用子选项命令:

-qa:查看系统中已安装的所有RPM软件包列表

-qi:查看指定软件的详细信息

-ql:查询指定软件包所安装的目录、文件列表

-qc:仅显示指定软件包安装的配置文件

-qd:仅显示指定软件包安装的文档文件

# 能够过滤除了。说明软件包已安装
# 查询不显示,说明对应软件包没有安装
[root@centos7 ~]# rpm -qa
[root@centos7 ~]# rpm -qa | wc -l
1411
[root@centos7 ~]# rpm -qa | grep bash
bash-4.2.46-34.el7.x86_64
bash-completion-2.1-8.el7.noarch# rpm -qf查看文件是由那个软件包安装的
[root@centos7 ~]# which vim
/usr/bin/vim
[root@centos7 ~]# rpm -qf /bin/vim
vim-enhanced-7.4.629-7.el7.x86_64

1.2、rpm -ivh 安装软件

[root@centos7 ~]# rpm -qa | grep zsh
[root@centos7 ~]# cd /run/media/root/CentOS\ 7\ x86_64/Packages/
[root@centos7 Packages]# ll | grep zsh
-rw-rw-r--  3 root root  2497380 Apr  8  2020 zsh-5.0.2-34.el7_8.2.x86_64.rpm
[root@centos7 Packages]# rpm -ivh zsh-5.0.2-34.el7_8.2.x86_64.rpm 
warning: zsh-5.0.2-34.el7_8.2.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...1:zsh-5.0.2-34.el7_8.2             ################################# [100%]

1.3 、rpm -e 卸载软件

[root@centos7 Packages]# rpm -qa | grep zsh
zsh-5.0.2-34.el7_8.2.x86_64
[root@centos7 Packages]# rpm -e zsh
[root@centos7 Packages]# rpm -qa | grep zsh

二、配置本地yum源

使用yum可以更好地解决软件包之间的依赖问题

2.1、重新挂载光盘到指定目录

[root@centos7 ~]# df -Th
Filesystem              Type      Size  Used Avail Use% Mounted on
devtmpfs                devtmpfs  2.0G     0  2.0G   0% /dev
tmpfs                   tmpfs     2.0G     0  2.0G   0% /dev/shm
tmpfs                   tmpfs     2.0G   13M  2.0G   1% /run
tmpfs                   tmpfs     2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/mapper/centos-root xfs        38G  4.3G   33G  12% /
/dev/sda1               xfs      1014M  172M  843M  17% /boot
/dev/mapper/centos-home xfs        19G   33M   19G   1% /home
tmpfs                   tmpfs     394M   36K  394M   1% /run/user/0
/dev/sr0                iso9660   4.4G  4.4G     0 100% /run/media/root/CentOS 7 x86_64# 创建目录,作为新的挂载点
[root@centos7 ~]# mkdir /mnt/dvd
[root@centos7 ~]# ls -ld /mnt/dvd
drwxr-xr-x 2 root root 6 Nov  8 04:46 /mnt/dvd# 查看光盘对应名称    /dev/sr0
[root@centos7 ~]# df -Th
Filesystem              Type      Size  Used Avail Use% Mounted on
devtmpfs                devtmpfs  2.0G     0  2.0G   0% /dev
tmpfs                   tmpfs     2.0G     0  2.0G   0% /dev/shm
tmpfs                   tmpfs     2.0G   13M  2.0G   1% /run
tmpfs                   tmpfs     2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/mapper/centos-root xfs        38G  4.3G   33G  12% /
/dev/sda1               xfs      1014M  172M  843M  17% /boot
/dev/mapper/centos-home xfs        19G   33M   19G   1% /home
tmpfs                   tmpfs     394M   36K  394M   1% /run/user/0
/dev/sr0                iso9660   4.4G  4.4G     0 100% /run/media/root/CentOS 7 x86_64# 将光盘挂载到新的挂载点
[root@centos7 ~]# mount /dev/sr0 /mnt/dvd
mount: /dev/sr0 is write-protected, mounting read-only
[root@centos7 ~]# df -Th
Filesystem              Type      Size  Used Avail Use% Mounted on
devtmpfs                devtmpfs  2.0G     0  2.0G   0% /dev
tmpfs                   tmpfs     2.0G     0  2.0G   0% /dev/shm
tmpfs                   tmpfs     2.0G   13M  2.0G   1% /run
tmpfs                   tmpfs     2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/mapper/centos-root xfs        38G  4.3G   33G  12% /
/dev/sda1               xfs      1014M  172M  843M  17% /boot
/dev/mapper/centos-home xfs        19G   33M   19G   1% /home
tmpfs                   tmpfs     394M   40K  394M   1% /run/user/0
/dev/sr0                iso9660   4.4G  4.4G     0 100% /mnt/dvd
[root@centos7 ~]# ll /mnt/dvd
total 696
-rw-r--r--  3 root root     14 Oct 29  2020 CentOS_BuildTag
drwxr-xr-x  3 root root   2048 Oct 26  2020 EFI
-rw-rw-r-- 21 root root    227 Aug 30  2017 EULA
-rw-rw-r-- 21 root root  18009 Dec  9  2015 GPL
drwxr-xr-x  3 root root   2048 Oct 26  2020 images
drwxr-xr-x  2 root root   2048 Nov  2  2020 isolinux
drwxr-xr-x  2 root root   2048 Oct 26  2020 LiveOS
drwxr-xr-x  2 root root 673792 Nov  4  2020 Packages
drwxr-xr-x  2 root root   4096 Nov  4  2020 repodata
-rw-rw-r-- 21 root root   1690 Dec  9  2015 RPM-GPG-KEY-CentOS-7
-rw-rw-r-- 21 root root   1690 Dec  9  2015 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r--  1 root root   2883 Nov  4  2020 TRANS.TBL

2.2、查看并编写配置文件

#格式:
[BASIC]                                                                                                            #仓库ID
name= BASIC                                                                                                 #仓库名
baseurl=                                                                                                         #仓库地址
>本地地址 file://本地软件包路径
>FTP服务器地址 ftp://仓库位置
>WEB服务器地址 http://仓库位置
enabled=0/1                                                                                                 #是否开启仓库
gpgcheck=0/1                                                                                            #是否需要公钥验证
gpgkey= file:///etc/pki/rpm-gPg/RPM-GPG-KEY-redhat-release                 #公钥验证地址

# 配置文件目录 /etc/yum.repo.d/
# 配置文件名 file.repo    以.repo为后缀
[root@centos7 ~]# cd /etc/yum.repos.d/
[root@centos7 yum.repos.d]# ll
total 40
-rw-r--r--. 1 root root 1664 Oct 23  2020 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Oct 23  2020 CentOS-CR.repo
-rw-r--r--. 1 root root  649 Oct 23  2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 Oct 23  2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 Oct 23  2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Oct 23  2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 8515 Oct 23  2020 CentOS-Vault.repo
-rw-r--r--. 1 root root  616 Oct 23  2020 CentOS-x86_64-kernel.repo
[root@centos7 yum.repos.d]# mkdir bak
[root@centos7 yum.repos.d]# mv *.repo bak
[root@centos7 yum.repos.d]# ll
total 0
drwxr-xr-x 2 root root 220 Nov  8 04:53 bak# 编辑配置文件,baseurl中的file:// 表示本地文件,第三个/ 表示根目录
[root@centos7 yum.repos.d]# vim centos7.repo
[root@centos7 yum.repos.d]# cat centos7.repo
[centos7]
name=centos7 repo
baseurl=file:///mnt/dvd
gpgcheck=0

2.3、yum命令

[root@centos7 ~]# yum clean all
Loaded plugins: fastestmirror, langpacks
Cleaning repos: centos7
Cleaning up list of fastest mirrors# 列出所有软件包
[root@centos7 ~]# yum list
[root@centos7 ~]# yum list | grep zsh
zsh.x86_64                              5.0.2-34.el7_8.2               centos7  

2.4、yum info 查看软件包信息

[root@centos7 ~]# yum info zsh
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Available Packages
Name        : zsh
Arch        : x86_64
Version     : 5.0.2
Release     : 34.el7_8.2
Size        : 2.4 M
Repo        : centos7
Summary     : Powerful interactive shell
URL         : http://zsh.sourceforge.net/
License     : MIT
Description : The zsh shell is a command interpreter usable as an interactive login: shell and as a shell script command processor.  Zsh resembles the ksh: shell (the Korn shell), but includes many enhancements.  Zsh supports: command line editing, built-in spelling correction, programmable: command completion, shell functions (with autoloading), a history: mechanism, and more.

2.5、yum install 安装软件包

[root@centos7 ~]# yum install zsh
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package zsh.x86_64 0:5.0.2-34.el7_8.2 will be installed
--> Finished Dependency ResolutionDependencies Resolved=============================================================================================================Package             Arch                   Version                            Repository               Size
=============================================================================================================
Installing:zsh                 x86_64                 5.0.2-34.el7_8.2                   centos7                 2.4 MTransaction Summary
=============================================================================================================
Install  1 PackageTotal download size: 2.4 M
Installed size: 5.6 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionInstalling : zsh-5.0.2-34.el7_8.2.x86_64                                                               1/1 Verifying  : zsh-5.0.2-34.el7_8.2.x86_64                                                               1/1 Installed:zsh.x86_64 0:5.0.2-34.el7_8.2                                                                              Complete!

2.6、yum remove 删除软件包

[root@centos7 ~]# yum remove zsh
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package zsh.x86_64 0:5.0.2-34.el7_8.2 will be erased
--> Finished Dependency ResolutionDependencies Resolved=============================================================================================================Package             Arch                   Version                           Repository                Size
=============================================================================================================
Removing:zsh                 x86_64                 5.0.2-34.el7_8.2                  @centos7                 5.6 MTransaction Summary
=============================================================================================================
Remove  1 PackageInstalled size: 5.6 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionErasing    : zsh-5.0.2-34.el7_8.2.x86_64                                                               1/1 Verifying  : zsh-5.0.2-34.el7_8.2.x86_64                                                               1/1 Removed:zsh.x86_64 0:5.0.2-34.el7_8.2                                                                              Complete!

三、源代码安装

3.1、xftp上传源代码包

# 在tmp下新建一个目录,用来存放软件包
[root@centos7 ~]# mkdir /tmp/software

3.2、解包 解压缩 tar

[root@centos7 software]# tar -xvzf nginx-1.24.0.tar.gz
nginx-1.24.0/
nginx-1.24.0/man/
nginx-1.24.0/CODE_OF_CONDUCT.md
nginx-1.24.0/LICENSE
nginx-1.24.0/configure
nginx-1.24.0/auto/
......
[root@centos7 software]# ls
nginx-1.24.0 nginx-1.24.0.tar.gz

3.3、解决依赖

[root@centos7 software]# yum install gcc pcre-devel zlib-devel openssl-devel -y
[root@centos7 software]# cd nginx-1.24.0/

3.4、编译安装Nginx

#对nginx编译
[root@centos7 nginx-1.24.0]# ./configure #找到makefile文件进行安装
[root@centos7 nginx-1.24.0]# ls
auto     CHANGES.ru  configure  html     Makefile  objs    src
CHANGES  conf        contrib    LICENSE  man       README
[root@centos7 nginx-1.24.0]# make && make install

http://www.dtcms.com/a/586424.html

相关文章:

  • 7.基础--SQL--DDL-数据类型及案例
  • 网站内部seo优化包括wordpress主题详情更改版权
  • 网站积分系统方案网络服务商网站
  • 浏览器如何做购物网站为什么网站的备案号在备案网站查询不到
  • COT控制架构下ASP3605负载调整特性评估
  • Java118 反射
  • Optuna超参数调优图例解读之Optimization History Plot(优化历史图)
  • 【Python】Tuple (元组)
  • 小吃培训网站源码广电网络公司优秀营销案例
  • 企业电子商务网站建设设计目的暴雪游戏有哪些
  • 仓颉初使用,资料查找及换进安装使用指导
  • 事务的相关介绍
  • 安徽省工程建设信息网站投资公司设立条件
  • Spring 框架核心技术全解析
  • C# OpenCVSharp使用 读光-票证检测矫正模型
  • 更换空间对网站的影响开发app需要什么设备
  • 佛山网站制作公司沈阳网页设计招聘
  • 南宁比优建站wordpress管理工具栏
  • 企业如何建设自己的网站网站主页跳转index
  • 网站利用百度离线地图淘宝电脑版网页
  • 工业控制网关物联网解决方案软硬件定制:我是你的研发部
  • 第2章 传感器技术与数据处理
  • 【开题答辩全过程】以 房地产销售管理系统为例,包含答辩的问题和答案
  • 建设项目环评验收网站建设行业门户网站需要什么条件
  • maven常用的命令
  • 动态商务网站开发与管理合肥网站建设工作室
  • 设计的网站都有哪些内容新榜数据平台
  • 扶绥县住房和城乡建设局网站品牌网站建设精湛磐石网络
  • MCU 的SPI 关键部分配置注意事项(SPI多机通信时)
  • 付网站建设费如果做账wordpress修改版面