apache httpd 从2.2升级到2.4的过程及中间遇到的坑
背景描述:
最近集团在做安全扫描,扫出了http的漏洞,一看是监控nagios涉及到的httpd,于是就考虑将httpd升级到最新的版本,在升级的过程中,真是遇到了很多的坑,弄了2天终于搞定了,现在梳理下相应的错误处理过程及解决的方法。
环境信息:
apache httpd版本:Apache/2.2.15
OS版本:Red Hat Enterprise Linux Server release 6.6 (Santiago)
httpd 2.2 升级到 2.4的过程【采用重新安装一个最新版本,然后加载原配置的方法】:
1.下载最新的httpd软件包,此处用的软件包版本
httpd-2.4.39.tar.gz
下载地址:http://httpd.apache.org/download.cgi
2.将软件上传到服务器上(注意使用root用户上传)
3.解压,检查环境配置
[root@hadoop1 softwares]# tar -zxf httpd-2.4..tar.gz
[root@hadoop1 softwares]# cd httpd-2.4.
[root@hadoop1 httpd-2.4.]# ./configure --prefix=/usr/local/httpd-2.4.
有如下报错信息:
[root@hadoop1 httpd-2.4.]# ./configure --prefix=/usr/local/httpd-2.4.
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /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... configure: WARNING: APR version 1.4. or later is required, found 1.3.
configure: WARNING: skipped APR at apr--config, version not acceptable
no
configure: error: APR not found. Please read the documentation.
通过以上的报错信息知道,缺少apr的包,下载apr相关的包
4.下载apr对应软件包,下载以下2个包

5.将apr及apr-util的包解压到httpd解压之后的目录中,放到srclib目录下
[root@hadoop1 httpd-2.4.]# pwd
/opt/softwares/httpd-2.4.
[root@hadoop1 httpd-2.4.]# ls
ABOUT_APACHE apache_probes.d BuildBin.dsp config.layout configure.in httpd.dsp INSTALL libhttpd.dsp Makefile.win os ROADMAP test
acinclude.m4 ap.d buildconf config.log docs httpd.mak InstallBin.dsp libhttpd.mak modules README server VERSIONING
Apache-apr2.dsw build CHANGES config.nice emacs-style httpd.spec LAYOUT LICENSE NOTICE README.cmake srclib
Apache.dsw BuildAll.dsp CMakeLists.txt configure httpd.dep include libhttpd.dep Makefile.in NWGNUmakefile README.platforms support
[root@hadoop1 httpd-2.4.]# cd srclib/
[root@hadoop1 srclib]# ll
total
-rw-r--r-- root dip Feb Makefile.in
将apr及apr-util解压到该目录下
[root@hadoop1 softwares]# tar -zxf apr-1.7..tar.gz -C ./httpd-2.4./srclib/
[root@hadoop1 softwares]# tar -zxf apr-util-1.6..tar.gz -C ./httpd-2.4./srclib/
[root@hadoop1 softwares]# cd httpd-2.4./srclib/
[root@hadoop1 srclib]# ls
apr-1.7. apr-util-1.6. Makefile.in
[root@hadoop1 srclib]# mv apr-1.7./ apr
[root@hadoop1 srclib]# mv apr-util-1.6./ apr-util
[root@hadoop1 srclib]# ls
apr apr-util Makefile.in
6.重新检查httpd的配置
[root@hadoop1 httpd-2.4.]# ./configure --prefix=/usr/local/httpd-2.4.
出现以下结果:
... ...省略
configure: summary of build options: Server Version: 2.4.
Install prefix: /usr/local/httpd-2.4.
C compiler: gcc -std=gnu99
CFLAGS: -g -O2 -pthread
CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE
LDFLAGS:
LIBS:
C preprocessor: gcc -E
以上提示,表示检查配置没有问题。
7.进行编译,安装
make
此处出现如下错误:
/apr-util/include -I/opt/softwares/httpd-2.4./srclib/apr-util/include/private -I/opt/softwares/httpd-2.4./srclib/apr/include -o xml/apr_xml.lo -c xml/apr_xml.c && touch xml/apr_xml.lo
xml/apr_xml.c::: error: expat.h: No such file or directory
xml/apr_xml.c:: error: expected specifier-qualifier-list before ‘XML_Parser’
xml/apr_xml.c: In function ‘cleanup_parser’:
xml/apr_xml.c:: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c: At top level:
xml/apr_xml.c:: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
xml/apr_xml.c: In function ‘apr_xml_parser_create’:
xml/apr_xml.c:: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:: error: ‘default_handler’ undeclared (first use in this function)
xml/apr_xml.c:: error: (Each undeclared identifier is reported only once
xml/apr_xml.c:: error: for each function it appears in.)
xml/apr_xml.c: In function ‘do_parse’:
xml/apr_xml.c:: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:: error: ‘apr_xml_parser’ has no member named ‘xp_err’
xml/apr_xml.c:: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c: In function ‘apr_xml_parser_geterror’:
xml/apr_xml.c:: error: ‘apr_xml_parser’ has no member named ‘xp_err’
xml/apr_xml.c:: error: ‘apr_xml_parser’ has no member named ‘xp_err’
make[]: *** [xml/apr_xml.lo] Error
make[]: Leaving directory `/opt/softwares/httpd-2.4./srclib/apr-util'
make[]: *** [all-recursive] Error
make[]: Leaving directory `/opt/softwares/httpd-2.4./srclib/apr-util'
make[]: *** [all-recursive] Error
make[]: Leaving directory `/opt/softwares/httpd-2.4./srclib'
make: *** [all-recursive] Error
解决方法,安装expdat-devel包
[root@hadoop1 httpd-2.4.39]# yum install expat-devel
Loaded plugins: product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package expat-devel.x86_64 0:2.0.1-13.el6_8 will be installed
--> Finished Dependency Resolution Dependencies Resolved ===============================================================================================================================================================================================
Package Arch Version Repository Size
===============================================================================================================================================================================================
Installing:
expat-devel x86_64 2.0.1-13.el6_8 base 119 k Transaction Summary
===============================================================================================================================================================================================
Install 1 Package(s) Total download size: 119 k
Installed size: 476 k
Is this ok [y/N]: y
Downloading Packages:
expat-devel-2.0.1-13.el6_8.x86_64.rpm | 119 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Installing : expat-devel-2.0.1-13.el6_8.x86_64 1/1
Verifying : expat-devel-2.0.1-13.el6_8.x86_64 1/1 Installed:
expat-devel.x86_64 0:2.0.1-13.el6_8 Complete!
再次进行编译,出现以下信息,表示编译成功
... ... 省略
mod_rewrite.lo
make[]: Leaving directory `/opt/softwares/httpd-2.4./modules/mappers'
make[]: Leaving directory `/opt/softwares/httpd-2.4./modules/mappers'
make[]: Leaving directory `/opt/softwares/httpd-2.4./modules'
make[]: Entering directory `/opt/softwares/httpd-2.4./support'
make[]: Leaving directory `/opt/softwares/httpd-2.4./support' make[]: Leaving directory `/opt/softwares/httpd-2.4.'
执行安装
[root@hadoop1 httpd-2.4.]# make install
8.创建配置文件目录conf.d,并且将原httpd配置文件拷贝到新版本配置目录下
[root@hadoop1 httpd-2.4.]# cd /usr/local/httpd-2.4./
[root@hadoop1 httpd-2.4.]# mkdir conf.d
[root@hadoop1 httpd-2.4.]# ls -l
total
drwxr-xr-x root root Jul : bin
drwxr-xr-x root root Jul : build
drwxr-xr-x root root Jul : cgi-bin
drwxr-xr-x root root Jul : conf
drwxr-xr-x root root Jul : conf.d
drwxr-xr-x root root Jul : error
drwxr-sr-x root root Mar : htdocs
drwxr-xr-x root root Jul : icons
drwxr-xr-x root root Jul : include
drwxr-xr-x root root Jul : lib
drwxr-xr-x root root Jul : logs
drwxr-xr-x root root Jul : man
drwxr-sr-x root root Mar : manual
drwxr-xr-x root root Jul : modules [root@hadoop1 httpd-2.4.]# cd conf
[root@hadoop1 conf]# cp httpd.conf httpd.conf.bak
[root@hadoop1 conf]# cd ../conf.d/
[root@hadoop1 conf.d]# cp /etc/httpd/conf.d/nagios.conf .
9.关闭原有httpd服务,启动新的服务
[root@hadoop1 httpd-2.4.]# service httpd stop
Stopping httpd: [ OK ]
[root@hadoop1 httpd-2.4.]# bin/apachectl -f conf/httpd.conf
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.30.10. Set the 'ServerName' directive globally to suppress this message
10.通过页面进行访问最新的服务
发现无法访问,出现以下的错误:

就没有这个nagios路径,说明没有加载到配置文件,查看发现没有include,增加以下配置
include conf.d/*.conf
重启服务,再次刷新页面,变成是没有权限访问了,如下:

查看日志,报如下的错误:

以上信息显示没有正常的生产索引,但是该目录下php的文件,应该能显示才对,
检查httpd中是否加载了php模块,发现没有php模块
[root@hadoop1 httpd-2.4.]# bin/apachectl -t -D DUMP_MODULES | grep php
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.30.10. Set the 'ServerName' directive globally to suppress this message
然后又找了相应的解决方案,发现是需要单独进行编译,然后在httpd中配置模块信息
--1.上传php包
[root@hadoop1 softwares]# ls -l php-7.3..tar.gz
-rw-r--r-- root root Jul : php-7.3..tar.gz
--2.解压,检查配置,编译
[root@hadoop1 softwares]# tar -zxf php-7.3..tar.gz
[root@hadoop1 softwares]# cd php-7.3.
[root@hadoop1 php-7.3.]# ./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/httpd-2.4./bin/apxs
发现有如下报错:
Configuring extensions
checking for strings.h... (cached) yes
checking io.h usability... no
checking io.h presence... no
checking for io.h... no
checking for strtoll... yes
checking for atoll... yes
checking whether to enable LIBXML support... yes
checking libxml2 install dir... no
checking for xml2-config path...
checking for pkg-config... /usr/bin/pkg-config
configure: error: libxml2 not found. Please check your libxml2 installation.
安装libxml2包
[root@hadoop1 php-7.3.]# yum install -y libxml2 libxml2-devel
再次进行配置检查,检查通过
执行编译
[root@hadoop1 php-7.3.]# make && make install
编译之后,在httpd目录modules中生产php模块文件
[root@hadoop1 modules]# ls -l libphp7.so
-rwxr-xr-x root root Jul : libphp7.so
--3.将php模块加入到http配置中
LoadModule php7_module modules/libphp7.so
检查配置是否加载
[root@hadoop1 httpd-2.4.]# bin/apachectl -t -D DUMP_MODULES | grep php
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.30.10. Set the 'ServerName' directive globally to suppress this message
php7_module (shared)
显示,已经加载了。在实验中发下,模块信息,在php make install之后会自动将配置加载到httpd.conf文件中,并且动态加载。
再次通过页面进行访问

仍然访问不了,报了相同的错误。
继续修改httpd.conf,支持php
AddType application/x-httpd-php .php <IfModule dir_module>
DirectoryIndex index.html index.php index.htm
</IfModule>
重新启动http服务,再次访问页面

主页是可以访问的了,但是点击其他的页面,就是下载cgi文件,无法执行

查看是否有cgi模块
[root@hadoop1 httpd-2.4.]# bin/apachectl -t -D DUMP_MODULES | grep cgi
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.30.10. Set the 'ServerName' directive globally to suppress this message
无该模块,继续修改httpd配置文件开启cgi模块支持
LoadModule cgid_module modules/mod_cgid.so
取消注释之后,再次检查,已经加载,无需重启
[root@hadoop1 httpd-2.4.]# bin/apachectl -t -D DUMP_MODULES | grep cgi
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.30.10. Set the 'ServerName' directive globally to suppress this message
cgid_module (shared)
经过验证,需要重启,才能生效,再次访问页面

正常,可以访问。升级完成。
另外,在升级中如果遇到以下报错:
[Mon Jul ::38.516704 ] [core:error] [pid :tid ] ()Permission denied: [client 10.253.7.100:] AH00035: access to /nagios/ denied (filesystem path '/mnt/aiprd/app') because search permissions are missing on a component of the path
[Mon Jul ::45.786697 ] [core:error] [pid :tid ] ()Permission denied: [client 10.191.36.37:] AH00035: access to / denied (filesystem path '/mnt/aiprd/app') because search permissions are missing on a component of the path
解决:
修改cgisocket文件路径,显示给个路径:
ScriptSock /var/run/cgid.sock
原因:主要还是安全的问题考虑,2.4之后对安全有很多的考虑。相关问题可以参考下http的安全提示:
Security Tips - Apache HTTP Server Version 2.4
文档创建时间:2019年7月3日12:40:52
apache httpd 从2.2升级到2.4的过程及中间遇到的坑的更多相关文章
- Apache Httpd Server 2.2升级2.4
Apache Httpd Server 2.2升级2.4 (2 votes, average: 5.00 out of 5) 2,302 views 2012 年 3 月 20 日Web服务器.服务器 ...
- Mysql5.5升级到5.7的过程已经踩到的坑
https://blog.csdn.net/u014534986/article/details/79699750 故事是这样子的,我们公司有几台老的mysql版本是5.5的,最近项目做了一些升级增加 ...
- Nginx为什么比Apache Httpd高效:原理篇
一.进程.线程? 进程是具有一定独立功能的,在计算机中已经运行的程序的实体.在早期系统中(如linux 2.4以前),进程是基本运作单位,在支持线程的系统中(如windows,linux2.6)中,线 ...
- Nginx为什么比Apache Httpd高效
转载于:http://www.toxingwang.com/linux-unix/linux-basic/1712.html 一.进程.线程? 在回答nginx 为什么比apache更高效之前,必须要 ...
- 【转】Linux下apache/httpd服务启动与停止
apache服务,或者说httpd服务,如何启动,如何开机启动. 转来转去,找不到原文.. 操作系统环境:红帽5,具体如下:# uname -a Linux machine1 2.6.18-164.e ...
- mac os 禁止apache httpd自动启动(转)
mac os 禁止apache httpd自动启动 博客分类: 计算机使用 mac os不像linux有/etc/init.d/rc.local以及service的方式可以设置程序随机启动,而是使 ...
- Apache Httpd + Subversion 搭建HTTP访问的SVN服务器
最近要搭建一个SVN服务器.简单安装之后,本地访问没有问题,但作为服务器肯定是需要HTTP访问.搜索之后,以下是我按照网上的资料搭建的过程,以备后用和参考.(所有软件安装步骤略,没有特殊的,如果没有特 ...
- Fedora8上Apache Httpd与Tomcat6初集成
系统信息: 环境: Linux version :2.6.23.1-42.fc8,gcc version 4.1.2 20070925 Apache Httpd version: 2.2.6.3-3 ...
- 在Fedora8上配置Apache Httpd
原以为Fedora8我安装的是最简版本,于是去Apache Httpd官网下一个httpd,但是速度很成问题,现在还没有下完. 打开Fedora8的光盘,里面有httpd-2.2.6.3-3.i386 ...
随机推荐
- Intel重大漏洞之Meltdown和Spectre
史上最大漏洞危机:影响所有 iPhone.Android.PC 设备,修复困难重重 近日,英特尔的日子可并不好过. 作为全球知名芯片制造商,任何有关英特尔芯片漏洞的问题都会导致全球上百万设备遭受牵连. ...
- (05节)快速搭建SSM项目
1.1 快速搭建Web项目 注意点:name:archetypeCatalog,value:internal 原因:Intellij IDEA根据maven archetype的本质,执行mvn a ...
- centos 启动 oracle
source .bash_profile su - oracle //切换到自己的oracle账户 lsnrctl start //启动oracle监听 sqlplus /nolog //登录 ...
- oracle 字符集安装错了,修改字符集 及创建用户 表空间 ,删除用户及所有的表
1.首先以sysdba的身份登录上去 conn /as sysdba 2.关闭数据库shutdown immediate; 3.以mount打来数据库,startup mount 4.设置sessio ...
- Linux的sz和rz命令
工作中需要在Linux和Windows之间传输文件时,一般使用winscp或者ftp工具来完成,最近才知道有sz和rz这两个命令,方便好用. sz 下载 从Linux下载文件到本机 , 在Linux ...
- JPA 报错:Page 2 of 1 containing UNKNOWN instances
JPA 中,page是从0开始,不是从1开始: 因此,将用户输入的从1开始的page页码减1: PageRequest pageRequest = PageRequest.of(page - 1, p ...
- Numpy | 01 简介
NumPy(Numerical Python) 是 Python 语言的一个扩展程序库,支持大量的维度数组与矩阵运算,此外也针对数组运算提供大量的数学函数库. NumPy 是一个运行速度非常快的数学库 ...
- 可以使用WinDbg将PE映像作为转储文件打开
WinDbg.ntsd.cdb.kd和其他任何使用DbgEng打开转储文件的工具都有一个鲜为人知的特性.事实证明,使用DbgEng提供的任何功能,在任何可以打开转储文件(用户转储.内核转储等)的地方, ...
- match 和 search 和 indexOf 查找及 正则表达式的 exec 和 test 用法
function test(){ var name= "1.087"; var abc = "abd wor66k ne78xt"; var reg = /\d ...
- AtCoder Regular Contest 069 F Flags 二分,2-sat,线段树优化建图
AtCoder Regular Contest 069 F Flags 二分,2-sat,线段树优化建图 链接 AtCoder 大意 在数轴上放上n个点,点i可能的位置有\(x_i\)或者\(y_i\ ...