编译安装httpd-2.4
1.编译安装
//安装开发环境
[root@localhost ~]# yum groups mark install "Development Tools"
[root@localhost ~]# groupadd -r apache
[root@localhost ~]# useradd -r -g apache apache
[root@localhost ~]# yum -y install openssl-devel pcre-devel expat-devel libtool
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Resolving Dependencies
--> Running transaction check
---> Package openssl-devel.x86_64 1:1.0.2k-12.el7 will be installed
--> Processing Dependency: openssl-libs(x86-64) = 1:1.0.2k-12.el7 for package: 1:openssl-devel-1.0.2k-12.el7.x86_64
......
......
libselinux-utils.x86_64 0:2.5-12.el7 libsepol.x86_64 0:2.5-8.1.el7
libss.x86_64 0:1.42.9-12.el7_5 openssl.x86_64 1:1.0.2k-12.el7
openssl-libs.x86_64 1:1.0.2k-12.el7
Complete!
//下载并安装apr-1.4+和apr-util-1.4+
[root@localhost ~]# cd /usr/src/
[root@localhost src]# wget http://mirror.bit.edu.cn/apache/apr/apr-1.6.5.tar.gz
[root@localhost src]# wget http://mirror.bit.edu.cn/apache/apr/apr-util-1.6.1.tar.gz
[root@localhost src]# ls
apr-1.6.5.tar.gz apr-util-1.6.1.tar.gz debug kernels
[root@localhost src]# tar xf apr-1.6.5.tar.gz
[root@localhost src]# tar xf apr-util-1.6.1.tar.gz
[root@localhost src]# ls
apr-1.6.5 apr-1.6.5.tar.gz apr-util-1.6.1 apr-util-1.6.1.tar.gz debug kernels
[root@localhost src]# cd apr-1.6.5
[root@localhost apr-1.6.5]# vim configure
cfgfile="${ofile}T"
trap "$RM \"$cfgfile\"; exit 1" 1 2 15
# $RM "$cfgfile" //将此行加上注释,或者删除此行
[root@localhost apr-1.6.5]# ./configure --prefix=/usr/local/apr
配置过程略...
[root@localhost apr-1.6.5]# make && make install
编译安装过程略...
[root@localhost apr-1.6.5]# cd /usr/src/apr-util-1.6.1
[root@localhost apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
配置过程略...
[root@localhost apr-util-1.6.1]# make && make install
编译安装过程略...
//编译安装httpd
[root@localhost ~]# wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.4.38.tar.gz
[root@localhost ~]# ls
httpd-2.4.38.tar.gz
[root@localhost ~]# tar xf httpd-2.4.38.tar.gz
[root@localhost ~]# cd httpd-2.4.38
[root@localhost httpd-2.4.38]# ./configure --prefix=/usr/local/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.38]# make && make install
2.修改PATH环境变量
[root@localhost ~]# echo 'export PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/htttpd.sh
3.开启服务
[root@localhost ~]# apachectl start
4.查看版本
[root@localhost ~]# apachectl -v
Server version: Apache/2.4.38 (Unix)
Server built: Nov 10 2019 19:13:15
2.更新版本
2.1下载源码包并解压
wget https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.4.41.tar.gz
[root@localhost ~]# tar xf httpd-2.4.41.tar.gz
[root@localhost ~]# ls
anaconda-ks.cfg apache.sh httpd httpd-2.4.41 httpd-2.4.41.tar.gz index.html
2.2 进入到旧版本httpd-2.4.38,把config.nice执行文件的内容找出来,configure需要用
[root@localhost ~]# cd httpd-2.4.38
[root@localhost httpd-2.4.38]# ls
ABOUT_APACHE CHANGES httpd.dep LICENSE README
acinclude.m4 CMakeLists.txt httpd.dsp Makefile README.cmake
Apache-apr2.dsw config.layout httpd.mak Makefile.in README.platforms
Apache.dsw config.log httpd.spec Makefile.win ROADMAP
apache_probes.d config.nice include modules server
ap.d config.status INSTALL modules.c srclib
build configure InstallBin.dsp modules.lo support
BuildAll.dsp configure.in LAYOUT modules.o test
BuildBin.dsp docs libhttpd.dep NOTICE VERSIONING
buildconf emacs-style libhttpd.dsp NWGNUmakefile
buildmark.o httpd libhttpd.mak os
[root@localhost httpd-2.4.38]# cat config.nice
#! /bin/sh
#
# Created by configure
"./configure" \
"--prefix=/usr/local/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" \
"$@"
2.3 定制组件,
[root@localhost ~]# cd httpd-2.4.41
[root@localhost httpd-2.4.41]# "./configure" \
> "--prefix=/usr/local/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" \
> "$@"
2.4 用make编译,编译好了之后会生成一个httpd执行文件
[root@localhost httpd-2.4.41]# make
[root@localhost httpd-2.4.41]# ls
ABOUT_APACHE CHANGES httpd.dep LICENSE README
acinclude.m4 CMakeLists.txt httpd.dsp Makefile README.cmake
Apache-apr2.dsw config.layout httpd.mak Makefile.in README.platforms
Apache.dsw config.log httpd.spec Makefile.win ROADMAP
apache_probes.d config.nice include modules server
ap.d config.status INSTALL modules.c srclib
build configure InstallBin.dsp modules.lo support
BuildAll.dsp configure.in LAYOUT modules.o test
BuildBin.dsp docs libhttpd.dep NOTICE VERSIONING
buildconf emacs-style libhttpd.dsp NWGNUmakefile
buildmark.o httpd libhttpd.mak os
2.5 把/usr/local/apache/bin/下的httpd执行文件备份
[root@localhost ~]# mv /usr/local/apache/bin/httpd /opt/haha
2.6 然后切换到httpd-2.4.41版本目录里面把httpd复制到/usr/local/apache/bin/httpd
[root@localhost ~]# cd httpd-2.4.41
[root@localhost httpd-2.4.41]# ls
ABOUT_APACHE CHANGES httpd.dep LICENSE README
acinclude.m4 CMakeLists.txt httpd.dsp Makefile README.cmake
Apache-apr2.dsw config.layout httpd.mak Makefile.in README.platforms
Apache.dsw config.log httpd.spec Makefile.win ROADMAP
apache_probes.d config.nice include modules server
ap.d config.status INSTALL modules.c srclib
build configure InstallBin.dsp modules.lo support
BuildAll.dsp configure.in LAYOUT modules.o test
BuildBin.dsp docs libhttpd.dep NOTICE VERSIONING
buildconf emacs-style libhttpd.dsp NWGNUmakefile
buildmark.o httpd libhttpd.mak os
[root@localhost httpd-2.4.41]#
[root@localhost httpd-2.4.41]# cp -r httpd /usr/local/apache/bin/httpd
[root@localhost httpd-2.4.41]# ls /usr/local/apache/bin
ab apxs dbmmanage envvars-std htcacheclean htdigest httpd logresolve
apachectl checkgid envvars fcgistarter htdbm htpasswd httxt2dbm rotatelogs
2.7 刷新服务并查看版本发现版本从之前的2.4.38变成了2.4.41
[root@localhost ~]# apachectl restart
[root@localhost ~]# apachectl -v
Server version: Apache/2.4.41 (Unix)
Server built: Nov 11 2019 12:03:10