Linux软件包安装
1、RPM工具 首先要挂载光驱,访问RPM包光盘
[root@bogon mnt]# mount /dev/cdrom /mnt
mount: /dev/sr0 写保护,将以只读方式挂载
[root@bogon mnt]# ls /mnt
CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7
EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL
rpm 包格式:-包名-版本号-发布版本号_平台
[root@bogon mnt]# cd Packages/
[root@bogon Packages]# ls |head
389-ds-base-1.3.6.1-16.el7.x86_64.rpm
389-ds-base-libs-1.3.6.1-16.el7.x86_64.rpm
abattis-cantarell-fonts-0.0.25-1.el7.noarch.rpm
abrt-2.1.11-48.el7.centos.x86_64.rpm
abrt-addon-ccpp-2.1.11-48.el7.centos.x86_64.rpm
abrt-addon-kerneloops-2.1.11-48.el7.centos.x86_64.rpm
abrt-addon-pstoreoops-2.1.11-48.el7.centos.x86_64.rpm
abrt-addon-python-2.1.11-48.el7.centos.x86_64.rpm
abrt-addon-vmcore-2.1.11-48.el7.centos.x86_64.rpm
abrt-addon-xorg-2.1.11-48.el7.centos.x86_64.rpm
rpm ivh rpm包文件 安装
[root@bogon Packages]# rpm -ivh zsh-5.0.2-28.el7.x86_64.rpm
准备中... ################################# [100%]
正在升级/安装...
1:zsh-5.0.2-28.el7 ################################# [100%]
[root@bogon Packages]# rpm -Uvh zsh-5.0.2-28.el7.x86_64.rpm
准备中... ################################# [100%]
软件包 zsh-5.0.2-28.el7.x86_64 已经安装
[root@bogon Packages]# rpm -e zsh
[root@bogon Packages]# rpm -qa |head
open-vm-tools-10.1.5-3.el7.x86_64
grub2-common-2.02-0.64.el7.centos.noarch
kexec-tools-2.0.14-17.el7.x86_64
setup-2.8.71-7.el7.noarch
NetworkManager-tui-1.8.0-9.el7.x86_64
basesystem-10.0-7.el7.centos.noarch
NetworkManager-wifi-1.8.0-9.el7.x86_64
bind-license-9.9.4-50.el7.noarch
postfix-2.10.1-6.el7.x86_64
firewalld-filesystem-0.4.4.4-6.el7.noarch
[root@bogon Packages]# rpm -q postfix-2.10.1-6.el7.x86_64
postfix-2.10.1-6.el7.x86_64
[root@bogon Packages]# rpm -qi postfix
Name : postfix
Epoch : 2
Version : 2.10.1
Release : 6.el7
Architecture: x86_64
Install Date: 2018年05月08日 星期二 00时11分28秒
Group : System Environment/Daemons
Size : 12773475
License : IBM and GPLv2+
Signature : RSA/SHA256, 2014年07月04日 星期五 12时33分15秒, Key ID 24c6a8a7f4a80eb5
Source RPM : postfix-2.10.1-6.el7.src.rpm
Build Date : 2014年06月10日 星期二 09时39分36秒
Build Host : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://www.postfix.org
Summary : Postfix Mail Transport Agent
Description :
Postfix is a Mail Transport Agent (MTA), supporting LDAP, SMTP AUTH (SASL),
TLS
[root@bogon Packages]# rpm -ql postfix /etc/pam.d/smtp /etc/pam.d/smtp.postfix /etc/postfix /etc/postfix/access /etc/postfix/canonical /etc/postfix/generic /etc/postfix/header_checks
[root@bogon Packages]# rpm -qf `which cd` bash-4.2.46-28.el7.x86_64 [root@bogon Packages]# which cd /usr/bin/cd [root@bogon Packages]# rpm -qf /usr/bin/cd bash-4.2.46-28.el7.x86_64
2、yum 工具
yum list 列出可用的rpm包
[root@bogon Packages]# yum list
......
zlib-devel.x86_64 1.2.7-17.el7 base
zlib-static.i686 1.2.7-17.el7 base
zlib-static.x86_64 1.2.7-17.el7 base
zsh.x86_64 5.0.2-28.el7 base
zsh-html.x86_64 5.0.2-28.el7 base
zziplib.i686 0.13.62-5.el7 base
zziplib.x86_64 0.13.62-5.el7 base
zziplib-devel.i686 0.13.62-5.el7 base
zziplib-devel.x86_64 0.13.62-5.el7 base
zziplib-utils.x86_64 0.13.62-5.el7 base
ls /etc/yum.repos.d/ yum配置文件
> [root@bogon Packages]# ls /etc/yum.repos.d/
> CentOS-Base.repo CentOS-CR.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Sources.repo CentOS-Vault.repo
yum search vim 搜索vim包
[root@bogon Packages]# yum search vim
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
============================================================ N/S matched: vim =============================================================
protobuf-vim.x86_64 : Vim syntax highlighting for Google Protocol Buffers descriptions
vim-X11.x86_64 : The VIM version of the vi editor for the X Window System
vim-common.x86_64 : The common files needed by any version of the VIM editor
vim-enhanced.x86_64 : A version of the VIM editor which includes recent enhancements
vim-filesystem.x86_64 : VIM filesystem layout
vim-minimal.x86_64 : A minimal version of the VIM editor
名称和简介匹配 only,使用“search all”试试。
yum list |grep 'vim'
[root@bogon Packages]# yum list |grep 'vim'
vim-common.x86_64 2:7.4.160-4.el7 @base
vim-enhanced.x86_64 2:7.4.160-4.el7 @base
vim-filesystem.x86_64 2:7.4.160-4.el7 @base
vim-minimal.x86_64 2:7.4.160-2.el7 @anaconda
protobuf-vim.x86_64 2.5.0-8.el7 base
vim-X11.x86_64 2:7.4.160-4.el7 base
vim-minimal.x86_64
yum install [-y] yum安装
[root@bogon Packages]# yum install -y vim
已加载插件:fastestmirror
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
updates/7/x86_64/primary_db | 2.0 MB 00:00:02
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
软件包 2:vim-enhanced-7.4.160-4.el7.x86_64 已安装并且是最新版本
无须任何处理
[root@bogon Packages]# yum grouplist
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Available Environment Groups:
Minimal Install
Compute Node
Infrastructure Server
File and Print Server
Basic Web Server
Virtualization Host
Server with GUI
GNOME Desktop
KDE Plasma Workspaces
Development and Creative Workstation
Available Groups:
Compatibility Libraries
Console Internet Tools
Development Tools
Graphical Administration Tools
Legacy UNIX Compatibility
Scientific Support
Security Tools
Smart Card Support
System Administration Tools
System Management
Done
[root@bogon Packages]# yum groupinstall 'Virtualization Host'
......
[root@bogon Packages]# yum remove -y zip
[root@bogon Packages]# yum update -y zip
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
No packages marked for update
yum provides "/*/vim"
[root@bogon Packages]# yum provides "/*/vim"
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base/7/x86_64/filelists_db | 6.9 MB 00:00:05
extras/7/x86_64/filelists_db | 519 kB 00:00:00
updates/7/x86_64/filelists_db | 1.3 MB 00:00:01
cmake-2.8.12.2-2.el7.x86_64 : Cross-platform make system
Repo : base
Matched from:
Filename : /usr/share/cmake/editors/vim
2:docker-unit-test-1.13.1-53.git774336d.el7.centos.x86_64 : Automates deployment of containerized applications - for running unit tests
Repo : extras
Matched from:
Filename : /var/lib/docker-unit-test/v1.10-migrator-c417a6a022c5023c111662e8280f885f6ac259be/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim
Filename : /var/lib/docker-unit-test/contrib/syntax/vim
Filename : /var/lib/docker-unit-test/runc-e9c345b3f906d5dc5e8100b05ce37073a811c74a/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim
Filename : /var/lib/docker-unit-test/docker-novolume-plugin-385ec70baac3ef356f868f391c8d7818140fbd44/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim
Filename : /var/lib/docker-unit-test/containerd-296f1f80d6c6a83cc625163f863e53d3287328ee/vendor/src/github.com/docker/docker/contrib/syntax/vim
2:docker-unit-test-1.13.1-58.git87f2fab.el7.centos.x86_64 : Automates deployment of containerized applications - for running unit tests
Repo : extras
Matched from:
Filename : /var/lib/docker-unit-test/v1.10-migrator-c417a6a022c5023c111662e8280f885f6ac259be/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim
Filename : /var/lib/docker-unit-test/contrib/syntax/vim
Filename : /var/lib/docker-unit-test/runc-e9c345b3f906d5dc5e8100b05ce37073a811c74a/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim
Filename : /var/lib/docker-unit-test/docker-novolume-plugin-385ec70baac3ef356f868f391c8d7818140fbd44/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim
Filename : /var/lib/docker-unit-test/containerd-296f1f80d6c6a83cc625163f863e53d3287328ee/vendor/src/github.com/docker/docker/contrib/syntax/vim
2:docker-unit-test-1.13.1-63.git94f4240.el7.centos.x86_64 : Automates deployment of containerized applications - for running unit tests
Repo : extras
Matched from:
Filename : /var/lib/docker-unit-test/v1.10-migrator-c417a6a022c5023c111662e8280f885f6ac259be/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim
Filename : /var/lib/docker-unit-test/contrib/syntax/vim
Filename : /var/lib/docker-unit-test/runc-e9c345b3f906d5dc5e8100b05ce37073a811c74a/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim
Filename : /var/lib/docker-unit-test/docker-novolume-plugin-385ec70baac3ef356f868f391c8d7818140fbd44/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim
Filename : /var/lib/docker-unit-test/containerd-296f1f80d6c6a83cc625163f863e53d3287328ee/vendor/src/github.com/docker/docker/contrib/syntax/vim
git-1.8.3.1-13.el7.x86_64 : Fast Version Control System
Repo : base
Matched from:
Filename : /usr/share/doc/git-1.8.3.1/contrib/vim
2:vim-common-7.4.160-4.el7.x86_64 : The common files needed by any version of the VIM editor
Repo : base
Matched from:
Filename : /usr/share/vim
2:vim-enhanced-7.4.160-4.el7.x86_64 : A version of the VIM editor which includes recent enhancements
Repo : base
Matched from:
Filename : /usr/bin/vim
2:vim-enhanced-7.4.160-4.el7.x86_64 : A version of the VIM editor which includes recent enhancements
Repo : @base
Matched from:
Filename : /usr/bin/vim
yum 本地仓库
[root@bogon ~]# cp -r /etc/yum.repos.d /etc/yum.repos.d.bak
[root@bogon ~]# cd /etc/yum.repos.d
[root@bogon yum.repos.d]# ls
CentOS-Base.repo CentOS-CR.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Sources.repo CentOS-Vault.repo CentOS-fasttrack.repo
[root@bogon yum.repos.d]# rm -f /etc/yum.repos.d/*
写入
[dvd]
name=install dvd
baseurl=file:///mnt
enable=1
gpcheck=0
清除缓存
[root@bogon ~]yum clean all
[root@bogon ~]yum list
更换yum仓库源
[root@bogon yum.repos.d]# ls
dvd.repo
[root@bogon yum.repos.d]# rm -f dvd.repo
[root@bogon yum.repos.d]# cp ../yum.repos.d.bak/* .
[root@bogon yum.repos.d]# ls
CentOS-Base.repo CentOS-CR.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Sources.repo CentOS-Vault.repo CentOS-fasttrack.repo
[root@bogon yum.repos.d]#
[root@bogon yum.repos.d]# rm -f CentOS-Base.repo
[root@bogon yum.repos.d]# curl -O http://mirrors.163.com/.help/CentOS7-Base-163.repo
安装扩展源epel
[root@bogon yum.repos.d]# ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Sources.repo CentOS-fasttrack.repo
CentOS-CR.repo CentOS-Media.repo CentOS-Vault.repo CentOS7-Base-163.repo
[root@bogon yum.repos.d]# yum install -y epel-release
Failed to set locale, defaulting to C
.......
[root@bogon yum.repos.d]# ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Sources.repo CentOS-fasttrack.repo epel-testing.repo
CentOS-CR.repo CentOS-Media.repo CentOS-Vault.repo CentOS7-Base-163.repo epel.repo
[root@bogon yum.repos.d]# cat epel.repo
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
[epel-debuginfo]
name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch/debug
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1
[epel-source]
name=Extra Packages for Enterprise Linux 7 - $basearch - Source
#baseurl=http://download.fedoraproject.org/pub/epel/7/SRPMS
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1
[root@bogon yum.repos.d]# yum list |grep epel
......
yum 下载rpm包
[root@bogon yum.repos.d]# yum install -y bash --downloadonly
[root@bogon yum.repos.d]# yum install -y bash --downloadonly --downloaddir=/tmp/
[root@bogon yum.repos.d]# yum reinstall -y bash --downloadonly --downloaddir=/tmp/
3、源码包安装
[root@bogon yum.repos.d]# cd /usr/local/src/
[root@bogon src]# wget http://archive.apache.org/dist/httpd/httpd-2.2.9.tar.gz
解压缩
[root@bogon src]# tar -zxvf httpd-2.2.9.tar.gz
......
[root@bogon src]# ls
httpd-2.2.9 httpd-2.2.9.tar.gz
[root@bogon src]#
[root@bogon src]# cd httpd-2.2.9
[root@bogon httpd-2.2.9]# ls
ABOUT_APACHE CHANGES LICENSE NWGNUmakefile VERSIONING buildconf docs include server
Apache.dsw INSTALL Makefile.in README acinclude.m4 config.layout emacs-style libhttpd.dsp srclib
BuildAll.dsp InstallBin.dsp Makefile.win README.platforms apachenw.mcp.zip configure httpd.dsp modules support
BuildBin.dsp LAYOUT NOTICE ROADMAP build configure.in httpd.spec os test
[root@bogon httpd-2.2.9]#
[root@bogon httpd-2.2.9]# ./configure --prefix=/usr/local/apache2 指定路径安装
[root@bogon httpd-2.2.9]# make
[root@bogon httpd-2.2.9]# make install 安装步骤,创建相关的存放目录和配置文件
[root@bogon httpd-2.2.9]# ls /usr/local/apache2/
bin build cgi-bin conf error htdocs icons include lib logs man manual modules
补充:echo $? 检查上一条命令,非0代表命令没有执行成功