源码安装软件
源码安装软件需要执行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
此时源码安装软件包完成。