Apache2.4源码安装与配置

环境准备

openssl-devel
pcre-devel
expat-devel
libtool
gcc
libxml2-devel
这些包要提前安装,否则httpd编译安装时候会报错

下载源码、解压缩、软连接

1、wget下载[root@node01 ~]# wget https://downloads.apache.org/httpd/httpd-2.4.57.tar.gz
--2023-07-20 12:49:02--  https://downloads.apache.org/httpd/httpd-2.4.57.tar.gz
Resolving downloads.apache.org (downloads.apache.org)... 135.181.214.104, 88.99.95.219, 2a01:4f9:3a:2c57::2, ...
Connecting to downloads.apache.org (downloads.apache.org)|135.181.214.104|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9773385 (9.3M) [application/x-gzip]
Saving to: ‘httpd-2.4.57.tar.gz’100%[===========================================================>] 9,773,385   3.50MB/s   in 2.7s   2023-07-20 12:49:05 (3.50 MB/s) - ‘httpd-2.4.57.tar.gz’ saved [9773385/9773385]2、解压缩
[root@node01 ~]# tar -zxf httpd-2.4.57.tar.gz -C /usr/local/cluster/3、软连接
[root@node01 ~]# ln -s /usr/local/cluster/httpd-2.4.57/ /usr/local/cluster/httpd

编译安装需要两个依赖包

[root@node01 ~]# wget https://downloads.apache.org/apr/apr-1.7.4.tar.gz
--2023-07-20 16:43:32--  https://downloads.apache.org/apr/apr-1.7.4.tar.gz
Resolving downloads.apache.org (downloads.apache.org)... 88.99.95.219, 135.181.214.104, 2a01:4f9:3a:2c57::2, ...
Connecting to downloads.apache.org (downloads.apache.org)|88.99.95.219|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1122147 (1.1M) [application/x-gzip]
Saving to: ‘apr-1.7.4.tar.gz’100%[===========================================================>] 1,122,147    933KB/s   in 1.2s   2023-07-20 16:43:34 (933 KB/s) - ‘apr-1.7.4.tar.gz’ saved [1122147/1122147][root@node01 ~]# wget https://downloads.apache.org/apr/apr-util-1.6.3.tar.gz
--2023-07-20 16:45:01--  https://downloads.apache.org/apr/apr-util-1.6.3.tar.gz
Resolving downloads.apache.org (downloads.apache.org)... 88.99.95.219, 135.181.214.104, 2a01:4f8:10a:201a::2, ...
Connecting to downloads.apache.org (downloads.apache.org)|88.99.95.219|: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      476KB/s   in 1.1s   2023-07-20 16:45:03 (476 KB/s) - ‘apr-util-1.6.3.tar.gz’ saved [556623/556623][root@node01 ~]# ll -h apr*
-rw-r--r-- 1 root root 1.1M Apr 16 21:07 apr-1.7.4.tar.gz
-rw-r--r-- 1 root root 544K Feb  2 03:06 apr-util-1.6.3.tar.gz

编译安装apr

[root@node01 ~]# tar -zxf apr-1.7.4.tar.gz -C /usr/local/cluster/
[root@node01 ~]# ln -s /usr/local/cluster/apr-1.7.4/ /usr/local/cluster/apr
[root@node01 ~]# cd /usr/local/cluster/apr添加#注释
[root@node01 apr]# vim configure
#    $RM "$cfgfile"[root@node01 apr]# ./configure --prefix=/usr/local/apr
。。。
configure: creating ./config.status
config.status: creating Makefile
config.status: creating include/apr.h
config.status: creating build/apr_rules.mk
config.status: creating build/pkg/pkginfo
config.status: creating apr-1-config
config.status: creating apr.pc
config.status: creating test/Makefile
config.status: creating test/internal/Makefile
config.status: creating include/arch/unix/apr_private.h
config.status: executing libtool commands
config.status: executing default commands
config.status: include/apr.h is unchanged
config.status: include/arch/unix/apr_private.h is unchanged[root@node01 apr]# make && make install
。。。
----------------------------------------------------------------------
/usr/bin/install -c -m 644 apr.exp /usr/local/apr/lib/apr.exp
/usr/bin/install -c -m 644 apr.pc /usr/local/apr/lib/pkgconfig/apr-1.pc
for f in libtool shlibtool; do \if test -f ${f}; then /usr/bin/install -c -m 755 ${f} /usr/local/apr/build-1; fi; \
done
/usr/bin/install -c -m 755 /usr/local/cluster/apr/build/mkdir.sh /usr/local/apr/build-1
for f in make_exports.awk make_var_export.awk; do \/usr/bin/install -c -m 644 /usr/local/cluster/apr/build/${f} /usr/local/apr/build-1; \
done
/usr/bin/install -c -m 644 build/apr_rules.out /usr/local/apr/build-1/apr_rules.mk
/usr/bin/install -c -m 755 apr-config.out /usr/local/apr/bin/apr-1-config

编译安装apr-util

[root@node01 ~]# tar -zxf apr-util-1.6.3.tar.gz -C /usr/local/cluster/
[root@node01 ~]# ln -s /usr/local/cluster/apr-util-1.6.3/ /usr/local/cluster/apr-util
[root@node01 ~]# cd /usr/local/cluster/apr-util[root@node01 apr-util]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
。。。
configure: creating ./config.status
config.status: creating Makefile
config.status: creating export_vars.sh
config.status: creating build/pkg/pkginfo
config.status: creating apr-util.pc
config.status: creating apu-1-config
config.status: creating include/private/apu_select_dbm.h
config.status: creating include/apr_ldap.h
config.status: creating include/apu.h
config.status: creating include/apu_want.h
config.status: creating test/Makefile
config.status: creating include/private/apu_config.h
config.status: executing default commands[root@node01 apr-util]# make && make install报错提示需要安装expat
xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory#include <expat.h>^
compilation terminated.
make[1]: *** [xml/apr_xml.lo] Error 1
make[1]: Leaving directory `/usr/local/cluster/apr-util-1.6.3'
make: *** [all-recursive] Error 1[root@node01 apr-util]# yum install expat-devel -y再次执行
[root@node01 apr-util]# make && make installSee any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
/usr/bin/install -c -m 644 aprutil.exp /usr/local/apr-util/lib
/usr/bin/install -c -m 755 apu-config.out /usr/local/apr-util/bin/apu-1-config

编译安装httpd

因为没有提前安装依赖包,需要重新编译安装apr和apr-util,最后再重新编译安装httpd[root@node01 ~]# tar -zxf httpd-2.4.57.tar.gz -C /usr/local/cluster/
[root@node01 ~]# ln -s /usr/local/cluster/httpd-2.4.57/ /usr/local/cluster/httpd
[root@node01 ~]# cd /usr/local/cluster/httpd[root@node01 httpd]# ./configure --prefix=/usr/local/httpd --enable-so --enable-ssl --enable-cgi --enable--rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most  --enable-mpms-shared=all --with-mpm=prefork报错需要pcre包
checking for pcre-config... no
configure: error: pcre(2)-config for libpcre not found. PCRE is required and available from http://pcre.org/[root@node01 httpd]# yum install pcre-devel -y再次执行checking for OpenSSL version >= 0.9.8a... FAILED
configure: WARNING: OpenSSL version is too old
no
checking whether to enable mod_ssl... configure: error: mod_ssl has been requested but can not be built due to prerequisite failures[root@node01 httpd]# yum list openssl*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile* base: mirrors.aliyun.com* extras: mirrors.tuna.tsinghua.edu.cn* updates: mirrors.aliyun.com
Installed Packages
openssl.x86_64                               1:1.0.2k-19.el7                                @anaconda
openssl-libs.x86_64                          1:1.0.2k-19.el7                                @anaconda
Available Packages
openssl.x86_64                               1:1.0.2k-26.el7_9                              updates  
openssl-devel.i686                           1:1.0.2k-26.el7_9                              updates  
openssl-devel.x86_64                         1:1.0.2k-26.el7_9                              updates  
openssl-libs.i686                            1:1.0.2k-26.el7_9                              updates  
openssl-libs.x86_64                          1:1.0.2k-26.el7_9                              updates  
openssl-perl.x86_64                          1:1.0.2k-26.el7_9                              updates  
openssl-static.i686                          1:1.0.2k-26.el7_9                              updates  
openssl-static.x86_64                        1:1.0.2k-26.el7_9                              updates  
openssl098e.i686                             0.9.8e-29.el7.centos.3                         base     
openssl098e.x86_64                           0.9.8e-29.el7.centos.3                         base   升级OpenSSL 安装openssl-devel
[root@node01 httpd]# yum install openssl-devel -y再次执行
[root@node01 httpd]# ./configure --prefix=/usr/local/httpd --enable-so --enable-ssl --enable-cgi --enable--rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most  --enable-mpms-shared=all --with-mpm=prefork configure: summary of build options:Server Version: 2.4.57Install prefix: /usr/local/httpdC compiler:     gcc -std=gnu11CFLAGS:          -g -O2 -pthread  CPPFLAGS:        -DLINUX -D_REENTRANT -D_GNU_SOURCE  LDFLAGS:           LIBS:             C preprocessor: gcc -std=gnu11 -E[root@node01 httpd]# make && make install报错
/usr/local/apr/build-1/libtool --silent --mode=link gcc -std=gnu11  -g -O2 -pthread         -o htpasswd  htpasswd.lo passwd_common.lo      /usr/local/apr-util/lib/libaprutil-1.la /usr/local/apr/lib/libapr-1.la -lrt -lcrypt -lpthread -ldl -lcrypt
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_GetErrorCode'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetEntityDeclHandler'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_ParserCreate'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetCharacterDataHandler'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_ParserFree'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetUserData'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_StopParser'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_Parse'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_ErrorString'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetElementHandler'
collect2: error: ld returned 1 exit status
make[2]: *** [htpasswd] Error 1
make[2]: Leaving directory `/usr/local/cluster/httpd-2.4.57/support'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/cluster/httpd-2.4.57/support'
make: *** [all-recursive] Error 1[root@node01 httpd]# yum install libtool -y解决参考文档
https://my.oschina.net/LuCastiel/blog/1590706安装 libxml2-devel 包[root@node01 httpd]# yum install libxml2-devel -y删除 apr-util 安装目录,并重新编译安装
[root@node01 httpd]# rm -rf /usr/local/apr-util/
[root@node01 httpd]# cd /usr/local/cluster/apr-util这一步很重要,必须清除之前配置时的缓存
[root@node01 apr-util]# make clean再次重新编译安装apr-util
[root@node01 apr-util]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@node01 apr-util]# make && make install重新编译安装 httpd
[root@node01 apr-util]# cd /usr/local/cluster/httpd
[root@node01 httpd]# make clean
[root@node01 httpd]# ./configure --prefix=/usr/local/httpd --enable-so --enable-ssl --enable-cgi --enable--rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most  --enable-mpms-shared=all --with-mpm=prefork 
configure: summary of build options:Server Version: 2.4.57Install prefix: /usr/local/httpdC compiler:     gcc -std=gnu11CFLAGS:          -g -O2 -pthread  CPPFLAGS:        -DLINUX -D_REENTRANT -D_GNU_SOURCE  LDFLAGS:           LIBS:             C preprocessor: gcc -std=gnu11 -E[root@node01 httpd]# make && make instal
。。。
make[4]: Entering directory `/usr/local/cluster/httpd-2.4.57/modules/mappers'
make[4]: Nothing to be done for `local-shared-build'.
make[4]: Leaving directory `/usr/local/cluster/httpd-2.4.57/modules/mappers'
make[3]: Leaving directory `/usr/local/cluster/httpd-2.4.57/modules/mappers'
make[2]: Leaving directory `/usr/local/cluster/httpd-2.4.57/modules'
make[2]: Entering directory `/usr/local/cluster/httpd-2.4.57/support'
make[2]: Leaving directory `/usr/local/cluster/httpd-2.4.57/support'Installing configuration files
mkdir /usr/local/httpd/conf
mkdir /usr/local/httpd/conf/extra
mkdir /usr/local/httpd/conf/original
mkdir /usr/local/httpd/conf/original/extra
Installing HTML documents
mkdir /usr/local/httpd/htdocs
Installing error documents
mkdir /usr/local/httpd/error
Installing icons
mkdir /usr/local/httpd/icons
mkdir /usr/local/httpd/logs
Installing CGIs
mkdir /usr/local/httpd/cgi-bin
Installing header files
mkdir /usr/local/httpd/include
Installing build system files
mkdir /usr/local/httpd/build
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 `/usr/local/cluster/httpd-2.4.57'根据输出信息可以看到安装目录是/usr/local/httpd

启动httpd服务


[root@node01 httpd]# whereis httpd
httpd: /usr/local/httpd[root@node01 httpd]# cd /usr/local/httpd/[root@node01 httpd]# ll -h
total 36K
drwxr-xr-x  2 root root  262 Jul 20 18:43 bin
drwxr-xr-x  2 root root  167 Jul 20 18:43 build
drwxr-xr-x  2 root root   78 Jul 20 18:43 cgi-bin
drwxr-xr-x  4 root root   84 Jul 20 18:43 conf
drwxr-xr-x  3 root root 4.0K Jul 20 18:43 error
drwxr-xr-x  2 root root   24 Jul 20 18:43 htdocs
drwxr-xr-x  3 root root 8.0K Jul 20 18:43 icons
drwxr-xr-x  2 root root 4.0K Jul 20 18:43 include
drwxr-xr-x  2 root root    6 Jul 20 18:43 logs
drwxr-xr-x  4 root root   30 Jul 20 18:43 man
drwxr-xr-x 14 root root 8.0K Jul 20 18:43 manual
drwxr-xr-x  2 root root 4.0K Jul 20 18:43 modules[root@node01 httpd]# cd bin/[root@node01 bin]# ./apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.6.101. Set the 'ServerName' directive globally to suppress this message
httpd (pid 548) already runninghttpd已经运行
[root@node01 bin]# netstat -anp |grep httpd
tcp6       0      0 :::80                   :::*                    LISTEN      548/httpd [root@node01 bin]# ./apachectl stop
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.6.101. Set the 'ServerName' directive globally to suppress this message修改配置文件
[root@node01 conf]# pwd
/usr/local/httpd/conf
[root@node01 conf]# vim httpd.conf
ServerName 192.168.6.101:80[root@node01 bin]# ./apachectl stop
[root@node01 bin]# ./apachectl start
[root@node01 bin]# ps -ef |grep httpd
root       3236      1  0 18:52 ?        00:00:00 /usr/local/httpd/bin/httpd -k start
daemon     3237   3236  0 18:52 ?        00:00:00 /usr/local/httpd/bin/httpd -k start
daemon     3238   3236  0 18:52 ?        00:00:00 /usr/local/httpd/bin/httpd -k start
daemon     3239   3236  0 18:52 ?        00:00:00 /usr/local/httpd/bin/httpd -k start
daemon     3240   3236  0 18:52 ?        00:00:00 /usr/local/httpd/bin/httpd -k start
daemon     3241   3236  0 18:52 ?        00:00:00 /usr/local/httpd/bin/httpd -k start
root       3352   1706  0 18:52 pts/0    00:00:00 grep --color=auto httpd
[root@node01 bin]# [root@node01 bin]# netstat -anp | grep httpd
tcp6       0      0 :::80                   :::*                    LISTEN      3236/httpd    [root@node01 htdocs]# more index.html 
<html><body><h1>It works!</h1></body></html>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/60393.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

jenkins流水线

1.拉取代码 https://gitee.com/Wjc_project/yygh-parent.git2、项目编译 mvn clean package -Dmaven.test.skiptrue ls hospital-manage/target3、构建镜像 ls hospital-manage/target docker build -t hospital-manage:latest -f hospital-manage/Dockerfile ./hospital-ma…

本质矩阵E、基本矩阵F、单应矩阵H

1. E (归一化坐标对进行计算) t ^ R 为3*3的矩阵, 因为R,t共有6个自由度&#xff0c;又因为单目尺度等价性&#xff0c;所以实际上E矩阵共有5个自由度。因此至少需要5个点对来求解。 2. 基本矩阵F:根据两帧间匹配的像素点对儿计算 3*3且自由度为7的矩阵kF也为基础矩阵&#x…

如何给Google Chrome增加proxy

1. 先打开https://github.com/KaranGauswami/socks-to-http-proxy/releases 我的电脑是Liunx系统所以下载第一个 2. 下载完之后把这个文件变成可执行文件&#xff0c;可以是用这个命令 chmod x 文件名 3. 然后执行这个命令&#xff1a; ./sthp-linux -p 8080 -s 127.0.0.1:…

使用 Visual Studio Code 调试 CMake 脚本

之前被引入到 Visual Studio 中的 CMake 调试器&#xff0c;现已在 Visual Studio Code 中可用。 也就是说&#xff0c;现在你可以通过在 VS Code 中安装 CMake 工具扩展&#xff0c;来调试你的 CMakeLists.txt 脚本了。是不是很棒? 背景知识 Visual C 开发团队和 CMake 的维…

tui.calender日历在vue中的使用1.0

官网&#xff1a;https://ui.toast.com/tui-calendar github&#xff1a;https://github.com/nhn/tui.calendar/tree/main 月、周、日视图都有&#xff0c;拖拽也比较方便&#xff0c;但是自己用起来比较费劲&#xff0c;参考文档写得不全&#xff0c;做个记录日后方便参考&…

如何使用 AT+WEBSERVER 指令实现自定义的 Webserver html 网页配网

开启 AT 固件中的 Webserver 指令和 FS 指令支持 乐鑫官网发布的默认通用 AT 固件不支持 webserver 配网功能&#xff0c; 需要用户自己搭建 esp-at 环境&#xff0c;并在 sdkconfig 中开启 webserver AT 指令 和 FS 指令的支持&#xff0c; 如下图所示&#xff1a; 测试 AT 固…

【Spring Boot】构建RESTful服务 — 构建RESTful应用接口

构建RESTful应用接口 RESTful架构是目前最流行的互联网软件架构规范&#xff0c;是Web API&#xff08;应用编程接口&#xff09;的大趋势和主流规范&#xff0c;了解了RESTful的众多优点之后&#xff0c;接下来一步一步地学习如何使用Spring Boot构建RESTful Web API。 1.Sp…

ThinkPHP6企业OA办公系统

有需要请加文章底部Q哦 可远程调试 ThinkPHP6企业OA办公系统 一 介绍 勾股OA基于ThinkPHP6开发&#xff0c;前端Layui&#xff0c;数据库mysql&#xff0c;是一款实用的企业办公系统。可多角色登录&#xff0c;集成了系统设置、人事管理、消息管理、审批管理、日常办公、客户…

解决Qt的列表加载大量数据卡顿的问题

问题概述 本人在使用QListView插入大量数据时&#xff0c;界面卡顿十分严重。数据量大概只有上千左右&#xff0c;但是每个Item的内容比较多。当数据不停地插入一段时间后&#xff0c;卡顿到鼠标的移动都有点困难。 解决思路 QListView是典型的MVC思想的产物。界面呈现出来的数…

python——案例11:数值交换

案例11&#xff1a;数值交换xinput(输入一个数值赋值给x&#xff1a;) yinput(输入一个数值赋值给y&#xff1a;)tempx #创建临时变量&#xff0c;以此变量为基础进行逐次交换 xy ytemp print(交换后的X的值是:{}.format(x)) # print(交换后的Y的值是:{}.format(y)) #

RabbitMQ学习——发布订阅/fanout模式 topic模式 rabbitmq回调确认 延迟队列(死信)设计

目录 引出点对点(simple)Work queues 一对多发布订阅/fanout模式以登陆验证码为例pom文件导包application.yml文件rabbitmq的配置生产者生成验证码&#xff0c;发送给交换机消费者消费验证码 topic模式配置类增加配置生产者发送信息进行发送控制台查看 rabbitmq回调确认配置类验…

Flutter:屏幕适配

flutter_screenutil flutter_screenutil是一个用于在Flutter应用程序中进行屏幕适配的工具包。它旨在帮助开发者在不同屏幕尺寸和密度的设备上创建响应式的UI布局。 flutter_screenutil提供了一些用于处理尺寸和间距的方法&#xff0c;使得开发者可以根据设备的屏幕尺寸和密度…