Linux上的軟件安裝可以分為三種方式:
1. yum安裝
yum基于RPM包管理,一次性安裝所有依賴包,提供了查找、安裝、刪除一個(gè)、一組
至全部軟件包的命令,配置文件在/etc/yum.repos.d/下
主要命令:
yum install gcc g++
yum remove wget
yum list installed //顯示已經(jīng)安裝過的軟件
yum list //顯示所有可以安裝的包
.
[wyb@localhost ~]$ wget -h //驗(yàn)證有沒有安裝wget
-bash: /usr/bin/wget: No such file or directory
[wyb@localhost ~]$ sudo yum search wget //通過yum查找wget,看有沒有這個(gè)軟件包
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirrors.yun-idc.com
* extras: mirrors.pubyun.com
* updates: mirrors.yun-idc.com
============================== N/S Matched: wget ===============================
wget.x86_64 : A utility for retrieving files using the HTTP or FTP protocols
Name and summary matches only, use "search all" for everything.
[wyb@localhost ~]$ sudo yum deplist wget //列出安裝包的依賴項(xiàng)
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirrors.yun-idc.com
* extras: mirrors.pubyun.com
* updates: mirrors.yun-idc.com
Finding dependencies:
package: wget.x86_64 1.12-5.el6_6.1
dependency: libssl.so.10()(64bit)
provider: openssl.x86_64 1.0.1e-42.el6
provider: openssl.x86_64 1.0.1e-42.el6_7.1
provider: openssl.x86_64 1.0.1e-42.el6_7.2
provider: openssl.x86_64 1.0.1e-42.el6_7.4
[wyb@localhost ~]$ sudo yum install wget //安裝一個(gè)或兩個(gè)軟件包
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirrors.yun-idc.com
* extras: mirrors.pubyun.com
* updates: mirrors.yun-idc.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.12-5.el6_6.1 will be installed
--> Finished Dependency Resolution
[wyb@localhost ~]$ sudo yum remove wget //移除wget
[sudo] password for wyb:
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.12-5.el6_6.1 will be erased
--> Finished Dependency Resolution
2. rpm安裝
分為:二進(jìn)制包和源代碼包
二進(jìn)制包可直接安裝,源碼包會(huì)由rpm自動(dòng)編譯、安裝,安裝包常以src、rpm做為后綴
主要參數(shù):
-ivh *.rpm 安裝并顯示安裝進(jìn)度
-Uvh *.rpm 升級(jí)軟件包
-qpl *.rpm 查看rpm軟件包內(nèi)的包含的文件,顯示安裝后文件釋放的絕對(duì)路徑
-qpi *.rpm 列出rpm軟件包的描述信息
-qa 查找所有通過rpm安裝的軟件
-qf /etc/httpd/conf/httpd.conf 查找文件屬于那個(gè)安裝包
-va 檢驗(yàn)軟件包有沒有丟失信息
-e 軟件名 移除軟件包
用rpm安裝軟件:
[wyb@localhost ~]$ wget http://192.168.1.7/wget-1.12-5.el6_6.1.x86_64.rpm //使用wget下載軟件
--2016-04-18 04:31:27-- http://192.168.1.7/wget-1.12-5.el6_6.1.x86_64.rpm
Connecting to 192.168.1.7:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 494884 (483K) [application/x-rpm]
Saving to: 鈝get-1.12-5.el6_6.1.x86_64.rpm?
100%[======================================>] 494,884 1006K/s in 0.5s
2016-04-18 04:31:27 (1006 KB/s) - 鈝get-1.12-5.el6_6.1.x86_64.rpm鈙aved [494884/494884]
先yum remove wget卸載wget,然后用rpm安裝軟件
[wyb@localhost ~]$ ls
wget-1.12-5.el6_6.1.x86_64.rpm
[wyb@localhost ~]$ sudo rpm -ivh wget-1.12-5.el6_6.1.x86_64.rpm //安裝wget
Preparing... ########################################### [100%]
1:wget ########################################### [100%]
[wyb@localhost ~]$ sudo rpm -qpl wget-1.12-5.el6_6.1.x86_64.rpm //查看軟件包內(nèi)的內(nèi)容
/etc/wgetrc
/usr/bin/wget
/usr/share/doc/wget-1.12
/usr/share/doc/wget-1.12/AUTHORS
/usr/share/doc/wget-1.12/COPYING
/usr/share/doc/wget-1.12/MAILING-LIST
/usr/share/doc/wget-1.12/NEWS
/usr/share/doc/wget-1.12/README
/usr/share/doc/wget-1.12/sample.wgetrc
/usr/share/info/wget.info.gz
/usr/share/locale/be/LC_MESSAGES/wget.mo
/usr/share/locale/bg/LC_MESSAGES/wget.mo
[wyb@localhost ~]$ sudo rpm -qpi wget-1.12-5.el6_6.1.x86_64.rpm //列出包的描述信息
Name : wget Relocations: (not relocatable)
Version : 1.12 Vendor: CentOS
Release : 5.el6_6.1 Build Date: Thu 30 Oct 2014 10:22:02 AM PDT
Install Date: (not installed) Build Host: c6b8.bsys.dev.centos.org
Group : Applications/Internet Source RPM: wget-1.12-5.el6_6.1.src.
[wyb@localhost ~]$ rpm -qa |grep wget //-qa查看所有安裝的軟件,用grep篩選出來,看有沒有安裝wget
wget-1.12-5.el6_6.1.x86_64
[wyb@localhost ~]$ which wget
/usr/bin/wget
[wyb@localhost ~]$ sudo rpm -qf /usr/bin/wget //查看wget這個(gè)文件屬于那個(gè)軟件
wget-1.12-5.el6_6.1.x86_64
[wyb@localhost ~]$ sudo rpm -e wget //寫在軟件wget
[wyb@localhost ~]$ wget -h
-bash: /usr/bin/wget: No such file or directory
3. 源碼安裝
sudo yum groupinstall "Development tools" //如果你源碼安裝軟件就需要安裝這個(gè)
.
源代碼安裝軟件:
1、./configure,對(duì)系統(tǒng)進(jìn)行檢測(cè)然后生成makefile,為下一步的編譯做準(zhǔn)備
./configure -prefix=/usr軟件將安裝在/usr下面,可執(zhí)行文件則會(huì)安裝在/usr/bin,默認(rèn)安裝在/usr/local/bin
2、make,這一步就是編譯,大多數(shù)的源碼包都經(jīng)過這一步進(jìn)行編譯,這時(shí)軟件已經(jīng)可以用了,不過要通過全路徑來執(zhí)行
實(shí)際上它不是編譯工具,其實(shí)是一個(gè)構(gòu)建工具
3、make install 進(jìn)行安裝,一般你要擁有root權(quán)限,因?yàn)橐蛳到y(tǒng)寫入東西,相當(dāng)與配環(huán)境變量、將二進(jìn)制文件拷貝到/usr/local/bin下面
4、make clean將由make產(chǎn)生的過程文件清除
.
PS:
curl -o wget.rpm url可以訪問網(wǎng)頁,它同時(shí)還保存了文件,文件名為wget.rpm
wget url也能下載,文件名為全名
Linux下的env可查看環(huán)境變量