ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

源码安装apache的详细步骤与解决方法

2022-07-14 13:00:35  阅读:222  来源: 互联网

标签:httpd src apr 步骤 make util 源码 usr apache


目录


httpd源码安装

先安装httpd需要的包

[root@YL apr-1.7.0]# yum -y install  gcc gcc-c++ 
  wget https://mirrors.aliyun.com/apache/apr/apr-1.7.0.tar.gz
  wget https://mirrors.aliyun.com/apache/apr/apr-util-1.6.1.tar.gz
  wget https://mirrors.aliyun.com/apache/httpd/httpd-2.4.54.tar.gz

解压进入此目录

tar xf apr-1.7.0.tar.gz
cd apr-1.7.0/

配置相关的选项,并生成Makefile

[root@YL apr-1.7.0]# ./configure --help|head
`configure' configures this package to adapt to many kinds of systems.

Usage: ./configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.

Defaults for the options are specified in brackets.

Configuration:

指定编译参数 指定apr的安装路径

[root@YL apr-1.7.0]# ./configure --prefix=/usr/local/apr
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

验证这一步命令是否成功, 非0的都不算成功

[root@YL apr-1.7.0]# echo $?
0

编译安装

[root@YL apr-1.7.0]# make 
make[1]: Entering directory '/usr/src/apr-1.7.0'
/bin/sh /usr/src/apr-1.7.0/libtool --silent --mode=compile gcc -g -O2 -pthread   -DHAVE_CONFIG_H  -DLINUX -D_REENTRANT -D_GNU_SOURCE   -I./include -I/usr/src/apr-1.7.0/include/arch/unix -I./include/arch/unix -I/usr/src/apr-1.7.0/include/arch/unix -I/usr/src/apr-1.7.0/include -I/usr/src/apr-1.7.0/include/private -I/usr/src/apr-1.7.0/include/private  -o encoding/apr_encode.lo -c encoding/apr_encode.c && touch encoding/apr_encode.lo

[root@YL apr-1.7.0]# make install
make[1]: Entering directory '/usr/src/apr-1.7.0'
make[1]: Nothing to be done for 'local-all'.
make[1]: Leaving directory '/usr/src/apr-1.7.0'
/usr/src/apr-1.7.0/build/mkdir.sh /usr/local/apr/lib /usr/local/apr/bin /usr/local/apr/build-1 \
	     /usr/local/apr/lib/pkgconfig /usr/local/apr/include/apr-1

进入到apr的目录下查看是否有lib库文件和include头部文件,如果有对其进行设置

[root@YL apr-1.7.0]# cd /usr/local/apr/
[root@YL apr]# ls
bin  build-1  include  lib

库文件的设置方法

[root@YL apr-1.7.0]# cat /etc/ld.so.conf.d/apr.conf 
/usr/local/apr/lib

头部文件的设置方法

ln -s /usr/local/apr/include/ /usr/include/apr  //(将安装目录下的include软连接到/usr/include下)

apr文件已经暂时编译完成
解压apr-util的包并进入其目录

[root@YL src]# tar xf apr-util-1.6.1.tar.gz 
[root@YL src]# cd apr-util-1.6.1/
[root@YL apr-util-1.6.1]# 

配置相关的选项,并生成Makefile

[root@YL apr-util-1.6.1]# ./configure --help|head
`configure' configures this package to adapt to many kinds of systems.

Usage: ./configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.

Defaults for the options are specified in brackets.

Configuration:

指定编译参数 --with必须加,因为apr-utilyi'lai

[root@YL apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
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

验证这一步命令是否成功, 非0的都不算成功

[root@YL apr-util-1.6.1]# echo $?
0

安装这个包

[root@YL apr-util-1.6.1]# yum -y install expat-devel

make编译

安装完这个包之后编译,编译完成

[root@YL apr-util-1.6.1]# make
make[1]: Entering directory '/usr/src/apr-util-1.6.1'
/bin/sh /usr/local/apr/build-1/libtool --silent --mode=compile gcc -g -O2 -pthread   -DHAVE_CONFIG_H  -DLINUX -D_REENTRANT -D_GNU_SOURCE   -I/usr/src/apr-util-1.6.1/include -I/usr/src/apr-util-1.6.1/include/private  -I/usr/local/apr/include/apr-1    -o xml/apr_xml.lo -c xml/apr_xml.c && touch xml/apr_xml.lo

编译安装

[root@YL apr-util-1.6.1]# make install
make[1]: Entering directory '/usr/src/apr-util-1.6.1'
make[1]: Nothing to be done for 'local-all'.
make[1]: Leaving directory '/usr/src/apr-util-1.6.1'
/usr/local/apr/build-1/mkdir.sh /usr/local/apr-util/include/apr-1 /usr/local/apr-util/lib/pkgconfig \
	     /usr/local/apr-util/lib /usr/local/apr-util/bin
for f in /usr/src/apr-util-1.6.1/include/*.h /usr/src/apr-util-1.6.1/include/*.h; do \
	/usr/bin/install -c -m 644 ${f} /usr/local/apr-util/include/apr-1; \

进入到此目录查找apr-util是否有库文件与头部文件

[root@YL apr-util-1.6.1]# cd /usr/local/apr-util/

库文件的解决方法

[root@YL apr-util-1.6.1]# vi /etc/ld.so.conf.d/apr-util.conf
[root@YL apr-util-1.6.1]# cat /etc/ld.so.conf.d/apr-util.conf
/usr/local/apr-util/lib
[root@YL apr-util-1.6.1]# ldconfig	//ldconfig让其生效

头部文件的解决方法

[root@YL apr-util-1.6.1]# ln -s /usr/local/apr-util/include/ /usr/include/apr-util

解压httpd压缩包并进入其目录

[root@YL src]# tar xf httpd-2.4.54.tar.gz 
[root@YL src]# cd httpd-2.4.54/
[root@YL httpd-2.4.54]# 

安装这个包

[root@YL httpd-2.4.54]# yum -y install pcre-devel

配置相关的选项,并生成Makefile

[root@YL httpd-2.4.54]# ./configure --help|head
`configure' configures this package to adapt to many kinds of systems.

Usage: ./configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.

Defaults for the options are specified in brackets.

Configuration:

进入apr-util的安装目录删除他,重新编译

[root@YL src]# rm -rf apr-util-1.6.1

编译完成后清理缓存

[root@YL httpd-2.4.54]# make clean

然后进行编译安装

[root@YL httpd-2.4.54]# make
Making all in srclib
make[1]: Entering directory '/usr/src/httpd-2.4.54/srclib'
make[1]: Leaving directory '/usr/src/httpd-2.4.54/srclib'
Making all in os
make[1]: Entering directory '/usr/src/httpd-2.4.54/os'
Making all in unix
[root@YL httpd-2.4.54]# make install
Making install in srclib
make[1]: Entering directory '/usr/src/httpd-2.4.54/srclib'
make[2]: Entering directory '/usr/src/httpd-2.4.54/srclib'
make[2]: Leaving directory '/usr/src/httpd-2.4.54/srclib'
make[1]: Leaving directory '/usr/src/httpd-2.4.54/srclib'
Making install in os
make[1]: Entering directory '/usr/src/httpd-2.4.54/os'
Making install in unix

进入到httpd的安装目录只有一个include头部文件,对其进行软链接

[root@YL httpd-2.4.54]# ln -s /usr/local/httpd/include/ /usr/include/httpd

网页访问apache

https://images.cnblogs.com/cnblogs_com/blogs/757984/galleries/2181430/o_220713043404_QQ%E5%9B%BE%E7%89%8720220713112547.png

访问apache

[root@YL httpd-2.4.54]# curl YL
<html><body><h1>It works!</h1></body></html>

错误解决方法

第一次编译apr-util是的错误

xml/apr_xml.c:35:10: fatal error: expat.h: No such file or directory
 #include <expat.h>
          ^~~~~~~~~
compilation terminated.
make[1]: *** [/usr/src/apr-util-1.6.1/build/rules.mk:206: xml/apr_xml.lo] Error 1
make[1]: Leaving directory '/usr/src/apr-util-1.6.1'
make: *** [/usr/src/apr-util-1.6.1/build/rules.mk:118: all-recursive] Error 1

apr-util解决方法

[root@YL apr-util-1.6.1]# yum -y install expat-devel

第一次编译httpd是的错误

[root@YL httpd-2.4.54]# ./configure --prefix=/usr/local/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
.......
configure: error: pcre(2)-config for libpcre not found. PCRE is required and available from http://pcre.org/

解决方法

[root@YL httpd-2.4.54]# yum -y install pcre-devel

安装软件包后编译 此时编译还是会报错

[root@YL httpd-2.4.54]# make
Making all in srclib
make[1]: Entering directory '/usr/src/httpd-2.4.54/srclib'
make[1]: Leaving directory '/usr/src/httpd-2.4.54/srclib'
Making all in os
make[1]: Entering directory '/usr/src/httpd-2.4.54/os'

此时需要进入到apr-util的安装包删除掉他,重新进行编译,编译完成后清理缓存make clean 再次make make|install 安装,进行头部文件解决
然后进行编译安装

[root@YL httpd-2.4.54]# make
Making all in srclib
make[1]: Entering directory '/usr/src/httpd-2.4.54/srclib'
make[1]: Leaving directory '/usr/src/httpd-2.4.54/srclib'
Making all in os
make[1]: Entering directory '/usr/src/httpd-2.4.54/os'
Making all in unix
[root@YL httpd-2.4.54]# make install
Making install in srclib
make[1]: Entering directory '/usr/src/httpd-2.4.54/srclib'
make[2]: Entering directory '/usr/src/httpd-2.4.54/srclib'
make[2]: Leaving directory '/usr/src/httpd-2.4.54/srclib'
make[1]: Leaving directory '/usr/src/httpd-2.4.54/srclib'
Making install in os
make[1]: Entering directory '/usr/src/httpd-2.4.54/os'
Making install in unix
[root@YL httpd-2.4.54]# ln -s /usr/local/httpd/include/ /usr/include/httpd

编译完成:curl 主机名访问 ip进行网页访问

标签:httpd,src,apr,步骤,make,util,源码,usr,apache
来源: https://www.cnblogs.com/TQingS/p/16477309.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有