Apache-2.4.x源码安装
Apache-2.4.x源码安装
官方网站:
环境:
centos7
httpd-2.4
一.安装编译依赖库
yum -y install gcc gcc++ zlib zlib-devel
二.卸载自带httpd
for package in $(rpm -qa|grep httpd)
do
done
三.安装
1.apr
tar -xvf apr-1.5.2.tar.bz2 -C /usr/local/src
cd
/usr/local/src/apr-1.5.2
./configure --prefix=/opt/apache/apr && make -j4
&& make install
2.apr-util
tar -xvf apr-util-1.5.4.tar.bz2 -C /usr/local/src
cd /usr/local/src/apr-util-1.5.4
./configure --prefix=/opt/apache/apr-util
--with-apr=/opt/apache/apr && make -j4 && make
install
3.pcre
tar -xvf pcre-8.37.tar.bz2 -C /usr/local/src
cd /usr/local/src/pcre-8.37
./configure --prefix=/opt/apache/pcre && make -j4
&& make install
4.httpd
tar -xvf httpd-2.4.17.tar.bz2 -C /usr/local/src
cd /usr/local/src/httpd-2.4.17
./configure \
--prefix=/opt/apache/httpd \
--enable-rewrite \
--enable-so \
--enable-headers \
--enable-expires \
--enable-modules=most \
--enable-deflate \
--enable-rewrite=shared \
--enable-deflate=shared \
--enable-expires=shared \
--enable-static-support \
--with-mpm=worker
\
--with-apr=/opt/apache/apr \
--with-apr-util=/opt/apache/apr-util \
--with-pcre=/opt/apache/pcre
make -j4 && make install
四.配置
1.init脚本
a.httpd
cp /usr/local/src/httpd-2.4.17/build/rpm/httpd.init
/etc/init.d/httpd
chmod +x /etc/init.d/httpd
sed -i "/httpd=/i HTTPD=/opt/apache/httpd/bin/httpd"
/etc/init.d/httpd
sed -i
"/httpd=/i PIDFILE=/opt/apache/httpd/logs/httpd.pid"
/etc/init.d/httpd
sed -i "/CONFFILE=/ s#/etc/httpd#/opt/apache/httpd#g"
/etc/init.d/httpd
b.htcacheclean
cp /usr/local/src/httpd-2.4.17/build/rpm/htcacheclean.init
/etc/init.d/htcacheclean
chmod +x /etc/init.d/htcacheclean
sed -i "/htcacheclean=/i
HTTPD=/opt/apache/httpd/bin/htcacheclean" /etc/init.d/htcacheclean
sed -i "/htcacheclean=/i CACHEPATH=/opt/apache/httpd/cache-root"
/etc/init.d/htcacheclean
sed -i
"/^pidfile=/c pidfile=/opt/apache/httpd/logs/${prog}.pid"
/etc/init.d/htcacheclean
mkdir -p /opt/apache/httpd/cache-root
2.logrotate
cp /usr/local/src/httpd-2.4.17/build/rpm/httpd.logrotate
/etc/logrotate.d/
sed -i "1c /opt/apache/httpd/logs/*.log {"
/etc/logrotate.d/httpd.logrotate
五.启服务
chkconfig httpd on
chkconfig htcacheclean on
service httpd start
service htcacheclean start
补充:ubuntu14.04
apt-get -y install build-essential make openssl libgnutls-openssl27 libssl-dev
./configure --prefix=/opt/apache --with-mpm=worker --enable-mods-shared=all --enable-so --enable-most --enable-max
make -j2 && make install
echo /opt/apache/lib >> /etc/ld.so.conf
ldconfig
cp /opt/apache/bin/apachectl /etc/init.d/httpd
service httpd start
update-rc.d httpd defaults
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET制作智能桌面机器人:结合BotSharp智能体框架开发语音交互
· 软件产品开发中常见的10个问题及处理方法
· .NET 原生驾驭 AI 新基建实战系列:向量数据库的应用与畅想
· 从问题排查到源码分析:ActiveMQ消费端频繁日志刷屏的秘密
· 一次Java后端服务间歇性响应慢的问题排查记录
· 互联网不景气了那就玩玩嵌入式吧,用纯.NET开发并制作一个智能桌面机器人(四):结合BotSharp
· Vite CVE-2025-30208 安全漏洞
· 《HelloGitHub》第 108 期
· MQ 如何保证数据一致性?
· 一个基于 .NET 开源免费的异地组网和内网穿透工具