前言(本实验环境在centos7.9中完成)
安装步骤
安装apr
安装apr-util
安装apr-iconv
安装apache
启动apache
测试apache
MPM
一、安装依赖
yum install -y pcre-devel libxml2 expat-devel
二、apr介绍及安装
APR(Apache portable Run-time libraries,Apache可移植运行库)的目的如其名称一样,主要为上层的应用程序提供一个可以跨越多操作系统平台使用的底层支持接口库。在早期 的Apache版本中,应用程序本身必须能够处理各种具体操作系统平台的细节,并针对不同的平台调用不同的处理函数。
yum install -y wget
wget https://www.apache.org/dist/apr/apr-1.7.0.tar.bz2 --no-check-certificate
tar xvf apr-1.7.0.tar.bz2
cd apr-1.7.0
./configure --prefix=/usr/local/apr
make -j4 && make install
可能会出现的问题
rm: cannot remove 'libtoolT': No such file or directory
config.status: executing default commands
解决方法
yum install libtool -y
在configure里面把RM='$RM'改为RM='$RM -f',把 31880 $RM “$cfgfile” 那行删除掉
三、APR-util介绍及安装
apr-util该目录中也是包含了一些常用的开发组件。这些组件与apr目录下的相比,它们与apache的关系更加密切一些。比如存储段和存储段组,加密等等。
yum install -y expat-devel
wget https://www.apache.org/dist/apr/apr-util-1.6.1.tar.bz2 --no-check-certificate
tar xvf apr-util-1.6.1.tar.bz2
cd apr-util-1.6.1
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
make -j4 && make install
四、apr-iconv介绍及安装
wget https://www.apache.org/dist/apr/apr-iconv-1.2.2.tar.bz2 --no-check-certificate
tar xvf apr-iconv-1.2.2.tar.bz2
cd apr-iconv-1.2.2
./configure --prefix=/usr/local/apr-iconv --with-apr=/usr/local/apr
make -j4 && make install
五、apache安装
wget https://downloads.apache.org/httpd/httpd-2.4.54.tar.bz2 --no-check-certificate
tar xvf httpd-2.4.54.tar.bz2
cd httpd-2.4.54
./configure --prefix=/usr/local/apache --enable-mpms-shared=all --with-mpm=event --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-remoteip --enable-proxy --enable-proxy-fcgi --enable-proxy-uwsgi --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-cache --enable-file-cache --enable-mem-cache --enable-disk-cache --enable-static-support --enable-static-ab --disable-userdir --enable-nonportable-atomics --disable-ipv6 --with-sendfile
--prefix=/usr/local/apache 指定安装目录
--enable-mpms-shared=all --with-mpm=event 开启动态MPM切换
--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util 指定依赖包apr apr-util安装路径
--enable-so 打开 so 模块,so 模块是用来提 dso 支持的 apache 核心模块
--enable-remoteip 支持基于客户端IP做访问控制
--enable-proxy --enable-proxy-fcgi --enable-proxy-uwsgi 启用代理支持PHP Python网站
--enable-deflate=shared 开启压缩
--enable-expires=shared 开启客户端缓存
--enable-rewrite=shared 开启URL重写
--enable-cache --enable-file-cache --enable-mem-cache --enable-disk-cache 开启服务器缓存
--enable-static-support 支持静态连接
--enable-static-ab 使用静态连接编译 ab - apache http 服务器性能测试工具
--disable-userdir 禁用用户主目录提供页面访问
--enable-nonportable-atomics 对新式CPU支持,支持原子的比较交换(compare-and -swap, CAS)操作指令
--disable-ipv6 禁用IPV6
--with-sendfile 开启sendfile 0复制机制
make -j4 && make install
六、apache启动
/usr/local/apache/bin/apachectl -t 测试apeche配置文件是否有问题
出现以下报错:
AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, using fe80::20c:29ff:fe13:a151%ens33. Set the ‘ServerName’ directive globally to suppress this message
解决办法:
只需将/usr/local/apache/conf/httpd.conf中进行以下修改
可以看到
[root@centos7-server httpd-2.4.54]# /usr/local/apache/bin/apachectl -t
Syntax OK
七、apache状态测试
[root@centos7-server httpd-2.4.54]# yum search elinks
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
======================================== N/S matched: elinks ========================================
elinks.x86_64 : A text-mode Web browser
Name and summary matches only, use “search all” for everything.
[root@centos7-server httpd-2.4.54]# yum install elinks -y
[root@centos7-server httpd-2.4.54]# yum search killall
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
========================================= Matched: killall ==========================================
psmisc.x86_64 : Utilities for managing processes on your system
[root@centos7-server httpd-2.4.54]# yum install -y psmisc.x86_64
[root@centos7-server httpd-2.4.54]# /usr/local/apache/bin/apachectl
[root@centos7-server httpd-2.4.54]# elinks http://192.168.11.16 --dump
It works!
总结
如果要安装lamp的话,可以将默认虚拟主机文件开启
然后:killall httpd
之后重启httpd服务:/usr/local/apache/bin/apachectl