1、编译安装方式

源码包下载,并上传到服务器:

https://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.43.tar.gz

查看是否安装有apache

rpm -qa httpd

安装依赖包及相关软件:

yum install  pcre-devel  zlib-devel  expat-devel  gcc gcc++  -y

上传apr-1.7.0.tar.gz并安装:

tar zxf apr-1.7.0.tar.gz

cd apr-1.7.0

./configure

make && make install

上传apr-util-1.6.1.tar.gz并安装:

tar zxf apr-util-1.6.1.tar.gz

cd apr-util-1.6.1

./configure -with-apr=/usr/local/apr/bin/apr-1-config

make && make install

添加apache用户:

useradd -s /sbin/nologin -M apache

建立安装目录:

mkdir /application

解压源码安装包:

tar zxf httpd-2.4.43.tar.gz

cp -rf  ./apr-1.7.0  ./httpd-2.4.43/srclib/apr

cp -rf ./apr-util-1.6.1  ./httpd-2.4.43/srclib/apr-util

编译安装:

cd httpd-2.4.43

./configure \

--prefix=/application \

--with-included-apr \

--enable-deflate \

--enable-expires \

--enable-headers \

--enable-modules=most \

--enable-so \

--with-mpm=worker \

--enable-rewrite

2、启动

/application/bin/apachectl -t #语法检查

/application/bin/apachectl start #启动

3、测试

netstat -lntup|grep 80

image.png 

浏览器输入服务器地址:

CentOS7.3学习笔记总结(十九)_第1张图片