【httpd的编译和配置】

本文详细介绍了如何编译安装Apache httpd 2.4,包括下载源码、配置环境、安装资源包等步骤。接着讲解了如何配置三种类型的虚拟主机,分别是相同IP不同端口、不同IP相同端口和相同IP相同端口不同域名。此外,还涵盖了https的配置,包括配置httpd.conf、证书以及实现https访问。
摘要由CSDN通过智能技术生成

编译安装最新版的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         
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值