编译安装http2.4

仅以博客形式记录linux所学,不足之处继续优化

linux系统(centos)的软件安装一般分为2中,一是rpm包安装(yum,dnf都是基于rpm包),一是源码包编译安装。

实际应用场景中,源码包编译安装较为常用,因为它可以实现个性化,定制化,随你的需要定向安装到某个文件夹,启动或者禁用某些功能。

源码编译首先要安装编译工具gcc

yum install -y gcc

源码编译安装一般是三步

1,进入到源码包下一般都会有configure文件,即configure脚本,在运行时你可以指定安装位置、指定启用的特性

具体的可以看./configure --help

安装路径设定

--prefix=/PATH:指定默认安装位置,默认为/usr/local/
--sysconfdir=/PATH:配置文件安装位置

可选特性

--disable-FEATURE
--enable-FEATURE[=ARG]

依赖包

--with-PACKAGE[=ARG] 依赖包
--without-PACKAGE 禁用依赖关系

2,make  根据Makefile文件,构建应用程序

3,make install   复制文件到相应路径

centos7虚拟机测试

将httpd-2.4.25.tar.bz2上传到/data下

 解压

tar xvf httpd-2.4.25.tar.bz2

利用configure编译

[root@centos7 httpd-2.4.25]# ./configure --prefix=/apps/httpd2.4.25 
> --sysconfdir=/etc/httpd 
> --enable-ssl 
> --enable-so    #指定安装路径,配置文件路径,ssl证书
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-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure: 
configure: Configuring Apache Portable Runtime library...
configure: 
checking for APR... no
configure: error: APR not found.  Please read the documentation.  

上面提示APR未找到

一般这种问题就是缺少这个依赖包,这个依赖包的名字一般情况是apr-devel

yum install apr-devel

接下来如果还报类似的错误,重复上述操作。

上述./configure执行工需要安装4个依赖包

apr-devel
apr-util-devel
pcre-devel
openssl-devel

此时可以看到已经生成makefile文件

 接下来直接执行make && make install

因为是安装在/apps下的,启动软件/apps/httpd2.4.25/bin/httpd.就启动了软件

原文地址:https://www.cnblogs.com/qianyuezhan/p/13384879.html