标签:联网 lis eve 错误 运行 下载源码 clean only 绝对路径
Linux安装软件包的三种方法rpm工具:预先在Linux机器上编译并打包安装的文件,安装迅速。(缺点:安装程序包时,有可能因为依赖另外一个程序包而无法安装)
yum工具:可以使用工具安装时,同时将依赖的另外的程序包同时安装好;(CentOS中免费,Red Hat里需要付费)
源码包:一般源码包都是通过C语言开发出来的,Linux机器必须安装gcc才能编译;
检测命令
echo $?
检查上一条命令是否错误
0为正确 1为错误
rpm包格式:包名、版本号、发布版本号、平台
举例:libjpeg-turbo-devel-1.2.90-5.el7.x86_64.rpm
包名为:libjpeg-turbo-devel
版本号:1.2.90
发布版本号:5.el7
平台:x86_64
准备工作:
光驱设置好系统安装盘镜像,将光驱挂载到/mnt目录下:
[root@shu-test ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@shu-test ~]# df -h |grep -v tmpfs
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda3 28G 1.5G 27G 6% /
/dev/sda1 197M 97M 100M 50% /boot
/dev/sr0 4.3G 4.3G 0 100% /mnt
[root@shu-test ~]# cd /mnt/
[root@shu-test mnt]# ls
CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7
EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL
[root@shu-test mnt]#
格式:
rpm -ivh [rpm包文件]
[root@shu-test Packages]# rpm -ivh zsh-5.0.2-28.el7.x86_64.rpm
准备中... ################################# [100%]
正在升级/安装...
1:zsh-5.0.2-28.el7 ################################# [100%]
[root@shu-test Packages]#
格式:
rpm -Uvh [rpm包文件]
格式:
rpm -e [rpm包名]
[root@shu-test Packages]# rpm -e zsh
[root@shu-test Packages]#
格式:
rpm -qa
格式:
rpm -q [包名]
格式:
rpm -qi [包名]
格式:
rpm -ql [包名]
[root@shu-test Packages]# 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@shu-test Packages]#
格式:
rpm -qf [文件绝对路径]
[root@shu-test Packages]# rpm -qf /usr/bin/vim
vim-enhanced-7.4.160-2.el7.x86_64
[root@shu-test Packages]#
yum工具最大的优势就是可以在联网去下载所需要的RPM包,然后自动安装。如果要安装的RPM包邮依赖关系,yum工具会帮我们依次安装所有相关的RPM包;
格式:
yum list
[root@shu-test Packages]# yum list | head -n 10
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* epel: mirrors.sohu.com
已安装的软件包
GeoIP.x86_64 1.5.0-11.el7 @anaconda
NetworkManager.x86_64 1:1.8.0-9.el7 @anaconda
NetworkManager-libnm.x86_64 1:1.8.0-9.el7 @anaconda
NetworkManager-team.x86_64 1:1.8.0-9.el7 @anaconda
NetworkManager-tui.x86_64 1:1.8.0-9.el7 @anaconda
NetworkManager-wifi.x86_64 1:1.8.0-9.el7 @anaconda
由于管道被破坏而退出
[root@shu-test Packages]#
格式:
yum search [关键词]
[root@shu-test Packages]# yum search vim
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* epel: mirrors.sohu.com
======================================== N/S matched: vim ========================================
beakerlib-vim-syntax.noarch : Files for syntax highlighting BeakerLib tests in VIM editor
fluxbox-vim-syntax.noarch : Fluxbox syntax scripts for vim
neovim.x86_64 : Vim-fork focused on extensibility and agility
protobuf-vim.x86_64 : Vim syntax highlighting for Google Protocol Buffers descriptions
python2-neovim.noarch : Python client to Neovim
python34-neovim.noarch : Python client to Neovim
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-go.x86_64 : Go development plugin for Vim
vim-gtk-syntax.noarch : Vim syntax highlighting for GLib, Gtk+, Gstreamer, and more
vim-minimal.x86_64 : A minimal version of the VIM editor
vim-vimoutliner.noarch : Script for building an outline editor on top of Vim
xtuple-csvimp-devel.x86_64 : CSVImp development files
vim-halibut.noarch : Syntax file for the halibut manual tool
xtuple-csvimp.x86_64 : xTuple data import utility
名称和简介匹配 only,使用“search all”试试。
[root@shu-test Packages]#
使用管道符搜索
yum list | grep ‘vim‘
[root@shu-test Packages]# yum list | grep ‘vim‘
vim-common.x86_64 2:7.4.160-2.el7 @base
vim-enhanced.x86_64 2:7.4.160-2.el7 @base
vim-filesystem.x86_64 2:7.4.160-2.el7 @base
vim-minimal.x86_64 2:7.4.160-2.el7 @anaconda
beakerlib-vim-syntax.noarch 1.16-3.el7 epel
fluxbox-vim-syntax.noarch 1.3.7-1.el7 epel
neovim.x86_64 0.2.0-2.el7 epel
protobuf-vim.x86_64 2.5.0-8.el7 base
python2-neovim.noarch 0.1.13-3.el7 epel
python34-neovim.noarch 0.1.13-3.el7 epel
vim-X11.x86_64 2:7.4.160-2.el7 base
vim-go.x86_64 1.8-3.el7 epel
vim-gtk-syntax.noarch 20130716-1.el7 epel
vim-halibut.noarch 1.2-1.el7 epel
vim-vimoutliner.noarch 0.3.7-5.el7 epel
xtuple-csvimp.x86_64 0.5.4-8.el7 epel
xtuple-csvimp-devel.x86_64 0.5.4-8.el7 epel
[root@shu-test Packages]#
格式:
yum install [-y] [包名]
[root@shu-test Packages]# yum install -y protobuf
已加载插件:fastestmirror
base | 3.6 kB 00:00:00
epel/x86_64/metalink | 8.0 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/4): epel/x86_64/updateinfo | 866 kB 00:00:05
(2/4): epel/x86_64/primary_db | 6.2 MB 00:00:00
(3/4): extras/7/x86_64/primary_db | 145 kB 00:00:05
(4/4): updates/7/x86_64/primary_db | 5.2 MB 00:00:09
Loading mirror speeds from cached hostfile
* epel: mirrors.sohu.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 protobuf.x86_64.0.2.5.0-8.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
==================================================================================================
Package 架构 版本 源 大小
==================================================================================================
正在安装:
protobuf x86_64 2.5.0-8.el7 base 338 k
事务概要
==================================================================================================
安装 1 软件包
总下载量:338 k
安装大小:1.1 M
Downloading packages:
protobuf-2.5.0-8.el7.x86_64.rpm | 338 kB 00:00:05
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : protobuf-2.5.0-8.el7.x86_64 1/1
验证中 : protobuf-2.5.0-8.el7.x86_64 1/1
已安装:
protobuf.x86_64 0:2.5.0-8.el7
完毕!
[root@shu-test Packages]#
格式:
yum remove [-y] [RPM包]
格式:
yum update [-y] [RPM包]
格式:
yum provides “[命令]”
yum provides "/*/vim"
当系统无法联网时,就无法便捷实用yum工具了,此时我们可以实用光盘系统制作yum源;
mount /dev/cdrom /mnt
cp -r /etc/yum.repos.d /etc/yum.repos.d.bak
[root@shu-test Packages]# cd /etc/yum.repos.d
[root@shu-test yum.repos.d]# rm -rf ./*
/etc/yum.repos.d/dvd.repo
以及文件内容
[root@shu-test yum.repos.d]# vim /etc/yum.repos.d/dvd.repo
[dvd]
name=install dvd
baseurl=file:///mnt
enable=1
gpcheck=0
yum clean all
[root@shu-test yum.repos.d]# yum clean all
已加载插件:fastestmirror
正在清理软件源: dvd
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@shu-test yum.repos.d]#
yum makecache
[root@shu-test yum.repos.d]# yum makecache
已加载插件:fastestmirror
dvd | 3.6 kB 00:00:00
(1/4): dvd/group_gz | 156 kB 00:00:00
(2/4): dvd/filelists_db | 3.1 MB 00:00:00
(3/4): dvd/primary_db | 3.1 MB 00:00:00
(4/4): dvd/other_db | 1.2 MB 00:00:00
Determining fastest mirrors
元数据缓存已建立
[root@shu-test yum.repos.d]#
[root@shu-test yum.repos.d]# yum install -y tftp
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 tftp.x86_64.0.5.2-13.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
==================================================================================================
Package 架构 版本 源 大小
==================================================================================================
正在安装:
tftp x86_64 5.2-13.el7 dvd 35 k
事务概要
==================================================================================================
安装 1 软件包
总下载量:35 k
安装大小:48 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : tftp-5.2-13.el7.x86_64 1/1
验证中 : tftp-5.2-13.el7.x86_64 1/1
已安装:
tftp.x86_64 0:5.2-13.el7
完毕!
[root@shu-test yum.repos.d]#
yum联网下载源一般都是国外网络资源,我们为了更快安装可以更换为国内的资源下载;
cd /etc/yum.repos.d
rm -rf CentOS-Base.repo
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
[root@shu-test yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
--2018-01-09 01:13:09-- http://mirrors.163.com/.help/CentOS7-Base-163.repo
正在解析主机 mirrors.163.com (mirrors.163.com)... 59.111.0.251
正在连接 mirrors.163.com (mirrors.163.com)|59.111.0.251|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1572 (1.5K) [application/octet-stream]
正在保存至: “CentOS7-Base-163.repo”
100%[========================================================>] 1,572 --.-K/s 用时 0s
2018-01-09 01:13:15 (108 MB/s) - 已保存 “CentOS7-Base-163.repo” [1572/1572])
[root@shu-test yum.repos.d]# ls
CentOS7-Base-163.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo
[root@shu-test yum.repos.d]#
或者
curl -O http://mirrors.163.com/.help/CentOS7-Base-163.repo
有时候我们需要下载RPM包但不安装,仅仅是复制给其他机器使用;
默认RPM包保存路径为/var/cache/yum/x86_64/7/base/packages/
格式:
yum install [包名] -y --downloadonly
[root@shu-test yum.repos.d]# yum install zsh --downloadonly
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 zsh.x86_64.0.5.0.2-28.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
==================================================================================================
Package 架构 版本 源 大小
==================================================================================================
正在安装:
zsh x86_64 5.0.2-28.el7 base 2.4 M
事务概要
==================================================================================================
安装 1 软件包
总计:2.4 M
安装大小:5.6 M
Background downloading packages, then exiting:
exiting because "Download Only" specified
[root@shu-test yum.repos.d]# rpm -q zsh
未安装软件包 zsh
[root@shu-test yum.repos.d]# ls /var/cache/yum/x86_64/7/base/packages/
zsh-5.0.2-28.el7.x86_64.rpm
[root@shu-test yum.repos.d]#
格式:
yum install [包名] --downloadonly --downloaddir=[路径]
[root@shu-test yum.repos.d]# yum install zsh --downloadonly --downloaddir=/tmp/
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 zsh.x86_64.0.5.0.2-28.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
==================================================================================================
Package 架构 版本 源 大小
==================================================================================================
正在安装:
zsh x86_64 5.0.2-28.el7 base 2.4 M
事务概要
==================================================================================================
安装 1 软件包
总下载量:2.4 M
安装大小:5.6 M
Background downloading packages, then exiting:
exiting because "Download Only" specified
[root@shu-test yum.repos.d]# ls /tmp/
1.txt
b
d6z
d6z.tar
systemd-private-29a53244520c4fe384fbfe93dd3912c7-chronyd.service-4xzXLI
systemd-private-29a53244520c4fe384fbfe93dd3912c7-vgauthd.service-G8e3b4
systemd-private-29a53244520c4fe384fbfe93dd3912c7-vmtoolsd.service-w9qRlq
yum_save_tx.2018-01-09.01-34.V0zRaP.yumtx
yum_save_tx.2018-01-09.01-36.aUdoib.yumtx
yum_save_tx.2018-01-09.01-37.eAOZ3u.yumtx
yum_save_tx.2018-01-09.01-43.UDTWTf.yumtx
zsh-5.0.2-28.el7.x86_64.rpm
[root@shu-test yum.repos.d]#
格式:
yum reinstall -y [包名] --downloadonly --downloaddir=[路径]
[root@shu-test yum.repos.d]# yum reinstall vim-enhanced.x86_64 --downloadonly --downloaddir=/tmp/
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 vim-enhanced.x86_64.2.7.4.160-2.el7 将被 已重新安装
--> 解决依赖关系完成
依赖关系解决
==================================================================================================
Package 架构 版本 源 大小
==================================================================================================
重新安装:
vim-enhanced x86_64 2:7.4.160-2.el7 base 1.0 M
事务概要
==================================================================================================
重新安装 1 软件包
总下载量:1.0 M
安装大小:2.2 M
Background downloading packages, then exiting:
vim-enhanced-7.4.160-2.el7.x86_64.rpm | 1.0 MB 00:00:06
exiting because "Download Only" specified
[root@shu-test yum.repos.d]# ls /tmp/
1.txt
b
d6z
d6z.tar
systemd-private-29a53244520c4fe384fbfe93dd3912c7-chronyd.service-4xzXLI
systemd-private-29a53244520c4fe384fbfe93dd3912c7-vgauthd.service-G8e3b4
systemd-private-29a53244520c4fe384fbfe93dd3912c7-vmtoolsd.service-w9qRlq
vim-enhanced-7.4.160-2.el7.x86_64.rpm
yum_save_tx.2018-01-09.01-34.V0zRaP.yumtx
yum_save_tx.2018-01-09.01-36.aUdoib.yumtx
yum_save_tx.2018-01-09.01-37.eAOZ3u.yumtx
yum_save_tx.2018-01-09.01-43.UDTWTf.yumtx
yum_save_tx.2018-01-09.01-46.58Zlvk.yumtx
zsh-5.0.2-28.el7.x86_64.rpm
[root@shu-test yum.repos.d]#
删除目录即可删除源码包;
源码包的编译必须通过GCC编译器,所以必须安装好gcc才能正常安装源码包;
yum install -y gcc
cd /usr/local/src
wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.34.tar.gz
[root@shu-test src]# wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.34.tar.gz
--2018-01-09 01:51:34-- http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.34.tar.gz
正在解析主机 mirrors.cnnic.cn (mirrors.cnnic.cn)... 101.6.6.178, 2402:f000:1:416:101:6:6:178
正在连接 mirrors.cnnic.cn (mirrors.cnnic.cn)|101.6.6.178|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:7684419 (7.3M) [application/octet-stream]
正在保存至: “httpd-2.2.34.tar.gz”
100%[========================================================>] 7,684,419 1.09MB/s 用时 6.8s
2018-01-09 01:51:46 (1.08 MB/s) - 已保存 “httpd-2.2.34.tar.gz” [7684419/7684419])
[root@shu-test src]#
tar -zxvf httpd-2.2.34.tar.gz
more INSTALL
安装方法
$ ./configure --prefix=PREFIX
$ make
$ make install
$ PREFIX/bin/apachectl start
./configure --prefix=/usr/local/apache2
make
make install
/usr/local/apache2/bin/apachectl start
rpm工具使用、yum工具使用、源码包安装、yum更换国内源、使用系统盘搭建本地仓库源
标签:联网 lis eve 错误 运行 下载源码 clean only 绝对路径
原文地址:http://blog.51cto.com/shuzonglu/2058893