如何使用源码编译apache2.4
发表于:2025-12-02 作者:千家信息网编辑
千家信息网最后更新 2025年12月02日,如何使用源码编译apache2.4,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。[root@Jaking12 ~]# yum insta
千家信息网最后更新 2025年12月02日如何使用源码编译apache2.4
如何使用源码编译apache2.4,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。
[root@Jaking12 ~]# yum install -y gcc pcre pcre-devel expat-devel bzip2 openssl-devel zlib* libtool[root@Jaking12 src]# rz[root@Jaking12 src]# tar xvf apr-1.7.0.tar.gz[root@Jaking12 src]# lsapr-1.7.0 apr-1.7.0.tar.gz[root@Jaking12 src]# cd apr-1.7.0[root@Jaking12 apr-1.7.0]# ./configure --prefix=/usr/local/apr[root@Jaking12 apr-1.7.0]# make[root@Jaking12 apr-1.7.0]# make install[root@Jaking12 apr-1.7.0]# cd ..[root@Jaking12 src]# rzrz waiting to receive. zmodem trl+C ȡ 100% 541 KB 541 KB/s 00:00:01 0 Errors..[root@Jaking12 src]# lsapr-1.7.0 apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz[root@Jaking12 src]# tar xf apr-util-1.6.1.tar.gz [root@Jaking12 src]# lsapr-1.7.0 apr-1.7.0.tar.gz apr-util-1.6.1 apr-util-1.6.1.tar.gz[root@Jaking12 src]# cd apr-util-1.6.1[root@Jaking12 apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr[root@Jaking12 apr-util-1.6.1]# make[root@Jaking12 apr-util-1.6.1]# make install
更多的选项可以通过./configure --help 了解官方的编译选项文档http://httpd.apache.org/docs/current/programs/configure.html--prefix=/usr/local/apache --sysconfdir=/etc/httpd // 指定配置文件在安装在哪个路径。如不指定,配置文件就在程序安装的目录;如指定/etc目录--with-apr=/usr/local/apr // 指定依赖的apr路径。注意必须指明路径,否则编译时会自动去找/usr下的apr,而不是编译的高版本apr,下同--with-apr-util=/usr/local/apr-util --with-mpm=MPM //指定默认的 [prefork | worker | event] 如3种MPM模块都编译了,则通过此项指定默认使用哪种--with-pcre //依赖pcre库用于解决正则表达式问题。 ## 安装 pcre-devel(兼容Perl的正则表达式库)--enable-so //打开 so 模块,启用动态装载模块功能--enable-ssl //启用ssl功能。注意要先安装,https使用--enable-cgi //启用cgi功能,为非线程方式工作的mpm使用--enable-cgid //以线程工作(worker/event)的mpm使用--enable-rewrite //支持 URL 重写--enable-zlib //通用压缩机制--enable-module=most //[ all | most | ……] 指定启用哪些模块。可指定具体的模块名,也可使用all表示启用所有模块,most表示启用大多数常用模块。 一般使用most即可--enable-mpms-shared=all //启用MPM支持的模式,启用哪种mpm(prefork,worker,event),使用worker或event时要另外一种方式编译php(编译时使用了-enable-maintainer-zts选项)--enable-deflate //传输压缩机制,节约带宽提供对内容的压缩传输编码支持一般是html、js、css等内容的站点。使用此参数会大大 提高传输速度提升访问者访问的体验。在生产环境中这是apache调优的一个重要选项之一
[root@Jaking12 apr-util-1.6.1]# cd ..[root@Jaking12 src]# rzrz waiting to receive. zmodem trl+C ȡ 100% 8983 KB 8983 KB/s 00:00:01 0 Errors[root@Jaking12 src]# lsapr-1.7.0 apr-1.7.0.tar.gz apr-util-1.6.1 apr-util-1.6.1.tar.gz httpd-2.4.39.tar.gz[root@Jaking12 src]# tar xf httpd-2.4.39.tar.gz [root@Jaking12 src]# lsapr-1.7.0 apr-util-1.6.1 httpd-2.4.39apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.39.tar.gz[root@Jaking12 src]# cd httpd-2.4.39[root@Jaking12 httpd-2.4.39]# ./configure --prefix=/usr/local/apache24 --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-mods-shared=most --enable-mpms-shared=all --with-mpm=event[root@Jaking12 httpd-2.4.39]# make [root@Jaking12 httpd-2.4.39]# make install所有组件 /usr/local/apache24 主配置文件 /usr/local/apache24/conf 启动脚本 /usr/local/apache24/bin/apachectl[root@Jaking12 httpd-2.4.39]# ls /usr/local/apache24/bin build cgi-bin conf error htdocs icons include logs man manual modules[root@Jaking12 httpd-2.4.39]# ls /usr/local/apache24/conf/extra httpd.conf magic mime.types original[root@Jaking12 httpd-2.4.39]# ls /usr/local/apache24/bin/ab apxs dbmmanage envvars-std htcacheclean htdigest httpd logresolveapachectl checkgid envvars fcgistarter htdbm htpasswd httxt2dbm rotatelogs[root@Jaking12 httpd-2.4.39]# ll /usr/local/apache24/bin/apachectl -rwxr-xr-x 1 root dip 3440 Mar 10 16:45 /usr/local/apache24/bin/apachectl
启动 apache2.4
[root@Jaking12 httpd-2.4.39]# /usr/local/apache24/bin/apachectlAH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::250:56ff:fe2c:fe97%ens33. Set the 'ServerName' directive globally to suppress this message这是一个提示,问题不大 (⊙o⊙)…
重启 apache2.4
[root@Jaking12 httpd-2.4.39]# /usr/local/apache24/bin/apachectl graceful
查看 apache2.4 相关信息
[root@Jaking12 httpd-2.4.39]# netstat -pantul | grep 80tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 807/sshd tcp6 0 0 :::80 :::* LISTEN 35199/httpd tcp6 0 0 :::22 :::* LISTEN 807/sshd [root@Jaking12 httpd-2.4.39]# grep DocumentRoot /usr/local/apache24/conf/httpd.conf # DocumentRoot: The directory out of which you will serve yourDocumentRoot "/usr/local/apache24/htdocs" # access content that does not live under the DocumentRoot.[root@Jaking12 httpd-2.4.39]# ls /usr/local/apache24/htdocsindex.html[root@Jaking12 httpd-2.4.39]# cat /usr/local/apache24/htdocs/index.htmlIt works!

自定义首页内容
[root@Jaking12 httpd-2.4.39]# vim /usr/local/apache24/htdocs/index.htmlIt works!Hello World!
设置文件共享服务
[root@Jaking12 httpd-2.4.39]# cd /usr/local/apache24/htdocs/[root@Jaking12 htdocs]# lsindex.html[root@Jaking12 htdocs]# touch file{1..10}[root@Jaking12 htdocs]# lsfile1 file10 file2 file3 file4 file5 file6 file7 file8 file9 index.html[root@Jaking12 htdocs]# mv index.html index.html.bak[root@Jaking12 htdocs]# lsfile1 file10 file2 file3 file4 file5 file6 file7 file8 file9 index.html.bak至此,实战演示源码编译 apache2.4完毕。
看完上述内容,你们掌握如何使用源码编译apache2.4的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注行业资讯频道,感谢各位的阅读!
编译
模块
内容
文件
问题
源码
功能
更多
路径
传输
支持
配置
方式
方法
机制
正则
目录
线程
表达式
这是
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
柳州网络安全it培训待遇好
网络安全服务验收方案
沈阳升腾服务器厂商
计算机网络技术求职专业
手机软件开发青岗科技
网络技术对校园的影响
河南软件开发哪家便宜
数据库建表实验
数据库连接程序
软件开发工程师mta证书
网络安全法规定生
r 找出数据库
地理信息系统非定位数据库
vs数据库连接项目
python 网络安全前景
药店配送网络技术
社交软件开发那些事儿
提供网络安全服务用英语怎么说
中小学网络安全教育事例
车载网络技术课程标准
杭州随笔记网络技术有限公司上市
数据库技术怎么停止运行
河北特定软件开发操作
电商的软件开发员
服务器机柜防护视频
我的世界保护数据库
上海库存网络技术销售公司
视频转化软件开发
数据库开发技术面试题
成华区源的网络技术工作室