系統平臺 包類型 工具 在線安裝(自動解決依賴關係) RedHat/Centos/Fedora RPM rpm,rpmbuild yum Ubuntu/Debian DPKG dpkg apt
注意: 無論是源碼包,仍是二進制包,安裝時均可能會有依賴關係!!!php
一、得到RPM包途徑:node
notecase-1.9.8-1.fc6.i386.rpm 套件名 ntfs-3g-2010.3.6-1.el5.i386.rpm 套件名 stardict-langdao-ec-gb-2.4.2-1.noarch.rpm 套件名 軟件包名 版本號 發佈次數 平臺 notecase 1.9.8 1.fc6 i386(系統平臺i386 x86_64 noarch ) ntfs-3g 2010.3.6 1.el5 i386 //version: 版本 //release: 發佈版本 # uname -m //查看當前系統是多少位 x86_64 # cat /etc/issue CentOS release 6.5 (Final) Kernel \r on an \m # cat /etc/redhat-release CentOS release 6.5 (Final)
二、使用rpm工具管理rpm包 (警告:須要手動解決包的依賴關係)mysql
安裝linux
# rpm -ivh stardict-langdao-ec-gb-2.4.2-1.noarch.rpm 套件名 # rpm -ivh ntfs-3g-2010.3.6-1.el5.i386.rpm 套件名 額外選項: --force //強制安裝,通常適用於某個包文件損壞或丟失 --nodeps //忽略依賴關係,不建議使用
查詢 (從本地的rpm數據庫)nginx
# rpm -q ntfs-3g //查詢指定包是否安裝 # rpm -qa |grep ntfs # rpm -ql ntfs-3g //查詢ntfs-3g安裝的文件 # rpm -qf /usr/bin/ntfs-3g //查詢該文件屬於哪一個rpm包 # rpm -qi ntfs-3g //查詢包的information # rpm -e ntfs-3g # rpm -qi ntfs-3g package ntfs-3g is not installed # rpm -qc ntfs-3g # rpm -q vsftpd vsftpd-2.0.5-24.el5 # rpm -qc vsftpd //查詢某個包安裝的配置文件 /etc/logrotate.d/vsftpd.log /etc/pam.d/vsftpd /etc/vsftpd/ftpusers /etc/vsftpd/user_list /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd_conf_migrate.sh # rpm -qd vsftpd //查安裝的幫助文檔
擴展知識: 針對沒有安裝的包,直接從套件中查詢sql
# rpm -qip vagrant_2.1.1_x86_64.rpm # rpm -qcp vagrant_2.1.1_x86_64.rpm # rpm -qdp vagrant_2.1.1_x86_64.rpm # rpm -qlp vagrant_2.1.1_x86_64.rpm
卸載數據庫
# rpm -e vagrant # rpm -e vagrant --nodeps
rpm工具管理軟件包總結:apache
三、使用YUM工具管理RPM包 (自動解決包的依賴關係) YUM倉庫中必須包括:vim
第一種狀況:使用系統光盤安裝rpm軟件 1. 自己存在yum數據庫,不須要生成 2. YUM指定數據庫位置 [root@yangs ~]# df 文件系統 1K-塊 已用 可用 已用% 掛載點 /dev/hdc 3435526 3435526 0 100% /media/cd /media/cd/Server /media/cd/VT /media/cd/Cluster /media/cd/ClusterStorage [root@station230 ~]# cd /etc/yum.repos.d/ [root@station230 yum.repos.d]# vim rhel5.repo //文件名自定義,必須以.repo結尾 [Server] //倉庫ID name=Server //倉庫名 baseurl=file:///media/cd/Server //倉庫位置 enabled=1 //啓用倉庫 gpgcheck=0 //不檢查軟件包的簽名
檢查目前可用的倉庫緩存
# yum clean all //清空緩存 # yum repolist //查詢可用的倉庫
安裝
# yum install mysql-server # yum install nginx # yum -y install mysql-server # yum -y install php # rpm -e php # yum -y remove mysql-server # yum -y install "mysql*" httpd vsftpd samba dovecot # yum -y update samba
查詢
# yum list httpd mysql-server vsftpd tftp-server bind Installed Packages httpd.i386 2.2.3-63.el5 installed mysql-server.i386 5.0.77-4.el5_6.6 installed tftp-server.i386 0.49-2 installed vsftpd.i386 2.0.5-24.el5 installed Available Packages bind.i386 30:9.3.6-20.P1.el5 Server
卸載
# yum -y remove mysql-server
查詢某個文件(一般是當前系統中沒有)由哪一個rpm包提供
示例1: # gnuplot bash: gnuplot: command not found //沒有找到該命令 # yum provides gnuplot Loaded plugins: katello, product-id, security, subscription-manager Updating certificate-based repositories. Unable to read consumer identity gnuplot-4.0.0-14.el5.i386 : 繪製數學表達式和數據的程序。 Repo : Server Matched from: # yum -y install gnuplot # gnuplot 示例2: # rpm -e httpd # htpasswd //沒有找到該命令 bash: htpasswd: command not found # yum provides */htpasswd Loaded plugins: katello, product-id, security, subscription-manager Updating certificate-based repositories. Unable to read consumer identity Server/filelists | 2.4 MB 00:03 httpd-2.2.3-63.el5.i386 : Apache HTTP 服務器 Repo : Server Matched from: Filename : /usr/bin/htpasswd # yum -y install httpd-2.2.3-63.el5.i386 # htpasswd 示例3: # createrepo bash: createrepo: command not found # yum provides createrepo Loaded plugins: katello, product-id, security, subscription-manager Updating certificate-based repositories. Unable to read consumer identity createrepo-0.4.11-3.el5.noarch : 生成一個通用元數據庫 Repo : Server Matched from: # yum -y install createrepo
指定光盤上其餘軟件包倉庫
# yum -y install gfs-utils
軟件包組管理
# yum grouplist //查詢當前軟件包組的安裝狀況 # yum -y groupinstall "DNS 名稱服務器" //安裝軟件包組 做業: 查詢並安裝 「開發工具」 「開發庫」 軟件包組
第二種狀況:第三方rpm軟件包(例以下載的rpm軟件包) 1. 生成yum數據庫 //createrepo軟件包 2. 指定數據庫位置 3. yum安裝軟件包 ==準備倉庫(軟件包 和 數據庫文件) [root@station230 soft]# yum -y install createrepo [root@yangs newsoft]# pwd /newsoft [root@yangs newsoft]# ls ntfs-3g-2011.4.12-5.el5.i386.rpm [root@yangs newsoft]# createrepo . //在當前目錄生成yum數據庫文件 1/1 - ntfs-3g-2011.4.12-5.el5.i386.rpm Saving Primary metadata Saving file lists metadata Saving other metadata [root@yangs newsoft]# ls ntfs-3g-2011.4.12-5.el5.i386.rpm repodata ==給YUM指定倉庫 [root@yangs ~]# cd /etc/yum.repos.d/ [root@yangs yum.repos.d]# cat newsoft.repo [newsoft] name=newsoft baseurl=file:///newsoft enabled=1 gpgcheck=0 ==安裝 [root@yangs ~]# yum clean all [root@yangs ~]# yum repolist Loaded plugins: katello, product-id, security, subscription-manager Updating certificate-based repositories. Unable to read consumer identity repo id repo name status ClusterStorage ClusterStorage 39 Server Server 2,472 newsoft newsoft 1 repolist: 2,512 [root@yangs ftp]# yum -y install ntfs-3g 擴展知識: 若是有新rpm包加到入/newsoft倉庫 [root@yangs ftp]# cp notecase-1.9.8-1.fc6.i386.rpm /newsoft/ [root@yangs ftp]# cd /newsoft/ [root@yangs newsoft]# createrepo . 2/2 - ntfs-3g-2011.4.12-5.el5.i386.rpm Saving Primary metadata Saving file lists metadata Saving other metadata =================支持RPM簽名檢查========================= ==RPM工具使用簽名機制:== # rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release 導入紅帽公鑰 # rpm -ivh tftp-server-0.49-2.i386.rpm Preparing... ########################################### [100%] 1:tftp-server ########################################### [100%] ==YUM使用簽名機制:== 方法一: # rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release 導入紅帽公鑰 [root@station230 yum.repos.d] vim rhel-debuginfo.repo [Server] name=Server baseurl=file:///media/Server enabled=1 gpgcheck=1 //是否檢查軟件包的簽名 方法二: [root@station230 yum.repos.d] vim rhel-debuginfo.repo [Server] name=Server baseurl=file:///media/Server enabled=1 gpgcheck=1 //是否檢查軟件包的簽名 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release 指定公鑰文件 =====================================================================
得到源碼包途徑
準備工做
安裝httpd
# rpm -q httpd //查詢 # service httpd stop //中止httpd服務 # rpm -e httpd --nodeps //卸載 yum -y remove httpd # tar xvf httpd-2.2.11.tar.bz2 //解壓 # cd httpd-2.2.11
三步曲:
# ./configure --prefix=/usr/local/apache2 a. 指定安裝路徑,例如--prefix=DIR b. 啓用或禁用某項功能, 例如 --enable-ssl, --disable-filter c. 和其它軟件關聯,例如--with-ssl=DIR d. 檢查安裝環境,例如是否有編譯器gcc,是否知足軟件的依賴需求 最終生成:Makefile # make clean //清理掉之前編譯後產生的 *.o目標文件 # make //按Makefile文件編譯 # make install //安裝
驗證安裝結果:
[root@yangs ~]# ls /usr/local/apache2/ bin build cgi-bin conf error htdocs icons include lib logs man manual modules [root@yangs ~]# ls /usr/local/apache2/bin/ ab apu-1-config dbmmanage htcacheclean htpasswd logresolve apachectl apxs envvars htdbm httpd rotatelogs apr-1-config checkgid envvars-std htdigest httxt2dbm [root@yangs ~]# /usr/local/apache2/bin/apachectl start //啓動
其它的二進制軟件 bin格式軟件包:jdk-6u27-linux-i586.bin
[root@station230 software]# chmod a+x jdk-6u27-linux-i586.bin [root@station230 software]# ./jdk-6u27-linux-i586.bin