Linux安裝及管理程序精講

博文目錄

成都創(chuàng)新互聯(lián)公司專業(yè)為企業(yè)提供睢寧縣網(wǎng)站建設、睢寧縣做網(wǎng)站、睢寧縣網(wǎng)站設計、睢寧縣網(wǎng)站制作等企業(yè)網(wǎng)站建設、網(wǎng)頁設計與制作、睢寧縣企業(yè)網(wǎng)站模板建站服務,十多年睢寧縣做網(wǎng)站經(jīng)驗,不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡服務。

一、RPM包管理工具

二、安裝、升級和卸載RPM軟件

三、Linux應用程序基礎

四、源代碼編譯安裝

一、RPM包管理工具

RPM Pachage Manager由Red Hat公司提出,被眾多Linux發(fā)行版所采用。建立統(tǒng)一的數(shù)據(jù)庫文件,詳細記錄軟件包安裝、卸載等變化信息,能夠自動分析軟件包依賴關系。RPM軟件包一般命名格式如下:
Linux安裝及管理程序精講

1、查詢已安裝的RPM軟件信息

查詢已安裝的RPM軟件包語法格式如下:
Linux安裝及管理程序精講

應用舉例:

[root@centos01 ~]# rpm -qa  <!--查詢所有已安裝的rpm軟件信息-->
python2-pyasn1-modules-0.1.9-7.el7.noarch
mesa-libEGL-17.0.1-6.20170307.el7.x86_64
xcb-util-0.4.0-2.el7.x86_64
python-pyblock-0.53-6.el7.x86_64
sysstat-10.1.5-12.el7.x86_64
sos-3.4-6.el7.centos.noarch
xorg-x11-server-Xorg-1.19.3-11.el7.x86_64
libiscsi-1.9.0-7.el7.x86_64
sssd-ldap-1.15.2-50.el7.x86_64
postfix-2.10.1-6.el7.x86_64
…………<!--此處省略部分內(nèi)容-->
[root@centos01 ~]# rpm -q bash    <!--查詢已安裝的bash軟件包-->
bash-4.2.46-28.el7.x86_64
[root@centos01 ~]# rpm -qi bash    <!--查詢bash軟件包的詳細信息-->
Name        : bash
Version     : 4.2.46
Release     : 28.el7
Architecture: x86_64
Install Date: 2019年10月23日 星期三 22時29分35秒
Group       : System Environment/Shells
Size        : 3663637
License     : GPLv3+
Signature   : RSA/SHA256, 2017年08月10日 星期四 23時03分40秒, Key ID 24c6a8a7f4a80eb5
Source RPM  : bash-4.2.46-28.el7.src.rpm
Build Date  : 2017年08月03日 星期四 05時13分21秒
Build Host  : c1bm.rdu2.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Vendor      : CentOS
URL         : http://www.gnu.org/software/bash
Summary     : The GNU Bourne Again shell
Description :
The GNU Bourne Again shell (Bash) is a shell or command language
interpreter that is compatible with the Bourne shell (sh). Bash
incorporates useful features from the Korn shell (ksh) and the C shell
(csh). Most sh scripts can be run by bash without modification.
[root@centos01 ~]# rpm -qa | grep bash
bash-4.2.46-28.el7.x86_64
bash-completion-2.1-6.el7.noarch
[root@centos01 ~]# rpm -ql openssh <!--查看openssh在系統(tǒng)中安裝的所有目錄-->
/etc/ssh
/etc/ssh/moduli
/usr/bin/ssh-keygen
/usr/libexec/openssh
/usr/libexec/openssh/ctr-cavstest
/usr/libexec/openssh/ssh-keysign
/usr/share/doc/openssh-7.4p1
/usr/share/doc/openssh-7.4p1/CREDITS
…………<!--此處省略部分內(nèi)容-->

2、查詢文件或目錄屬于哪個RPM軟件

語法格式如下:
Linux安裝及管理程序精講

應用舉例:

[root@centos01 ~]# rpm -qf /usr/bin/vim   <!--查詢vim是由哪個軟件包安裝的-->
vim-enhanced-7.4.160-2.el7.x86_64
[root@centos01 ~]# rpm -qf /usr/libexec/openssh/  <!--查看配置文件是哪個程序使用-->
openssh-7.4p1-11.el7.x86_64

3、查詢未安裝的RPM包文件

查詢未安裝的RPM軟件包語法格式如下:
Linux安裝及管理程序精講

應用舉例:

[root@centos01 ~]# rpm -qpi /mnt/Packages/httpd-2.4.6
-67.el7.centos.x86_64.rpm    
            <!--查看httpd的rpm包詳細信息-->
Name        : httpd
Version     : 2.4.6
Release     : 67.el7.centos
Architecture: x86_64
Install Date: (not installed)
Group       : System Environment/Daemons
Size        : 9823661
License     : ASL 2.0
Signature   : RSA/SHA256, 2017年08月11日 星期五 00時40分32秒, Key ID 24c6a8a7f4a80eb5
Source RPM  : httpd-2.4.6-67.el7.centos.src.rpm
Build Date  : 2017年08月04日 星期五 11時21分07秒
Build Host  : c1bm.rdu2.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Vendor      : CentOS
URL         : http://httpd.apache.org/
Summary     : Apache HTTP Server
Description :
The Apache HTTP Server is a powerful, efficient, and extensible
web server.
[root@centos01 ~]# rpm -qpl /mnt/Packages/httpd-2.4.6
-67.el7.centos.x86_64.rpm    
          <!--查看httpd的rpm包安裝包含的目錄-->
/etc/httpd
/etc/httpd/conf
/etc/httpd/conf.d
/etc/httpd/conf.d/README
/etc/httpd/conf.d/autoindex.conf
/etc/httpd/conf.d/userdir.conf
/etc/httpd/conf.d/welcome.conf
/etc/httpd/conf.modules.d
/etc/httpd/conf.modules.d/00-base.conf
/etc/httpd/conf.modules.d/00-dav.conf
/etc/httpd/conf.modules.d/00-lua.conf
/etc/httpd/conf.modules.d/00-mpm.conf
/etc/httpd/conf.modules.d/00-proxy.conf
/etc/httpd/conf.modules.d/00-systemd.conf
/etc/httpd/conf.modules.d/01-cgi.conf
/etc/httpd/conf/httpd.conf
/etc/httpd/conf/magic
/etc/httpd/logs
/etc/httpd/modules
/etc/httpd/run
…………   <!--此處省略部分內(nèi)容-->
[root@centos01 ~]# rpm -qpc /mnt/Packages/httpd-2.4.6
-67.el7.centos.x86_64.rpm    
                <!--查看httpd安裝后的配置文件-->
/etc/httpd/conf.d/autoindex.conf
/etc/httpd/conf.d/userdir.conf
/etc/httpd/conf.d/welcome.conf
/etc/httpd/conf.modules.d/00-base.conf
/etc/httpd/conf.modules.d/00-dav.conf
/etc/httpd/conf.modules.d/00-lua.conf
/etc/httpd/conf.modules.d/00-mpm.conf
/etc/httpd/conf.modules.d/00-proxy.conf
/etc/httpd/conf.modules.d/00-systemd.conf
/etc/httpd/conf.modules.d/01-cgi.conf
/etc/httpd/conf/httpd.conf
/etc/httpd/conf/magic
/etc/logrotate.d/httpd
/etc/sysconfig/htcacheclean
/etc/sysconfig/httpd

二、安裝、升級和卸載RPM軟件

安裝、升級和卸載RPM軟件的語法格式及常用選項如下:
Linux安裝及管理程序精講

1、安裝RPM軟件

[root@centos01 ~]# rpm -ivh /mnt/Packages/ntsysv-1.7.4
-1.el7.x86_64.rpm    <!--安裝ntsysv程序-->
警告:/mnt/Packages/ntsysv-1.7.4-1.el7.x86_64.rpm: 頭V3 RSA/SHA256 Signature, 密鑰 ID f4a80eb5: NOKEY
準備中...                          ################################# [100%]
    軟件包 ntsysv-1.7.4-1.el7.x86_64 已經(jīng)安裝

結尾加“--force”選項是強制安裝所指定的rpm軟件包。

2、升級RPM軟件

[root@centos01 ~]# rpm -U /mnt/Packages/ntsysv-1.7.4-1.el7.x86_64.rpm
警告:/mnt/Packages/ntsysv-1.7.4-1.el7.x86_64.rpm: 頭V3 RSA/SHA256 Signature, 密鑰 ID f4a80eb5: NOKEY
    軟件包 ntsysv-1.7.4-1.el7.x86_64 已經(jīng)安裝

3、卸載RPM軟件

卸載rpm軟件包的語法格式及輔助選項如下:
Linux安裝及管理程序精講

應用舉例:

[root@centos01 ~]# rpm -e ntsysv    <!--卸載ntsysv程序-->
[root@centos01 ~]# rpm -ivh /mnt/Packages/system-config
-kickstart-2.9.6-1.el7.noarch.rpm --nodeps   
              <!--結合“--nodeps”選項忽略依賴關系-->
警告:/mnt/Packages/system-config-kickstart-2.9.6-1.el7.noarch.rpm: 頭V3 RSA/SHA256 Signature, 密鑰 ID f4a80eb5: NOKEY
準備中...                          ################################# [100%]
正在升級/安裝...
   1:system-config-kickstart-2.9.6-1.e################################# [100%]

4、維護RPM數(shù)據(jù)庫

[root@centos01 ~]# rpm --initdb
<!--或者-->
[root@centos01 ~]# rpm --rebuilddb

5、導入驗證公鑰

[root@centos01 ~]# cd /mnt/
[root@centos01 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@centos01 mnt]# rpm --import ./RPM-GPG-KEY-CentOS-7          <!--導入驗證公鑰-->

[root@centos01 ~]# rpm -ivh /mnt/Packages/dhcp-4.2.5
-58.el7.centos.x86_64.rpm    
              <!--再次安裝rpm包不再顯示密鑰-->
準備中...                          ################################# [100%]
正在升級/安裝...
   1:dhcp-12:4.2.5-58.el7.centos      ################################# [100%]

6、解決軟件包依賴關系

Linux安裝及管理程序精講

三、Linux應用程序基礎

1、應用程序與系統(tǒng)命令的關系

1)文件位置

  • 系統(tǒng)命令:一般在/bin和/sbin目錄中,或為Shell內(nèi)部指令。

  • 應用程序:通常在/usr/bin和/usr/sbin目錄中。

2)主要用途

  • 系統(tǒng)命令:完成對系統(tǒng)的基本管理工作,例如IP配置工具。

  • 應用程序:完成相對獨立的其他輔助任務,例如網(wǎng)頁瀏覽器。

3)適用環(huán)境

  • 系統(tǒng)命令:一般只在字符操作界面中運行。

  • 應用程序:根據(jù)實際需要,有些程序可在圖形界面中運行。

4)運行格式

  • 系統(tǒng)命令:一般包括命令字、命令選項和命令參數(shù)。

  • 應用程序:通常沒有固定的執(zhí)行格式。

2、典型應用程序的目錄結構

Linux安裝及管理程序精講

3、常見的軟件包封裝類型

Linux安裝及管理程序精講

四、源代碼編譯安裝

1、源代碼編譯概述

1)使用源代碼安裝軟件的優(yōu)點

獲得最新的軟件版本,及時修復bug;根據(jù)用戶需要,靈活定制軟件功能。

2)應用源代碼編譯安裝場合舉例

安裝較新版本的應用程序時使用;當前安裝的程序無法滿足需要時使用;需要為應用程序添加新的功能時使用等等。

2、編譯安裝源代碼包

1)Tarball包

.tar.gz和.tar.bz2格式居多。軟件素材參考:http://sourceforge.net

2)完整性校驗

計算MD5校驗和,并與官方提供的值相比較,判斷是否一致。如下:

[root@centos01 ~]# md5sum /mnt/Packages/tomcat-7.0.76-2.el7.noarch.rpm
3c901508f0651c5c3207f999fbf395ed  /mnt/Packages/tomcat-7.0.76-2.el7.noarch.rpm

3)確認源代碼編譯環(huán)境

需要安裝支持C/C++程序語言的編譯器,如下所示:

[root@centos01 ~]# rpm -qa | grep gcc  <!--查看是否安裝gcc和gcc-c++-->
libgcc-4.8.5-16.el7.x86_64
gcc-c++-4.8.5-16.el7.x86_64
gcc-4.8.5-16.el7.x86_64
gcc-gfortran-4.8.5-16.el7.x86_64
[root@centos01 ~]# rpm -qa | grep make   <!--查看是否安裝make-->
make-3.82-23.el7.x86_64
automake-1.13.4-3.el7.noarch

4、編譯安裝過程

Linux安裝及管理程序精講

5、編譯安裝步驟

1)tar解包

通常情況下習慣性將軟件包釋放到/usr/src/目錄,解包后的源代碼文件位置/usr/src/軟件名-版本號/。應用舉例:

[root@centos01 ~]# tar zxvf /mnt/httpd-2.2.17.tar.gz -C /usr/src/

2)./configure配置

使用源碼目錄中的configure腳本;執(zhí)行“./configure --help”可查看幫助;典型的配置選項:--prefix=軟件安裝目錄。應用舉例:

[root@centos01 ~]# cd /usr/src/httpd-2.2.17/
[root@centos01 httpd-2.2.17]# ./configure --prefix=/usr/local/httpd

不指定任何配置選項,則采用默認值。

3)編譯

[root@centos01 httpd-2.2.17]# make 

4)安裝

[root@centos01 httpd-2.2.17]#make install

注意:編譯和安裝可以一起執(zhí)行,中間結合&&即可一次性執(zhí)行兩條命令。

5)優(yōu)化程序目錄

[root@centos01 ~]# ln -s /usr/local/httpd/bin/* /usr/local/bin/

6)創(chuàng)建系統(tǒng)服務,添加執(zhí)行權限

[root@centos01 ~]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
[root@centos01 ~]# chmod +x /etc/init.d/httpd

7)修改系統(tǒng)服務

[root@centos01 ~]# vim /etc/init.d/httpd 
#!/bin/sh
#chkconfig:35 80 20
............<!--此處省略部分內(nèi)容-->

8)添加為系統(tǒng)服務,設置開機自動啟動

[root@centos01 ~]# chkconfig --add httpd
[root@centos01 ~]# chkconfig --level 35 httpd on

9)啟動apache服務

[root@centos01 ~]# systemctl start httpd

10)監(jiān)聽apache服務的端口號

[root@centos01 ~]# netstat -anptu | grep 80
tcp6       0      0 :::80                   :::*                    LISTEN      53115/httpd         

———————— 本文至此結束,感謝閱讀 ————————

當前標題:Linux安裝及管理程序精講
瀏覽地址:http://www.muchs.cn/article2/ghosoc.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設計企業(yè)網(wǎng)站制作、用戶體驗、網(wǎng)站策劃、微信公眾號、手機網(wǎng)站建設

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站制作