linux软件安装管理
Linux軟件安裝管理
TonyLinux系統(tǒng)工程師 收藏 ????
上面是linux 的源代碼安裝包
?
?
?
linux有兩種類型的軟件安裝方式:
1、源代碼安裝
? 這種方式的軟件安裝,可以指定軟件的安裝目錄,軟件的運行效率高,如何是大規(guī)模的并發(fā),安裝apache軟件最好使用源代碼包安裝,使用源代碼包安裝軟件卸載方便,直接刪除軟件安裝目錄就可以了
2、rpm安裝包
rmp是源代碼經(jīng)過編譯之后的安裝包,安裝方式簡單,便于新手安裝,winddows操作系統(tǒng)上的.exe文件就是經(jīng)過源代碼編譯之后對應的二進制安裝包,優(yōu)點是安裝簡單,只需要簡單的命令
就可以使用軟件的安裝升級和查詢,ubuntu對應的二進制安裝包對應的后綴是deb文件
rmp有一個很大的區(qū)別,就是軟件安裝存在依賴性,這個依賴性可以使用yum安裝進行解決。
?
接下來我們來學習rpm的常用操作,首先給光盤創(chuàng)建一個掛載點?
Linux系統(tǒng)中掛載和使用光盤的基本步驟
1. 創(chuàng)建掛載點
mkdir /mnt/cdrom
2. 打開光驅(qū),放入光盤
如果用的是VMware中的虛擬機,進入虛擬機設(shè)置,選擇“CD/DVD”硬件,勾選“已連接”和“啟動時連接”,在連接處,選擇“使用ISO映像文件”,瀏覽選擇本地電腦中下載好的ISO光盤鏡像文件,確定即可。
3. 執(zhí)行掛載命令
mount /dev/sr0 /mnt/cdrom
iso9660 是光盤的默認文件系統(tǒng)。?
由于linux系統(tǒng)可以自動識別光盤的文件系統(tǒng),故“-t iso9660”也可以省略不寫。
光盤的設(shè)備文件名是固定的,一般為/dev/cdrom或/dev/sr0。
掛載成功后,就可以通過掛載點讀取光盤里面的數(shù)據(jù)。
注意:操作完成之后,如果要取出光盤,必須解除掛載。
5. 解除掛載
不能在掛載點目錄下解除掛載,必須先切換到其他目錄(如用戶家目錄)。
5. 解除掛載
不能在掛載點目錄下解除掛載,必須先切換到其他目錄(如用戶家目錄)。
或者 umount /mnt/cdrom
我們iso光盤里面的所有二進制rpm包都在 iso光盤里面的Package目錄下面/mnt/cdrom/Packages
?
?rmp安裝存在樹形依賴,安裝a包,需要先安裝b包
樹形依賴的解決方案:安裝的時候同時安裝 abc
模塊依賴的解決方案,首先到網(wǎng)站查詢到該模塊對應的rpm包先安裝
模塊依賴一般都是以so.數(shù)字結(jié)尾,我們需要到上面的網(wǎng)站上找到對應的rpm包安裝就可以了
?
?
?
?
?rpm的安裝命令:
a、首先理解包名和包全名,在使用rpm安裝的時候要學會理解包名和包全名,
libreoffice-langpack-hr-4.0.4.2-9.el6.i686.rpm這就是包全名libreoffice就是包名
安裝和升級要使用包全面
查詢和刪除使用包名
這里需要重點強調(diào)的是千萬不要使用--nodeps,因為這回忽視依賴性的檢查,安裝a需要b才能使用,這里不安裝b就安裝a,a因為沒有安裝b是沒有辦法使用的
我們現(xiàn)在是人光盤里面的rpm安裝apache軟件
[root@weiyuan Packages]# rpm -ivh httpd- httpd-2.2.15-29.el6.centos.i686.rpm httpd-manual-2.2.15-29.el6.centos.noarch.rpm httpd-devel-2.2.15-29.el6.centos.i686.rpm httpd-tools-2.2.15-29.el6.centos.i686.rpm我們先安裝
httpd-manual-2.2.15-29.el6.centos.noarch.rpm?然后再安裝起來的幾個包,在安裝的過程中需要解決依賴性的問題,相當?shù)膹碗s,手工的安裝相當?shù)膹碗s,后面使用yum安裝來解決這個問題,沒有yum在線安裝,rpm安裝相當?shù)膹碗s
但是yum沒有查詢的查詢功能,只能收到使用rmp的查詢功能。rpm的安裝可以使用yum來解決。但是yum不能解決查詢等功能。
?
軟件的升級和卸載
注意升級軟件業(yè)必須使用包全名
?
?
[root@weiyuan Packages]# rpm -e httpd error: Failed dependencies:httpd >= 2.2.0 is needed by (installed) gnome-user-share-2.28.2-3.el6.i686 [root@weiyuan Packages]#?
卸載的時候報錯,首先卸載該軟件之前先要卸載?gnome-user-share-2.28.2-3.el6.i686這個軟件,所以rpm安裝和卸載的時候要解決rpm包依賴性的問題
?
?
?
?
[root@weiyuan Packages]# rpm -q httpd httpd-2.2.15-29.el6.centos.i686 [root@weiyuan Packages]# [root@weiyuan Packages]# rpm -qa | grep http httpd-tools-2.2.15-29.el6.centos.i686 httpd-2.2.15-29.el6.centos.i686 [root@weiyuan Packages]#?
在所有安裝的rpm查詢是否安裝了httpd
-qip是查詢未安裝包的信息,這個包沒有安裝到系統(tǒng)中
查詢rmp安裝文件的位置
[root@weiyuan Packages]# rpm -ql httpd?
?接下來我們重點學習yum在線安裝
在redhat中yum是需要給錢的,但是在centos中不需要給錢
我們首先來查看下yum源文件配置在那個地方
/etc/yum.repos.d
[root@weiyuan yum.repos.d]# ll -a 總用量 32 drwxr-xr-x. 2 root root 4096 2月 22 2013 . drwxr-xr-x. 117 root root 12288 5月 20 22:23 .. -rw-r--r--. 1 root root 1926 11月 27 2013 CentOS-Base.repo -rw-r--r--. 1 root root 638 11月 27 2013 CentOS-Debuginfo.repo -rw-r--r--. 1 root root 630 11月 27 2013 CentOS-Media.repo -rw-r--r--. 1 root root 3664 11月 27 2013 CentOS-Vault.repo [root@weiyuan yum.repos.d]#?
默認情況下生效的是?
CentOS-Base.repo這個文件我們來看看這個文件的內(nèi)容
# CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # #[base] name=CentOS-$releasever - Base mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6#released updates [updates] name=CentOS-$releasever - Updates mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6#additional packages that may be useful [extras] name=CentOS-$releasever - Extras mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6#additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6#contrib - mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os就是網(wǎng)絡(luò)yum的地址,這里可以替換成國內(nèi)清華大學或者163的地址
最關(guān)鍵的是enabled等于1的配置節(jié)點才有效果
上面如果上網(wǎng)就直接使用CentOS-Base.repo這個文件,但是在實驗室環(huán)境中無法上網(wǎng),我們只要上面的iso光盤,我們?nèi)绾问褂霉獗P配置本地yum了
第一步首先按照上面的步奏掛載
第二步讓上面的默認的
CentOS-Base.repo這個文件實效 [root@weiyuan yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak?
第三步:配置CentOS-Media.rep,讓其生效file指定當前光盤的掛載點路徑
配置enabled為1
注釋掉多余的file路徑否則會報錯
[root@weiyuan cdrom]# pwd /mnt/cdrom?
我們來看看具體的配置 [root@weiyuan yum.repos.d]# vim CentOS-Media.repo?
[c6-media] name=CentOS-$releasever - Media baseurl=file:///mnt/cdrom/ # file:///media/cdrom/ # file:///media/cdrecorder/ gpgcheck=1 enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6上面配置好了我們可以使用命令來查看yum是否安裝成功
[root@weiyuan yum.repos.d]# yum list?
接下來我們來分析?yum相關(guān)的命令[root@weiyuan yum.repos.d]# yum search httpd Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile ================================================================ N/S Matched: httpd ================================================================ httpd.i686 : Apache HTTP Server httpd-devel.i686 : Development interfaces for the Apache HTTP server httpd-manual.noarch : Documentation for the Apache HTTP server httpd-tools.i686 : Tools for use with the Apache HTTP Server mod_dav_svn.i686 : Apache httpd module for Subversion server mod_dnssd.i686 : An Apache HTTPD module which adds Zeroconf supportName and summary matches only, use "search all" for everything. [root@weiyuan yum.repos.d]#
注意:使用yum安裝只需要使用包名就可以了,不能使用包全名進行安裝
安裝
[root@weiyuan yum.repos.d]# yum -y install httpd-devel.i686 [root@weiyuan yum.repos.d]# yum -y install httpd.i686 [root@weiyuan yum.repos.d]# yum -y install gcc?
安裝yum之前需要確認下gcc軟件是否安裝成功,如果沒有安裝gcc,使用源代碼安裝就會失敗,gcc會對源代碼進行編譯[root@weiyuan yum.repos.d]# yum -y update
?
這條命令是升級系統(tǒng)的所有文件包括系統(tǒng)內(nèi)核,一定要慎用,會導致整個系統(tǒng)癱瘓?
[root@weiyuan yum.repos.d]# yum grouplist Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Group Process Loading mirror speeds from cached hostfile c6-media/group_gz | 212 kB 00:00 ... Installed Groups:Java 平臺NFS 文件服務器Perl 支持SNMP 支持X 窗口系統(tǒng)萬維網(wǎng)服務器互聯(lián)網(wǎng)應用程序互聯(lián)網(wǎng)瀏覽器辦公套件和生產(chǎn)率圖形管理工具基本字體安全性工具性能工具打印客戶端打印服務器撥號網(wǎng)絡(luò)支持服務器平臺桌面桌面平臺桌面調(diào)試和運行工具電子郵件服務器目錄客戶端硬件監(jiān)控工具繼承 UNIX 兼容性繼承 X Windows 系統(tǒng)的兼容性網(wǎng)絡(luò)基礎(chǔ)設(shè)施服務器網(wǎng)絡(luò)文件系統(tǒng)客戶端聯(lián)網(wǎng)工具調(diào)試工具輸入法通用桌面附加開發(fā) Installed Language Groups:不丹語支持 [dz]中文支持 [zh]烏爾都語支持 [ur]亞美尼亞語支持 [hy]伊努伊特語支持 [iu]印地語支持 [hi]敘利亞語支持 [or]古吉拉特語支持 [gu]古吉拉特語支持 [mr]坎納達語支持 [kn]埃塞俄比亞語支持 [am]塔吉克語支持 [tg]孟加拉語支持 [bn]希伯來語支持 [he]庫德語支持 [ku]康干語支持 [kok]文達語支持 [ve]新哈拉語支持 [si]旁遮普語支持 [pa]日語支持 [ja]格魯吉亞語支持 [ka]比哈爾語支持 [mai]泰盧固語支持 [te]泰米爾語支持 [ta]泰語支持 [th]緬甸語支持 [my]老撾語支持 [lo]阿拉伯語支持 [ar]阿薩姆語支持 [as]韓文支持 [ko]馬來語支持 [ml]高棉語支持 [km] Available Groups:?
這里使用grouplist 要安裝 中文支持 [zh]yum grouplistinstall 安裝中文支持后面只支持英語
不能寫成 yum grouplistinstall ?中文支持 [zh]
我們?nèi)绾谓鉀Q了,不要使用SecureCRT.exe 來執(zhí)行yum grouplist,直接在服務器里面運行 yum grouplist就可以了
?
這樣顯示的就是中文安裝了。
接下來重點講解下源碼包的安裝
?在講解源碼包安裝之前,我們在分析下rpm包和源碼包安裝的不同
源碼包安裝我們可以手動的指定安裝位置,rpm不需要指定安裝目錄,默認情況下安裝在上圖的目錄中,rpm也可以指定安裝位置,但是最好還是使用默認的安裝位置
rpm包使用默認的安裝路徑有啥好處了,我們可以按照標準的方式啟動服務,使用rpm我們可以按照默認標準的方式啟動服務
在linux操作系統(tǒng)中默認rpm安裝之后啟動服務的存在在/etc/rc.d/init.d這個文件夾下面
[root@weiyuan init.d]# ls abrt-ccpp blk-availability firstboot iptables messagebus ntpd rdisc rsyslog spice-vdagentd wpa_supplicant abrtd bluetooth functions irqbalance netconsole ntpdate restorecond sandbox sshd ypbind abrt-oops certmonger haldaemon kdump netfs oddjobd rngd saslauthd sssd acpid cpuspeed halt killall network portreserve rpcbind single sysstat atd crond htcacheclean lvm2-lvmetad NetworkManager postfix rpcgssd smartd udev-post auditd cups httpd lvm2-monitor nfs psacct rpcidmapd snmpd wdaemon autofs dnsmasq ip6tables mdmonitor nfslock quota_nld rpcsvcgssd snmptrapd winbind?
我們要啟動httpd服務我們就可以使用命令
第一種方式進入到/etc/rc.d/init.d目錄下執(zhí)行
[root@weiyuan init.d]# ./httpd start 正在啟動 httpd:httpd: Could not reliably determine the server's fully qualified domain name, using 183.221.250.11 for ServerName[確定]?
第二種方式:使用絕對路徑啟動
[root@weiyuan rc.d]# /etc/rc.d/init.d/httpd start 正在啟動 httpd:?
第三種方式還可以使用service命令啟動
[root@weiyuan rc.d]# service httpd start 正在啟動 httpd:?
?
?
service命令本質(zhì)上是搜索# /etc/rc.d/init.d/這個命令如果你修改了rpm包的默認安裝路徑,上面的命令也使用不了
?
?源碼包最好指定安裝目錄,一般是/usr/local目錄下,該目錄相當于windows下的project files目錄源碼包默認情況下是不能使用service命令來啟動,service默認查詢的是/etc/rc.d/init.d
而源碼包只能使用絕對路徑來啟動,例如httpd apache軟件
?
?如果源碼包想使用service命令啟動,我們只需要將上面的apachectl文件拷貝到目錄 /etc/rc.d/init.d,就可以使用serive命令啟動了接下來我們使用源碼包安裝httpd
安裝源碼包之前首先先安裝gcc,因為gcc要編譯源碼包
?
?安裝前準備
- 通過yum方式安裝gcc的編譯環(huán)境
-
下載httpd的源碼包
http://mirror.bit.edu.cn/apache/httpd
安裝過程
- Step1: 將源碼包上傳到linux服務器上(一般放到用戶目錄)
-
Step2:解壓軟件包
tar -zvxf http-2.2.32.tar.gz -
Step3: 進入已解壓的軟件包目錄
[root@VM_134_231_centos httpd-2.2.32] -
Step4: 查看軟件的安裝說明文件INSTALL?
- [weiyuan@weiyuan httpd-2.4.20]$ vim INSTALL
?
?
說明就說明了安裝的步奏[root@weiyuan httpd-2.4.20]# ./configure --prefix=/usr/local/apache2 checking for chosen layout... Apache checking for working mkdir -p... yes checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking build system type... i686-pc-linux-gnu checking host system type... i686-pc-linux-gnu checking target system type... i686-pc-linux-gnu configure: configure: Configuring Apache Portable Runtime library... configure: checking for APR... configure: WARNING: APR version 1.4.0 or later is required, found 1.3.9 configure: WARNING: skipped APR at apr-1-config, version not acceptable no configure: error: APR not found. Please read the documentation.
?
安裝 httpd-2.4.20報錯,說需要?WARNING: APR version 1.4.0 or later is required, found 1.3.9,如何解決 需要安裝按照向?qū)螺dapr-1.4.6.tar.gz,apr-util-1.5.1.tar.gz在/home/weiyuan/下載目錄下 [root@weiyuan 下載]# ls apr-1.6.3.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.20 httpd-2.4.20(1).tar.gz httpd-2.4.20.tar.gz nginx-1.10.2 nginx-1.10.2.tar.gz
?
接下來解壓我們下載的文件
[root@weiyuan 下載]# tar -zxvf apr-util-1.6.1.tar.gz [root@weiyuan 下載]# tar -zxvf apr-1.6.3.tar.gz [root@weiyuan 下載]# ll 總用量 18716 drwxr-xr-x. 27 1001 1001 4096 10月 18 2017 apr-1.6.3 -rw-rw-r--. 1 weiyuan weiyuan 1072661 5月 21 05:41 apr-1.6.3.tar.gz drwxr-xr-x. 20 1001 1001 4096 10月 18 2017 apr-util-1.6.1
?
解壓之后的目錄是存在版本號的,我們重新命名下,將版本號去掉[root@weiyuan 下載]# mv apr-1.6.3 apr [root@weiyuan 下載]# mv apr-util-1.6.1 apr-util
?
接下來將上面的文件夾復制到/home/weiyuan/下載/httpd-2.4.20/srclib目錄下
[root@weiyuan 下載]# cp -rf apr-util /home/weiyuan/下載/httpd-2.4.20/srclib/ [root@weiyuan 下載]# cp -rf apr /home/weiyuan/下載/httpd-2.4.20/srclib/
?
接下面進入到/home/weiyuan/下載/httpd-2.4.20,在重新執(zhí)行./configure命令
[root@weiyuan httpd-2.4.20]# ./configure --prefix=/usr/local/apache2 --with-included-apr
?
這樣就成功了接下來再執(zhí)行
[root@weiyuan httpd-2.4.20]# make [root@weiyuan httpd-2.4.20]# make install
?
這樣http源碼包就安裝成功了然后我們啟動apache
[root@weiyuan httpd-2.4.20]# /usr/local/apache2/bin/apachectl start AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 183.221.250.11. Set the 'ServerName' directive globally to suppress this message
這樣就表示虛擬機的apache就啟動成功了,默認apache的端口是80,一定要注意防火墻關(guān)閉,80端口可用。
? ?
轉(zhuǎn)載于:https://www.cnblogs.com/kebibuluan/p/9063489.html
總結(jié)
以上是生活随笔為你收集整理的linux软件安装管理的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: shell脚本:批量修改文件名(文件名中
- 下一篇: AOE网与关键路径简介