apache升级步骤

赵辉
2023-12-01
//首先查看当前已安装的apache版本

[root@localhost src]# httpd -v
Server version: Apache/2.4.38 (Unix)
Server built:   Nov 14 2019 09:14:32


//下载新版本并解压
[root@localhost ~]# cd /usr/src/
[root@localhost src]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.4.41.tar.gz
--2019-11-14 09:25:33--  https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.4.41.tar.gz
正在解析主机 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.8.193, 2402:f000:1:408:8100::1
正在连接 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:9267917 (8.8M) [application/octet-stream]
正在保存至: “httpd-2.4.41.tar.gz”

100%[================================================================================>] 9,267,917    472KB/s 用时 

2019-11-14 09:26:00 (472 KB/s) - 已保存 “httpd-2.4.41.tar.gz” [9267917/9267917])

[root@localhost src]# tar xf httpd-2.4.41.tar.gz 


//编译但不安装新版apache	
首先查看已安装的apache的配置
[root@localhost src]# cd httpd-2.4.41
[root@localhost httpd-2.4.41]# cat /usr/src/httpd-2.4.38/config.nice
#! /bin/sh
#
# Created by configure

"./configure" \
"--prefix=/opt/apache" \
"--sysconfdir=/etc/httpd24" \
"--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" \
"$@"
[root@localhost httpd-2.4.41]# ./configure \
> --prefix=/opt/apache \
> --sysconfdir=/etc/httpd24 \
> --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 \
>

//这里编译但不安装
[root@localhost httpd-2.4.41]# make
//备份旧版apache的httpd文件
[root@localhost httpd-2.4.41]# mv /opt/apache/bin/httpd{,.bak}
[root@localhost httpd-2.4.41]# ls /opt/apache/bin/httpd.bak 
/opt/apache/bin/httpd.bak
//复制新版apache的httpd到旧版的apache/bin目录下
[root@localhost httpd-2.4.41]# cp httpd /opt/apache/bin/
[root@localhost httpd-2.4.41]# ls /opt/apache/bin/
ab         apxs      dbmmanage  envvars-std  htcacheclean  htdigest  httpd      httxt2dbm   rotatelogs
apachectl  checkgid  envvars    fcgistarter  htdbm         htpasswd  httpd.bak  logresolve

//重启服务查看版本
[root@localhost httpd-2.4.41]# cd 
[root@localhost ~]# apachectl restart 
[root@localhost ~]# httpd -v
Server version: Apache/2.4.41 (Unix)
Server built:   Nov 14 2019 09:40:04

 类似资料: