源码安装软件

本文详细记录了在Linux环境中源码安装Apache的过程中遇到的错误,如APR库未找到和C编译器无法创建可执行文件的问题。通过安装apr、apr-devel、apr-util-devel以及gcc和gcc-c++来解决这些问题。最终成功编译并安装Apache。

源码安装软件

源码安装软件需要执行4步。
分别是:解压,配置(预编译),编译,安装。

解压

这里以httpd包为例子

[root@l ~]# tar zxf httpd-2.4.48.tar.gz

配置(预编译)

编译前需要进入解压之后的软件包

[root@l ~]# cd httpd-2.4.48

进行配置

[root@l httpd-2.4.48]# ./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.

此时出现了报错(出现error或者library及表示报错)

现在按照报错的提示进行下一步

此时需要安装apr

[root@l httpd-2.4.48]# yum list all | grep apr
apr.x86_64                              1.4.8-3.el7_4.1                centos7  
apr-devel.x86_64                        1.4.8-3.el7_4.1                centos7  
apr-util.x86_64                         1.5.2-6.el7                    centos7  
apr-util-devel.x86_64                   1.5.2-6.el7                    centos7  
haproxy.x86_64                          1.5.18-7.el7                   centos7

安装apr、apr-devel、apr-util-devel,一般来说后缀名带devel的为开发包。

[root@l httpd-2.4.48]# yum -y install apr apr-devel apr-util apr-util-devel pcre pcre-devel

在配置一下

[root@l httpd-2.4.48]# ./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... yes
  setting CC to "gcc"
  setting CPP to "gcc -E"
  setting CFLAGS to "  -pthread"
  setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE"
  setting LDFLAGS to " "
configure: 
configure: Configuring Apache Portable Runtime Utility library...
configure: 
checking for APR-util... yes
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/root/httpd-2.4.48':
configure: error: C compiler cannot create executables
See `config.log' for more details

此时又显示报错。

再来解决报错

此时报错显示缺少编译工具,现在安装编译工具。

[root@l httpd-2.4.48]# yum -y install gcc gcc-c++

在进行编译,直到不出现报错为止。

编译

此时直接输入make命令即可。

[root@l httpd-2.4.48]# make

编译完成之后查看一下是否编译成功。

[root@l httpd-2.4.48]# echo $?
0

显示编译成功。

安装

直接运行命令即可。

[root@l httpd-2.4.48]# make install

此时源码安装软件包完成。

评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值