系统平台 包类型 工具 在线安装(自动解决依赖关系) 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