当前位置: 首页 > article >正文

Linux(Centos 7.6)软件包安装

 Linux软件安装,常见的有三种方式,rpm方式yum方式源码编译安装方式。其中rpm方式可能存在依赖方式,可能会比较麻烦;源码编译安装同样可能会缺少一些编译需要的软件需要安装,也会比较麻烦;相对比较好的方式是yum方式,只要源仓库软件包齐全,安装时,缺少的依赖,会自动进行安装,简单方便。推荐使用yum方式

注:除以上三种方式外,也有其他的一些安装方式,比如有一些应用软件,解压安装包后,里面可能有install的shell脚本或者python脚本,执行这些脚本进行安装。

1.rpm方式安装

1.1.rpm软件包下载上传

1.双击iso文件,使用DVD驱动器加载iso文件,Packages目录下找httpd的软件包。

注:也可以去网络上找对应Linux系统版本的rpm包

2.左上角的搜索框,填写httpd-搜索,找到httpd-后紧接版本号的文件,鼠标选中推出到本地。

3.通过SFTP协议工具(如Xftp)上传httpd软件包,上传到Downloads目录。

[root@localhost ~]# cd Downloads/
[root@localhost Downloads]# ll
total 2780
-rw-r--r--. 1 root root 2844028 Dec 24 16:18 httpd-2.4.6-88.el7.centos.x86_64.rpm
[root@localhost Downloads]# 

 1.2.rpm方式安装软件包

1.rpm方式安装软件包,可能会出现如下情况,错误信息提示:Failed dependencies(错误的依赖),代表安装httpd需要提前安装httpd-tools、libapr-1.so.0相关的软件包、libaprutil-1.so.0相关软件包。

注:这里需要注意,httpd-tools是明确直到缺少什么软件包,可以去镜像或者网络上下载;但是下面两个提示有一些是无法确认具体缺什么,只能找apr相关的软件包,安装后再安装httpd服务,软件包的查找、下载、上传、安装、确认等步骤都很麻烦。像这类软件依赖多的情况,建议使用yum方式安装。

[root@localhost Downloads]# rpm -ivh httpd-2.4.6-88.el7.centos.x86_64.rpm 
error: Failed dependencies:
	/etc/mime.types is needed by httpd-2.4.6-88.el7.centos.x86_64
	httpd-tools = 2.4.6-88.el7.centos is needed by httpd-2.4.6-88.el7.centos.x86_64
	libapr-1.so.0()(64bit) is needed by httpd-2.4.6-88.el7.centos.x86_64
	libaprutil-1.so.0()(64bit) is needed by httpd-2.4.6-88.el7.centos.x86_64

2.部分简单的软件是可以直接使用rpm方式安装的;如free软件包,上传free软件包,直接使用rpm -ivh 软件包文件的名称即可安装,提示already installed即安装完成。

rpm -ivh中,i代表install(安装),v代表verbose(详细信息),h代表hash(打印散列标记)

[root@localhost Downloads]# ll
total 2828
-rw-r--r--. 1 root root 2844028 Dec 24 16:18 httpd-2.4.6-88.el7.centos.x86_64.rpm
-rw-r--r--. 1 root root   47508 Dec 24 16:39 tree-1.6.0-10.el7.x86_64.rpm
[root@localhost Downloads]# rpm -ivh tree-1.6.0-10.el7.x86_64.rpm 
Preparing...                          ################################# [100%]
	package tree-1.6.0-10.el7.x86_64 is already installed
[root@localhost Downloads]# rpm -qa | grep tree
tree-1.6.0-10.el7.x86_64
[root@localhost Downloads]# 

2.yum方式安装

2.1.yum源配置

yum详细的配置步骤见Linux(Centos 7.6)yum源配置

2.2.yum源方式安装软件包

yum方式安装,直接执行yum install 软件包名称(不是文件名称,不带版本号);安装过程可以看到具体还需要安装哪些依赖的软件包(依赖软件包包括apr、apr-util、httpd-tools、mailcap),最后看到Complete!提示即安装完成。

[root@localhost Downloads]# yum install httpd
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-99.el7.centos.1 will be installed
--> Processing Dependency: httpd-tools = 2.4.6-99.el7.centos.1 for package: httpd-2.4.6-99.el7.centos.1.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-99.el7.centos.1.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-99.el7.centos.1.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-99.el7.centos.1.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-7.el7 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7_9.1 will be installed
---> Package httpd-tools.x86_64 0:2.4.6-99.el7.centos.1 will be installed
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================
 Package                  Arch                Version                               Repository            Size
===============================================================================================================
Installing:
 httpd                    x86_64              2.4.6-99.el7.centos.1                 updates              2.7 M
Installing for dependencies:
 apr                      x86_64              1.4.8-7.el7                           base                 104 k
 apr-util                 x86_64              1.5.2-6.el7_9.1                       updates               92 k
 httpd-tools              x86_64              2.4.6-99.el7.centos.1                 updates               94 k
 mailcap                  noarch              2.1.41-2.el7                          base                  31 k

Transaction Summary
===============================================================================================================
Install  1 Package (+4 Dependent packages)

Total download size: 3.0 M
Installed size: 10 M
Is this ok [y/d/N]: y
Downloading packages:
(1/5): apr-util-1.5.2-6.el7_9.1.x86_64.rpm                                              |  92 kB  00:00:04     
(2/5): apr-1.4.8-7.el7.x86_64.rpm                                                       | 104 kB  00:00:04     
(3/5): httpd-tools-2.4.6-99.el7.centos.1.x86_64.rpm                                     |  94 kB  00:00:00     
(4/5): httpd-2.4.6-99.el7.centos.1.x86_64.rpm                                           | 2.7 MB  00:00:06     
(5/5): mailcap-2.1.41-2.el7.noarch.rpm                                                  |  31 kB  00:00:04     
---------------------------------------------------------------------------------------------------------------
Total                                                                          311 kB/s | 3.0 MB  00:00:09     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : apr-1.4.8-7.el7.x86_64                                                                      1/5 
  Installing : apr-util-1.5.2-6.el7_9.1.x86_64                                                             2/5 
  Installing : httpd-tools-2.4.6-99.el7.centos.1.x86_64                                                    3/5 
  Installing : mailcap-2.1.41-2.el7.noarch                                                                 4/5 
  Installing : httpd-2.4.6-99.el7.centos.1.x86_64                                                          5/5 
  Verifying  : httpd-2.4.6-99.el7.centos.1.x86_64                                                          1/5 
  Verifying  : mailcap-2.1.41-2.el7.noarch                                                                 2/5 
  Verifying  : apr-1.4.8-7.el7.x86_64                                                                      3/5 
  Verifying  : httpd-tools-2.4.6-99.el7.centos.1.x86_64                                                    4/5 
  Verifying  : apr-util-1.5.2-6.el7_9.1.x86_64                                                             5/5 

Installed:
  httpd.x86_64 0:2.4.6-99.el7.centos.1                                                                         

Dependency Installed:
  apr.x86_64 0:1.4.8-7.el7       apr-util.x86_64 0:1.5.2-6.el7_9.1  httpd-tools.x86_64 0:2.4.6-99.el7.centos.1 
  mailcap.noarch 0:2.1.41-2.el7 

Complete!
[root@localhost Downloads]# rpm -qa | grep httpd
httpd-2.4.6-99.el7.centos.1.x86_64
httpd-tools-2.4.6-99.el7.centos.1.x86_64

3.源码编译安装

3.1.httpd软件卸载

注:以下卸载方法,谨慎卸载ssh相关的软件包,卸载ssh相关的软件包可能导致远程ssh不能访问,然后必须去机房服务器上去恢复ssh服务(很麻烦)。

1.httpd软件包卸载可以使用rpm -e 软件包名称-e代表erase(擦除软件)。

[root@localhost Downloads]# rpm -e httpd
[root@localhost Downloads]# rpm -qa | grep httpd
httpd-tools-2.4.6-99.el7.centos.1.x86_64
[root@localhost Downloads]# 

2.httpd软件包卸载也可以使用yum remove 软件包名称

[root@localhost Downloads]# yum remove httpd
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-99.el7.centos.1 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================
 Package              Arch                  Version                              Repository               Size
===============================================================================================================
Removing:
 httpd                x86_64                2.4.6-99.el7.centos.1                @updates                9.4 M

Transaction Summary
===============================================================================================================
Remove  1 Package

Installed size: 9.4 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : httpd-2.4.6-99.el7.centos.1.x86_64                                                          1/1 
  Verifying  : httpd-2.4.6-99.el7.centos.1.x86_64                                                          1/1 

Removed:
  httpd.x86_64 0:2.4.6-99.el7.centos.1                                                                         

Complete!
[root@localhost Downloads]# rpm -qa | grep httpd
httpd-tools-2.4.6-99.el7.centos.1.x86_64
[root@localhost Downloads]# 

3.2.httpd源码下载

1.下载地址:Index of /httpd,双击软件包名称进行下载。

2.如果linux(Centos 7.6)可以连接外网,可以直接使用wget进行下载。 

[root@localhost Downloads]# wget https://dlcdn.apache.org/httpd/httpd-2.4.62.tar.gz
--2024-12-24 16:52:14--  https://dlcdn.apache.org/httpd/httpd-2.4.62.tar.gz
Resolving dlcdn.apache.org (dlcdn.apache.org)... 151.101.2.132, 2a04:4e42::644
Connecting to dlcdn.apache.org (dlcdn.apache.org)|151.101.2.132|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9872432 (9.4M) [application/x-gzip]
Saving to: ‘httpd-2.4.62.tar.gz’

100%[=====================================================================>] 9,872,432    971KB/s   in 11s    

2024-12-24 16:52:30 (898 KB/s) - ‘httpd-2.4.62.tar.gz’ saved [9872432/9872432]

[root@localhost Downloads]# ll httpd-2.4.62.tar.gz 
-rw-r--r--. 1 root root 9872432 Jul 18 01:48 httpd-2.4.62.tar.gz

3.3.httpd源码安装

3.3.1.解压安装包

tar.gz后缀的压缩包代表gzip压缩格式的压缩包,解压命令为targzip压缩方式对应解压参数是zx代表解压v代表详细信息f后跟压缩文件。解压后可以看到httpd-2.4.62的目录。

[root@localhost Downloads]# tar -zxvf httpd-2.4.62.tar.gz 
httpd-2.4.62/
httpd-2.4.62/acinclude.m4
httpd-2.4.62/README.cmake
httpd-2.4.62/INSTALL
httpd-2.4.62/CMakeLists.txt
httpd-2.4.62/LICENSE
... ...
[root@localhost Downloads]# ll
total 12476
drwxr-xr-x. 13  501 games    4096 Jul 15 20:12 httpd-2.4.62
-rw-r--r--.  1 root root  9872432 Jul 18 01:48 httpd-2.4.62.tar.gz
-rw-r--r--.  1 root root  2844028 Dec 24 16:18 httpd-2.4.6-88.el7.centos.x86_64.rpm
-rw-r--r--.  1 root root    47508 Dec 24 16:39 tree-1.6.0-10.el7.x86_64.rpm
[root@localhost Downloads]# 

3.3.2.源码安装

3.3.2.1.安装说明

进入解压目录,查看INSTALL文件,即可了解如何进行软件的编译、安装、启动服务。

./configure --prefix=PREFIX:是配置检查,执行该脚本主要是检查环境是否符合要求,也可以定义一些功能,如--prefix=PREFIX部分可以写为--prefix=/usr/local/httpd,以此定义httpd服务安装在/usr/lical/httpd目录。

[root@localhost Downloads]# cd httpd-2.4.62/
[root@localhost httpd-2.4.62]#
[root@localhost httpd-2.4.62]# cat INSTALL 

  APACHE INSTALLATION OVERVIEW

  Quick Start - Unix
  ------------------

  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
... ...
3.3.2.2.源码编译安装前检查

1.创建安装目录,执行编译安装前检查命令。

[root@localhost httpd-2.4.62]# mkdir /usr/local/httpd
[root@localhost httpd-2.4.62]# 
[root@localhost httpd-2.4.62]# ./configure --prefix=/usr/local/httpd
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure: 
configure: Configuring Apache Portable Runtime library...
configure: 
checking for APR... no
configure: error: APR not found.  Please read the documentation.
[root@localhost httpd-2.4.62]# rpm -qa | grep apr
apr-util-1.5.2-6.el7_9.1.x86_64
apr-1.4.8-7.el7.x86_64

2.检查报错,提示APR没发现,但是apr相关的已经安装,处理方式是下载apr源码文件到httpd源码目录。

下载地址:Download - The Apache Portable Runtime Project,网站内查看,鼠标右键查看下载链接,然后wget下载或者下载后上传Linux服务器。

[root@localhost httpd-2.4.62]# cd ..
[root@localhost Downloads]# wget https://dlcdn.apache.org//apr/apr-1.7.5.tar.gz
--2024-12-24 17:34:46--  https://dlcdn.apache.org//apr/apr-1.7.5.tar.gz
Resolving dlcdn.apache.org (dlcdn.apache.org)... 151.101.2.132, 2a04:4e42::644
Connecting to dlcdn.apache.org (dlcdn.apache.org)|151.101.2.132|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1131871 (1.1M) [application/x-gzip]
Saving to: ‘apr-1.7.5.tar.gz’

100%[=====================================================================>] 1,131,871    725KB/s   in 1.5s   

2024-12-24 17:34:53 (725 KB/s) - ‘apr-1.7.5.tar.gz’ saved [1131871/1131871]

[root@localhost Downloads]# wget https://dlcdn.apache.org//apr/apr-util-1.6.3.tar.gz
--2024-12-24 17:35:02--  https://dlcdn.apache.org//apr/apr-util-1.6.3.tar.gz
Resolving dlcdn.apache.org (dlcdn.apache.org)... 151.101.2.132, 2a04:4e42::644
Connecting to dlcdn.apache.org (dlcdn.apache.org)|151.101.2.132|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 556623 (544K) [application/x-gzip]
Saving to: ‘apr-util-1.6.3.tar.gz’

100%[=====================================================================>] 556,623      224KB/s   in 2.4s   

2024-12-24 17:35:10 (224 KB/s) - ‘apr-util-1.6.3.tar.gz’ saved [556623/556623]

[root@localhost Downloads]#

解压安装包,修改解压后的目录名称(去掉版本号信息),最后移动到http源码的srclib目录下。 

[root@localhost Downloads]# tar -zxf apr-1.7.5.tar.gz 
[root@localhost Downloads]# tar -zxf apr-util-1.6.3.tar.gz  
[root@localhost Downloads]# mv apr-1.7.5 apr
[root@localhost Downloads]# mv apr-util-1.6.3 apr-util
[root@localhost Downloads]# mv apr httpd-2.4.62/srclib/
[root@localhost Downloads]# mv apr-util httpd-2.4.62/srclib/

3.再次源码编译安装前检查。提示缺少pcre,查看有pcre,还需要pcre-devel,yum安装pcre-devel。 

[root@localhost httpd-2.4.62]# ./configure --prefix=/usr/local/httpd --with-include-apr
... ...
configure: error: pcre(2)-config for libpcre not found. PCRE is required and available from http://pcre.org/
[root@localhost httpd-2.4.62]# 
[root@localhost httpd-2.4.62]# rpm -qa | grep pcre
pcre2-utf16-10.23-2.el7.x86_64
pcre2-10.23-2.el7.x86_64
pcre-8.32-17.el7.x86_64
[root@localhost httpd-2.4.62]# yum install pcre-devel
... ...
Installed:
  pcre-devel.x86_64 0:8.32-17.el7                                                                              

Complete!
[root@localhost httpd-2.4.62]#

4.再次源码编译安装前检查,最后信息如下,没有报错信息,表示成功。

[root@localhost httpd-2.4.62]# ./configure --prefix=/usr/local/httpd --with-include-apr
... ...
config.status: executing default commands
configure: summary of build options:

    Server Version: 2.4.62
    Install prefix: /usr/local/httpd
    C compiler:     gcc -std=gnu11
    CFLAGS:          -g -O2 -pthread  
    CPPFLAGS:        -DLINUX -D_REENTRANT -D_GNU_SOURCE  
    LDFLAGS:           
    LIBS:             
    C preprocessor: gcc -std=gnu11 -E

[root@localhost httpd-2.4.62]#
3.3.2.3.make编译

1.httpd-2.4.62目录下执行make进行编译。

[root@localhost httpd-2.4.62]# make
... ...
xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory
 #include <expat.h>
                   ^
compilation terminated.
make[3]: *** [xml/apr_xml.lo] Error 1
make[3]: Leaving directory `/root/Downloads/httpd-2.4.62/srclib/apr-util'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/root/Downloads/httpd-2.4.62/srclib/apr-util'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/Downloads/httpd-2.4.62/srclib'
make: *** [all-recursive] Error 1
[root@localhost httpd-2.4.62]# 

2.提示在 #include <expat.h>右下角的箭头,检查发现有expat,还需要expat-devel,使用yum安装。

[root@localhost httpd-2.4.62]# rpm -qa | grep expat
expat-2.1.0-10.el7_3.x86_64
[root@localhost httpd-2.4.62]# yum install expat-devel
... ...
Installed:
  expat-devel.x86_64 0:2.1.0-15.el7_9                                                                          

Dependency Updated:
  expat.x86_64 0:2.1.0-15.el7_9                                                                                

Complete!
[root@localhost httpd-2.4.62]#

3.再次执行make编译,执行最后信息如下,没有报错信息,则表示成功。

[root@localhost httpd-2.4.62]# make
... ...
/root/Downloads/httpd-2.4.62/srclib/apr/libtool --silent --mode=link gcc -std=gnu11  -g -O2 -pthread           -o mod_rewrite.la -rpath /usr/local/httpd/modules -module -avoid-version  mod_rewrite.lo 
make[4]: Leaving directory `/root/Downloads/httpd-2.4.62/modules/mappers'
make[3]: Leaving directory `/root/Downloads/httpd-2.4.62/modules/mappers'
make[2]: Leaving directory `/root/Downloads/httpd-2.4.62/modules'
make[2]: Entering directory `/root/Downloads/httpd-2.4.62/support'
make[2]: Leaving directory `/root/Downloads/httpd-2.4.62/support'

make[1]: Leaving directory `/root/Downloads/httpd-2.4.62'
[root@localhost httpd-2.4.62]# 
3.3.2.4.make install编译安装
[root@localhost httpd-2.4.62]# make install
... ...
Installing man pages and online manual
mkdir /usr/local/httpd/man
mkdir /usr/local/httpd/man/man1
mkdir /usr/local/httpd/man/man8
mkdir /usr/local/httpd/manual
make[1]: Leaving directory `/root/Downloads/httpd-2.4.62'
[root@localhost httpd-2.4.62]# 

3.3.3.服务和验证

1.服务启动

[root@localhost httpd-2.4.62]# /usr/local/httpd/bin/apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
[root@localhost httpd-2.4.62]# 
[root@localhost httpd-2.4.62]# hostnamectl set-hostname node2
[root@localhost httpd-2.4.62]# 
[root@localhost httpd-2.4.62]# /usr/local/httpd/bin/apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::6d79:37d0:2840:d17f%ens33. Set the 'ServerName' directive globally to suppress this message
httpd (pid 119463) already running
[root@localhost httpd-2.4.62]# 

2.服务启动验证,网页访问IP地址信息如下

如果无法访问,检查防火墙是否关闭,关闭命令systemctl stop firewalld.service。


http://www.kler.cn/a/458320.html

相关文章:

  • YOLOv9-0.1部分代码阅读笔记-train.py
  • 微信小程序:定义页面标题,动态设置页面标题,json
  • springboot 整合 rabbitMQ (延迟队列)
  • 典型常见的基于知识蒸馏的目标检测方法总结三
  • github提交不上去,网络超时问题解决
  • 加密流量TLS1.2 和TLS1.3的握手区别
  • NodeRed使用心得,实现增删改查等
  • 电商项目高级篇07-redisson分布式锁
  • 排序算法之快速排序、归并排序
  • java全栈day21--Web后端实战之利用Mybaits查询数据
  • pd虚拟机 [po] Parallels Desktop 20 激活 for Mac [jie] 安装教程【支持M芯片】
  • 鸿蒙TCPSocket通信模拟智能家居模拟案例
  • 勤工助学系统|Java|SSM|VUE| 前后端分离
  • springboot510基于Springboot+vue线上教育培训办公系统(论文+源码)_kaic
  • JSON的运用与总结
  • 【Python科研数据爬虫】基于国家标准查询平台和能源标准化信息平台的海上风电相关行业标准查询信息爬取及处理
  • STM32-笔记16-定时器中断点灯
  • overleaf中出现TeX capacity exceeded PDF object stream buffer=5000000的原因和解决方案
  • pandas df 如何 输出数据到 sqlite3
  • Android studio-SDK无法安装的问题
  • LeetCode:3083. 字符串及其反转中是否存在同一子字符串(哈希 Java)
  • VM虚拟机配置ubuntu网络
  • 机器人C++开源库The Robotics Library (RL)使用手册(三)
  • 小程序配置文件 —— 16 项目配置文件和配置 sass
  • 拉取docker run hello-world失败
  • 【每日学点鸿蒙知识】渐变效果、Web组件注册对象报错、深拷贝list、loadContent数据共享、半屏弹窗