软件安装及软件包管理
1、rpm包
由紅帽公司開發(fā)用于軟件包的安裝、升級、卸載與查詢的包管理工具
[root@localhost ~]# rpm -qa tree
tree-1.6.0-10.el7.x86_64 tree(軟件包名)-1.6.0(發(fā)布版本)-10(發(fā)布次數(shù)).el7(系統(tǒng)版本).x86_64(硬件平臺).rpm(擴展名)
①命令格式
rpm 【選項】【軟件包名稱】
-i 安裝rpm
-v 顯示安裝信息
-h 顯示安裝進度
-e 卸載軟件包
-e --force --nodeps 強制卸載
②rpm包安裝方法
[root@localhost ~]# cd /usr/src(操作系統(tǒng)存放源碼目錄)
[root@localhost src]# wget +rpm包網(wǎng)址鏈接
[root@localhost src]# rpm ivh 包名
軟件包直接拖進去
③查詢
rpm 【選項】【軟件包名稱】
-qa 查有系統(tǒng)中已安裝的所有RPM軟件包列表
-ql 查詢指定軟件包所安裝的目錄、文件列表
-qc 查詢指定軟件包的配置文件
-qi 查詢指定軟件的詳細信息
-qf 查詢文件或目錄屬于哪個RPM軟件包
優(yōu)點:軟件開發(fā)商預先編譯打包,安裝簡單,安裝路徑固定。
缺點:版本可能偏低,安裝有很嚴重依賴關(guān)系。
2、yum安裝管理
①什么是yum?
Yum是RedHat以及CentOS中的軟件包管理器。能夠通過互聯(lián)網(wǎng)下載rpm包并且安裝,并可以自動處理依賴性關(guān)系,無須繁瑣地一次次下載、安裝。(yum是生產(chǎn)常用安裝工具)
②什么是yum源
要想使用yum工具安裝、更新軟件,就需要有一個包含各種rpm軟件包的軟件倉庫,這樣的軟件倉庫就稱為yum源(yum 源默認都在/etc/yum.repos.d目錄下,以*.repo結(jié)尾)
yum源分為:
a.互聯(lián)網(wǎng)yum源
b.局域網(wǎng)yum源
c.服務器本地 yum源
③yum用法
yum list 查詢
yum install [軟件名] -y(非交互) 安裝軟件包
yum clean 刪除緩存數(shù)據(jù)
yum makecache 創(chuàng)建元數(shù)據(jù)緩存
④本地yum倉庫搭建
[root@localhost ~]# mount /dev/sr0 /mnt
[root@localhost yum.repos.d]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mkdir wmc
[root@localhost yum.repos.d]# mv *.repo wmc/
[root@localhost yum.repos.d]# vim cc.repo
[cc]? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # 倉庫名稱
name=wmc? ? ? ? ? ? ? ? ? ? ?#倉庫描述信息
baseurl=file:///mnt? ? ? ? ? #yum源url地址,可以是file://(本地) ftp://(局域網(wǎng)) http://(公網(wǎng))
enable=1? ? ? ? ? ? ? ? ? ? ? ? ?#是否使用該yum源(1代表激活,0代表禁用)
gpgcheck=0? ? ? ? ? ? ? ? ? ? ? ?#是否驗證軟件簽名(1代表激活,0代表禁用)
[root@localhost yum.repos.d]# yum clean all $$ yum makecache
已加載插件:fastestmirror, langpacks wmc | 3.6 kB 00:00
(1/4): wmc/group_gz | 156 kB 00:00
(2/4): wmc/filelists_db | 3.1 MB 00:00
(3/4): wmc/primary_db | 3.1 MB 00:00
(4/4): wmc/other_db | 1.2 MB 00:00
Determining fastest mirrors 元數(shù)據(jù)緩存已建立
3、源碼安裝
①什么是源碼包?
源碼包指的是開發(fā)人員編寫好的程序源代碼,但并沒有將其編譯為一個能正常使用的工具或軟件。
②為什么要源碼包安裝
部分軟件宮網(wǎng)僅提供源碼包,需要自行編譯并安裝。
部分軟件在新版本有一些特性還沒來得及制作成rpm包時,可以自行編譯軟件增加或使用其新特性。
③源碼包的優(yōu)缺點
優(yōu)點:可以自行修改源代碼,可以定制需要的相關(guān)功能。
缺點:相對yum安裝軟件會復雜很多,標準化實施困難,白動化運維復雜。
④編譯安裝源碼包軟件
步驟1:tar解包 用途:解壓并釋放源代碼包到指定的目錄
步驟2:/configure配置 用途:設(shè)置安裝目錄、安裝模塊等選項、生成makefile
步驟3:make編譯 用途:將makefile生成可執(zhí)行的二進制文件
步驟4:make install安裝 用途:復制二進制文件到系統(tǒng),配置應用環(huán)境
【例】通過編譯Nginx來展現(xiàn)源碼包編譯過程
a.基礎(chǔ)環(huán)境準備
[root@localhost ~]# yum install httpd -y
b.下載源碼包
[root@localhost ~]# wget -q https://nginx.org/download/nginx-1.20.2.tar.gz
[root@localhost ~]# ls nginx-1.20.2.tar.gz
c.解壓源碼包,并進入相應目錄
[root@localhost ~]# tar xf nginx-1.20.2.tar.gz
[root@localhost ~]# cd nginx-1.20.2/
d.配置相關(guān)的選項,并生成makefile
[root@localhost nginx-1.20.2]# ./configure --prefix=/nginx-1.20.2
e.將makefile文件編譯可執(zhí)行二進制程序
[root@localhost nginx-1.20.2]# make
f.將二進制程序拷貝至對應的目錄中
[root@localhost nginx-1.20.2]# make install
###############################################
[root@localhost nginx-1.20.2]# /nginx-1.20.2/sbin/nginx
[root@localhost nginx-1.20.2]# netstat -lntup|grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 9663/nginx: master
[root@localhost nginx-1.20.2]# curl 127.0.0.1
?
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
?
?
For online documentation and support please refer to?nginx.org.
Commercial support is available at?nginx.com.
??
Thank you for using nginx.
?
</body> </html>
##############################################
#配置相關(guān)的選項,并生成makefile,報錯解決方案
./configure: error: the HTTP rewrite module requires the PCRE library. You can either disable the module by using --without-http_rewrite_module option, or install the PCRE library into the system, or build the PCRE library statically from the source with nginx by using --with-pcre=<path> option.
[root@localhost nginx-1.20.2]# yum install pcre-devel -y
./configure: error: the HTTP gzip module requires the zlib library. You can either disable the module by using --without-http_gzip_module option, or install the zlib library into the system, or build the zlib library statically from the source with nginx by using --with-zlib=<path> option.
[root@localhost nginx-1.20.2]# yum install zlib-devel -y
總結(jié)
以上是生活随笔為你收集整理的软件安装及软件包管理的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 计算机一级要下什么软件练习,国家计算机一
- 下一篇: Android手机通讯录制作