rhel升级httpd
说明
1、此文档编写于2022年8月,阅读文档时,可能软件版本不是最新版本,请注意。
2、原理,安装时将新的httpd指向老的httpd,即可覆盖之前的httpd,完成升级,配置等都不会变。一定在测试环境测试完成再升级。
包名 | 下载地址 | 下载版本 |
---|---|---|
apr | https://apr.apache.org/download.cgi | apr-1.7.0.tar.gz |
apr-util | https://apr.apache.org/download.cgi | apr-util-1.6.1.tar.gz |
pcre | https://sourceforge.net/projects/pcre/files/ | pcre-8.44.tar.gz pcre-8.45.tar.gz(可安装最新版本) |
expat | https://github.com/libexpat/libexpat/releases | expat-2.0.1.tar.gz expat-2.4.8.tar.gz(可安装最新版本) |
zlib | https://www.zlib.net/ | zlib-1.2.8.tar.gz zlib-1.2.11.tar.gz(可安装最新版本) |
httpd | https://httpd.apache.org/download.cgi | httpd-2.4.46.tar.gz httpd-2.4.54.tar.gz |
安装老apache
安装gcc,gcc-c++,root用户执行
yum install gcc -y
yum install gcc-c++ -y
创建目录
mkdir /apache
mkdir /apache/apache2.4.46
mkdir /apache/app
安装apr
tar -xzf apr-1.7.0.tar.gz
cd apr-1.7.0
./configure --prefix=/apache/app/apr
make
make install
安装expat
tar -xzf expat-2.0.1.tar.gz
cd expat-2.0.1
./configure --prefix=/apache/app/expat
make
make install
安装apr-util
tar -xzf apr-util-1.6.1.tar.gz
cd apr-util-1.6.1
./configure --prefix=/apache/app/apr-util --with-apr=/apache/app/apr --with-expat=/apache/app/expat
make
make install
安装zlib
tar -xzf zlib-1.2.8.tar.gz
cd zlib-1.2.8/
./configure --prefix=/apache/app/zlib
make
make install
安装pcre
tar -xzf pcre-8.44.tar.gz
cd pcre-8.44
./configure --prefix=/apache/app/pcre
make
make install
安装httpd
tar -xzf httpd-2.4.46.tar.gz
cd httpd-2.4.46
./configure --prefix=/apache/apache2.4.46 --enable-so --enable-cgi --enable-cgid --enable-rewrite --with-pcre=/apache/app/pcre --with-z=/apache/app/zlib -with-apr=/apache/app/apr --with-apr-util=/apache/app/apr-util --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --with-mpm=event --enable-proxy --enable-proxy-fchi --enable-expires --enable-deflate
make
make install
修改配置文件,以便验证
User daemon改为User
Group Daemon改为Group
添加ServerName localhost:80
升级apache
备份apache目录
cd /apache
tar cvf ./apache2.4.46.tar ./apache2.4.46/
停止apache
cd /apache/apache2.4.46/bin
./httpd -k stop
升级apache
tar -xzf httpd-2.4.54.tar.gz
cd httpd-2.4.54
./configure --prefix=/apache/apache2.4.46 --enable-so --enable-cgi --enable-cgid --enable-rewrite --with-pcre=/apache/app/pcre/bin/pcre-config --with-z=/apache/app/zlib -with-apr=/apache/app/apr --with-apr-util=/apache/app/apr-util --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --with-mpm=event --enable-proxy --enable-proxy-fchi --enable-expires --enable-deflate
make
make install
启动apache
cd /apache/apache2.4.46/bin
./httpd -v
Server version: Apache/2.4.54 (Unix)
Server built: Jul 14 2022 18:54:04
./httpd -k start
检查服务是否正常
回退方案
再次备份apache目录,apache用户执行
cd /apache
tar cvf ./apache2.4.46_new.tar ./apache2.4.46/
停止apache
cd /apache/apache2.4.46/bin
./httpd -k stop
删除apache目录,并恢复apache目录,apache用户执行
rm -rf apache2.4.46
tar xvf apache2.4.46.tar
启动apache
cd /apache/apache2.4.46/bin
./httpd -v
Server version: Apache/2.4.46 (Unix)
Server built: Jul 14 2022 18:03:37
./httpd -k start