如何通过源码编译的方式安装apache2.4

Apache HTTP Server(简称Apache)是Apache软件基金会的一个开放源码的网页服务器,可以在大多数计算机操作系统中运行,由于其多平台和安全性被广泛使用,是最流行的Web服务器端软件之一,下面为大家分享一下如何通过源码编译的方式安装apache2.4。

本文档使用的源码包地址 链接:https://pan.baidu.com/s/110RWf3VC8J3oJhgYq5jU2w 提取码:pdc0

实战

[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]# ls
apr-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]# rz
rz waiting to receive.
zmodem trl+C ȡ

 100%     541 KB  541 KB/s 00:00:01       0 Errors..

[root@Jaking12 src]# ls
apr-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]# ls
apr-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]# rz
rz waiting to receive.
zmodem trl+C ȡ

 100%    8983 KB 8983 KB/s 00:00:01       0 Errors

[root@Jaking12 src]# ls
apr-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]# ls
apr-1.7.0         apr-util-1.6.1         httpd-2.4.39
apr-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      logresolve
apachectl  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/apachectl
AH00558: 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 80
tcp        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 your
DocumentRoot "/usr/local/apache24/htdocs"
   # access content that does not live under the DocumentRoot.
[root@Jaking12 httpd-2.4.39]# ls /usr/local/apache24/htdocs
index.html
[root@Jaking12 httpd-2.4.39]# cat /usr/local/apache24/htdocs/index.html
It works!

源码编译 apache2.4源码编译 apache2.4

自定义首页内容

[root@Jaking12 httpd-2.4.39]# vim /usr/local/apache24/htdocs/index.html
It works!
Hello World!

源码编译 apache2.4源码编译 apache2.4

设置文件共享服务

[root@Jaking12 httpd-2.4.39]# cd /usr/local/apache24/htdocs/
[root@Jaking12 htdocs]# ls
index.html
[root@Jaking12 htdocs]# touch file{1..10}
[root@Jaking12 htdocs]# ls
file1  file10  file2  file3  file4  file5  file6  file7  file8  file9  index.html
[root@Jaking12 htdocs]# mv index.html index.html.bak
[root@Jaking12 htdocs]# ls
file1  file10  file2  file3  file4  file5  file6  file7  file8  file9  index.html.bak

源码编译 apache2.4源码编译 apache2.4

总结

至此,实战演示源码编译 apache2.4完毕。

文章来源网络,作者:运维,如若转载,请注明出处:https://shuyeidc.com/wp/220141.html<

(0)
运维的头像运维
上一篇2025-04-14 10:40
下一篇 2025-04-14 10:41

相关推荐

  • 个人主题怎么制作?

    制作个人主题是一个将个人风格、兴趣或专业领域转化为视觉化或结构化内容的过程,无论是用于个人博客、作品集、社交媒体账号还是品牌形象,核心都是围绕“个人特色”展开,以下从定位、内容规划、视觉设计、技术实现四个维度,详细拆解制作个人主题的完整流程,明确主题定位:找到个人特色的核心主题定位是所有工作的起点,需要先回答……

    2025-11-20
    0
  • 社群营销管理关键是什么?

    社群营销的核心在于通过建立有温度、有价值、有归属感的社群,实现用户留存、转化和品牌传播,其管理需贯穿“目标定位-内容运营-用户互动-数据驱动-风险控制”全流程,以下从五个维度展开详细说明:明确社群定位与目标社群管理的首要任务是精准定位,需明确社群的核心价值(如行业交流、产品使用指导、兴趣分享等)、目标用户画像……

    2025-11-20
    0
  • 香港公司网站备案需要什么材料?

    香港公司进行网站备案是一个涉及多部门协调、流程相对严谨的过程,尤其需兼顾中国内地与香港两地的监管要求,由于香港公司注册地与中国内地不同,其网站若主要服务内地用户或使用内地服务器,需根据服务器位置、网站内容性质等,选择对应的备案路径(如工信部ICP备案或公安备案),以下从备案主体资格、流程步骤、材料准备、注意事项……

    2025-11-20
    0
  • 如何企业上云推广

    企业上云已成为数字化转型的核心战略,但推广过程中需结合行业特性、企业痛点与市场需求,构建系统性、多维度的推广体系,以下从市场定位、策略设计、执行落地及效果优化四个维度,详细拆解企业上云推广的实践路径,精准定位:明确目标企业与核心价值企业上云并非“一刀切”的方案,需先锁定目标客户群体,提炼差异化价值主张,客户分层……

    2025-11-20
    0
  • PS设计搜索框的实用技巧有哪些?

    在PS中设计一个美观且功能性的搜索框需要结合创意构思、视觉设计和用户体验考量,以下从设计思路、制作步骤、细节优化及交互预览等方面详细说明,帮助打造符合需求的搜索框,设计前的规划明确使用场景:根据网站或APP的整体风格确定搜索框的调性,例如极简风适合细线条和纯色,科技感适合渐变和发光效果,电商类则可能需要突出搜索……

    2025-11-20
    0

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注