zoukankan      html  css  js  c++  java
  • linux软件安装管理

    Linux软件安装管理

    TonyLinux系统工程师
    难度初级 
    时长 3小时 6分 
    学习人数64016 
    综合评分9.8
     

     

    上面是linux 的源代码安装包

    linux有两种类型的软件安装方式:

    1、源代码安装

      这种方式的软件安装,可以指定软件的安装目录,软件的运行效率高,如何是大规模的并发,安装apache软件最好使用源代码包安装,使用源代码包安装软件卸载方便,直接删除软件安装目录就可以了

    2、rpm安装包

    rmp是源代码经过编译之后的安装包,安装方式简单,便于新手安装,winddows操作系统上的.exe文件就是经过源代码编译之后对应的二进制安装包,优点是安装简单,只需要简单的命令

    就可以使用软件的安装升级和查询,ubuntu对应的二进制安装包对应的后缀是deb文件

    rmp有一个很大的区别,就是软件安装存在依赖性,这个依赖性可以使用yum安装进行解决。

    接下来我们来学习rpm的常用操作,首先给光盘创建一个挂载点 


    Linux系统中挂载和使用光盘的基本步骤

    Last login: Fri May 18 04:14:39 2018 from 192.168.1.4
    [weiyuan@weiyuan ~]$ su 
    密码:
    [root@weiyuan weiyuan]# mkdir /mnt/cdrom
    [root@weiyuan weiyuan]# mount /dev/sr0 /mnt/cdrom
    mount: block device /dev/sr0 is write-protected, mounting read-only
    [root@weiyuan weiyuan]# cd /mnt/cdrom

    1. 创建挂载点

    mkdir /mnt/cdrom

    2. 打开光驱,放入光盘

    如果用的是VMware中的虚拟机,进入虚拟机设置,选择“CD/DVD”硬件,勾选“已连接”和“启动时连接”,在连接处,选择“使用ISO映像文件”,浏览选择本地电脑中下载好的ISO光盘镜像文件,确定即可。

    3. 执行挂载命令

    mount /dev/sr0 /mnt/cdrom

    iso9660 是光盘的默认文件系统。 
    由于linux系统可以自动识别光盘的文件系统,故“-t iso9660”也可以省略不写。

    光盘的设备文件名是固定的,一般为/dev/cdrom或/dev/sr0。

    挂载成功后,就可以通过挂载点读取光盘里面的数据。

    注意:操作完成之后,如果要取出光盘,必须解除挂载。

    5. 解除挂载

    不能在挂载点目录下解除挂载,必须先切换到其他目录(如用户家目录)。

    5. 解除挂载

    不能在挂载点目录下解除挂载,必须先切换到其他目录(如用户家目录)。

    或者 umount /mnt/cdrom

    我们iso光盘里面的所有二进制rpm包都在 iso光盘里面的Package目录下面/mnt/cdrom/Packages

     rmp安装存在树形依赖,安装a包,需要先安装b包

    树形依赖的解决方案:安装的时候同时安装 abc

    模块依赖的解决方案,首先到网站查询到该模块对应的rpm包先安装

    模块依赖一般都是以so.数字结尾,我们需要到上面的网站上找到对应的rpm包安装就可以了

     

     rpm的安装命令:

    a、首先理解包名和包全名,在使用rpm安装的时候要学会理解包名和包全名,

    libreoffice-langpack-hr-4.0.4.2-9.el6.i686.rpm这就是包全名libreoffice就是包名

    安装和升级要使用包全面

    查询和删除使用包名

    这里需要重点强调的是千万不要使用--nodeps,因为这回忽视依赖性的检查,安装a需要b才能使用,这里不安装b就安装a,a因为没有安装b是没有办法使用的

    我们现在是人光盘里面的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  
    

     然后再安装起来的几个包,在安装的过程中需要解决依赖性的问题,相当的复杂,手工的安装相当的复杂,后面使用yum安装来解决这个问题,没有yum在线安装,rpm安装相当的复杂

    但是yum没有查询的查询功能,只能收到使用rmp的查询功能。rpm的安装可以使用yum来解决。但是yum不能解决查询等功能。

    软件的升级和卸载

    注意升级软件业必须使用包全名

    [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是查询未安装包的信息,这个包没有安装到系统中

    查询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这个文件
    我们来看看这个文件的内容
    # 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就是网络yum的地址,这里可以替换成国内清华大学或者163的地址
    最关键的是enabled等于1的配置节点才有效果
    上面如果上网就直接使用CentOS-Base.repo这个文件,但是在实验室环境中无法上网,我们只要上面的iso光盘,我们如何使用光盘配置本地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相关的命令
    [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 support
    
      Name 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
    这条命令是升级系统的所有文件包括系统内核,一定要慎用,会导致整个系统瘫痪
    [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 窗口系统
       万维网服务器
       互联网应用程序
       互联网浏览器
       办公套件和生产率
       图形管理工具
       基本
       字体
       安全性工具
       性能工具
       打印客户端
       打印服务器
       拨号网络支持
       服务器平台
       桌面
       桌面平台
       桌面调试和运行工具
       电子邮件服务器
       目录客户端
       硬件监控工具
       继承 UNIX 兼容性
       继承 X Windows 系统的兼容性
       网络基础设施服务器
       网络文件系统客户端
       联网工具
       调试工具
       输入法
       通用桌面
       附加开发
    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]

    我们如何解决了,不要使用SecureCRT.exe 来执行yum grouplist,直接在服务器里面运行
    yum grouplist就可以了

    这样显示的就是中文安装了。

    接下来重点讲解下源码包的安装

     在讲解源码包安装之前,我们在分析下rpm包和源码包安装的不同

    源码包安装我们可以手动的指定安装位置,rpm不需要指定安装目录,默认情况下安装在上图的目录中,rpm也可以指定安装位置,但是最好还是使用默认的安装位置

    rpm包使用默认的安装路径有啥好处了,我们可以按照标准的方式启动服务,使用rpm我们可以按照默认标准的方式启动服务

    在linux操作系统中默认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目录下执行

    [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命令本质上是搜索# /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的编译环境
    • 下载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 
     For complete installation documentation, see [ht]docs/manual/install.html or
      http://httpd.apache.org/docs/2.4/install.html
    
         $ ./configure --prefix=PREFIX
         $ make
         $ make install
         $ PREFIX/bin/apachectl start
    说明就说明了安装的步奏
    [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,如何解决
    需要安装按照向导下载apr-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,在重新执行./configure命令
    [root@weiyuan httpd-2.4.20]# ./configure  --prefix=/usr/local/apache2  --with-included-apr
    这样就成功了
    接下来再执行
    [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,一定要注意防火墙关闭,80端口可用。


     
     
     
  • 相关阅读:
    HTML
    数据挖掘之分类——基于规则的分类器
    Ubuntu 14.04下Hadoop2.4.1集群安装配置教程
    Jdk1.7+eclipse搭建Java开发环境
    约瑟夫环问题
    Linux 绝对路径与相对路径
    排序算法汇总
    朋友圈问题
    HTTP状态码
    哈希冲突,哈希函数
  • 原文地址:https://www.cnblogs.com/kebibuluan/p/9063489.html
Copyright © 2011-2022 走看看