文章目录
编译安装最新版的httpd
httpd的最新版本为2.4版本
编译安装httpd-2.4
1. 下载源码包并配置环境
源码包地址:https://downloads.apache.org/
[root@localhost ~]# wget https://downloads.apache.org/apr/apr-1.7.0.tar.gz
--2022-04-17 15:27:35-- https://downloads.apache.org/apr/apr-1.7.0.tar.gz
2022-04-17 15:27:38 (565 KB/s) - 已保存 “apr-1.7.0.tar.gz” [1093896/1093896])
[root@localhost ~]# wget https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz
--2022-04-17 15:28:17-- https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz
2022-04-17 15:28:20 (272 KB/s) - 已保存 “apr-util-1.6.1.tar.gz” [554301/554301])
[root@localhost ~]# wget https://downloads.apache.org/httpd/httpd-2.4.53.tar.gz
--2022-04-17 15:29:18--
2022-04-17 15:32:32 (49.2 KB/s) - 已保存 “httpd-2.4.53.tar.gz” [9726558/9726558])
配置环境
[root@localhost ~]# yum groups mark install "Development Tools"
[root@localhost ~]# rpm -qa|grep gcc
libgcc-8.3.1-5.el8.x86_64
[root@localhost ~]# useradd -r -M -s /sbin/nologin apache
[root@localhost ~]# id apache
uid=48(apache) gid=48(apache) 组=48(apache)
[root@localhost ~]# grep apache /etc/group
apache:x:973:
[root@localhost ~]# yum -y install bzip2 make openssl-devel pcre-devel expat-devel libtool gcc
2.安装资源包
解压
[root@localhost ~]# ls
公共 图片 音乐 apr-1.7.0.tar.gz initial-setup-ks.cfg
模板 文档 桌面 apr-util-1.6.1.tar.gz
视频 下载 anaconda-ks.cfg httpd-2.4.53.tar.gz
[root@localhost ~]# tar xf apr-1.7.0.tar.gz
[root@localhost ~]# tar xf apr-util-1.6.1.tar.gz
[root@localhost ~]# tar xf httpd-2.4.53.tar.gz
[root@localhost ~]# ls
公共 文档 anaconda-ks.cfg apr-util-1.6.1.tar.gz
模板 下载 apr-1.7.0 httpd-2.4.53
视频 音乐 apr-1.7.0.tar.gz httpd-2.4.53.tar.gz
图片 桌面 apr-util-1.6.1 initial-setup-ks.cfg
apr源码包
[root@localhost ~]# cd apr-1.7.0/
[root@localhost apr-1.7.0]# ./configure --prefix=/usr/local/apr
[root@localhost apr-1.7.0]# make
[root@localhost apr-1.7.0]# make install
apr-util源码包
[root@localhost ~]# cd 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
[root@localhost apr-util-1.6.1]# make install
httpd源码包
[root@localhost ~]# cd httpd-2.4.53/
[root@localhost httpd-2.4.53]# ./configure --prefix=/usr/local/apache \
> --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.53]# make
[root@localhost httpd-2.4.53]# make install
3.配置httpd
配置环境变量
[root@localhost ~]# ls /usr/local/
apache apr-util etc include lib64 sbin src
apr bin games lib libexec share
[root@localhost ~]# cd /usr/local/apache/
[root@localhost apache]# ls
bin cgi-bin error icons logs manual
build conf htdocs include man modules
[root@localhost apache]# cd
[root@localhost ~]# echo 'export PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/apache.sh
[root@localhost ~]# source /etc/profile.d/apache.sh
[root@localhost ~]# which httpd
/usr/local/apache/bin/httpd
[root@localhost ~]# which apachectl
/usr/local/apache/bin/apachectl
配置man
[root@localhost ~]# ln -s /usr/local/apache/include/ /usr/include/apache
[root@localhost ~]# vi /etc/man_db.conf
[root@localhost ~]# cat /etc/man_db.conf
#
MANDATORY_MANPATH /usr/man
MANDATORY_MANPATH /usr/share/man
MANDATORY_MANPATH /usr/local/share/man
MANDATORY_MANPATH /usr/local/share/apache
#
[root@localhost ~]# systemctl disable --now firewalld.service
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce
Permissive
[root@localhost ~]# vi /etc/selinux/config
[root@localhost ~]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
配置80端口
[root@localhost ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:111 0.0.0.0:*
LISTEN 0 32 192.168.122.1:53 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 5 127.0.0.1:631 0.0.0.0:*
LISTEN 0 128 [::]:111 [::]:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0