详解apache编译安装httpd-2.4.54及三种风格的init程序特点和区别


Posted in Servers onJuly 15, 2022

源码包编译实例

下面通过编译安装httpd来深入理解源码包安装(httpd-2.4.54)

下载编译工具,httpd以及其两个依赖包的源码包

//源码包建议到官方网站下载

[root@lnh ~]# mkdir xbz
[root@lnh ~]# cd xbz/
[root@lnh xbz]# dnf -y install gcc gcc-c++ make wget
[root@lnh xbz]# wget https://mirrors.aliyun.com/apache/httpd/httpd-2.4.54.tar.gz
[root@lnh xbz]# wget https://mirrors.aliyun.com/apache/apr/apr-1.7.0.tar.gz
[root@lnh xbz]# wget https://mirrors.aliyun.com/apache/apr/apr-util-1.6.1.tar.gz
[root@lnh xbz]# ls
apr-1.7.0.tar.gz  apr-util-1.6.1.tar.gz  httpd-2.4.54.tar.gz

安装apr

[root@lnh xbz]# ls
apr-1.7.0.tar.gz  apr-util-1.6.1.tar.gz  httpd-2.4.54.tar.gz
[root@lnh xbz]# tar -xf apr-1.7.0.tar.gz 
[root@lnh xbz]# ls 
apr-1.7.0  apr-1.7.0.tar.gz  apr-util-1.6.1.tar.gz  httpd-2.4.54.tar.gz
//将apr解压到当前目录
[root@lnh xbz]# cd apr-1.7.0/
[root@lnh apr-1.7.0]# ls
apr-config.in  build-outputs.mk  helpers       misc           strings
apr.dep        CHANGES           include       mmap           support
apr.dsp        CMakeLists.txt    libapr.dep    network_io     tables
apr.dsw        config.layout     libapr.dsp    NOTICE         test
apr.mak        configure         libapr.mak    NWGNUmakefile  threadproc
apr.pc.in      configure.in      libapr.rc     passwd         time
apr.spec       docs              LICENSE       poll           tools
atomic         dso               locks         random         user
build          emacs-mode        Makefile.in   README
build.conf     encoding          Makefile.win  README.cmake
buildconf      file_io           memory        shmem
//进入这个源码包可以看见里面被解压出来的东西
[root@lnh apr-1.7.0]# ./configure --prefix=/usr/local/src/apr
...
configure: creating ./config.status
config.status: creating Makefile
config.status: creating include/apr.h
config.status: creating build/apr_rules.mk
config.status: creating build/pkg/pkginfo
config.status: creating apr-1-config
config.status: creating apr.pc
config.status: creating test/Makefile
config.status: creating test/internal/Makefile
config.status: creating include/arch/unix/apr_private.h
config.status: executing libtool commands
rm: cannot remove 'libtoolT': No such file or directory
config.status: executing default commands
//生成Makefile
一般常用的有 --prefix=PREFIX 这个选项的意思是定义软件包安装到哪里
建议,源码包都是安装在/opt/目录下或者/usr/local/src目录下面
[root@lnh apr-1.7.0]# make
...
gcc -E -DHAVE_CONFIG_H  -DLINUX -D_REENTRANT -D_GNU_SOURCE   -I./include -I/root/xbz/apr-1.7.0/include/arch/unix -I./include/arch/unix -I/root/xbz/apr-1.7.0/include/arch/unix -I/root/xbz/apr-1.7.0/include -I/root/xbz/apr-1.7.0/include/private -I/root/xbz/apr-1.7.0/include/private  export_vars.c | sed -e 's/^\#[^!]*//' | sed -e '/^$/d' >> apr.exp
sed 's,^\(location=\).*$,\1installed,' < apr-1-config > apr-config.out
sed -e 's,^\(apr_build.*=\).*$,\1/usr/local/src/apr/build-1,' -e 's,^\(top_build.*=\).*$,\1/usr/local/src/apr/build-1,' < build/apr_rules.mk > build/apr_rules.out
make[1]: Leaving directory '/root/xbz/apr-1.7.0'
//编译生成Makefile,此处虽然出现了make[1]: Leaving directory '/root/xbz/apr-1.7.0',但是没关系可以继续进行下一步安装
[root@lnh apr-1.7.0]# make install
...
/usr/bin/install -c -m 755 /root/xbz/apr-1.7.0/build/mkdir.sh /usr/local/src/apr/build-1
for f in make_exports.awk make_var_export.awk; do \
    /usr/bin/install -c -m 644 /root/xbz/apr-1.7.0/build/${f} /usr/local/src/apr/build-1; \
done
/usr/bin/install -c -m 644 build/apr_rules.out /usr/local/src/apr/build-1/apr_rules.mk
/usr/bin/install -c -m 755 apr-config.out /usr/local/src/apr/bin/apr-1-config
//进行安装
[root@lnh apr-1.7.0]# cd /usr/local/src/apr/
[root@lnh apr]# ls
bin  build-1  include  lib
//进入apr的路径进行查看,默认情况下,系统搜索库文件的路径只有/lib,/usr/lib,我们需要进行修改在/etc/ld.so.conf.d/中创建以.conf为后缀名的文件,而后把要增添的路径直接写至此文件中。此时库文件增添的搜索路径重启后有效,若要使用增添的路径立即生效则要使用ldconfig命令
[root@lnh apr]# cd /etc/ld.so.conf.d/
[root@lnh ld.so.conf.d]# echo /usr/local/src/apr/lib/ >apr.conf
[root@lnh ld.so.conf.d]# cd -
/usr/local/src/apr
//切换到前一个工作目录
[root@lnh apr]# ldconfig 
//使命令生效
[root@lnh apr]# ln -s /usr/local/src/apr/include/ /usr/include/apr
[root@lnh apr]# ll /usr/include/apr/
total 4
drwxr-xr-x. 2 root root 4096 Jul 12 20:18 apr-1
lrwxrwxrwx. 1 root root   27 Jul 12 20:44 include -> /usr/local/src/apr/include/
将头文件软链接到/usr/include目录下

折叠

安装apr-util

[root@lnh xbz]# dnf -y install expat-devel libxml2-devel pcre-devel
//需要先安装这个依赖
[root@lnh xbz]# ls
apr-1.7.0  apr-1.7.0.tar.gz  apr-util-1.6.1.tar.gz  httpd-2.4.54.tar.gz
[root@lnh xbz]# tar -xf apr-util-1.6.1.tar.gz 
[root@lnh xbz]# ls
apr-1.7.0         apr-util-1.6.1         httpd-2.4.54.tar.gz
apr-1.7.0.tar.gz  apr-util-1.6.1.tar.gz
//解压到当前目录
[root@lnh xbz]# cd apr-util-1.6.1/
[root@lnh apr-util-1.6.1]# ls
aprutil.dep       CHANGES            include         NWGNUmakefile
aprutil.dsp       CMakeLists.txt     ldap            README
aprutil.dsw       config.layout      libaprutil.dep  README.cmake
aprutil.mak       configure          libaprutil.dsp  README.FREETDS
apr-util.pc.in    configure.in       libaprutil.mak  redis
apr-util.spec     crypto             libaprutil.rc   renames_pending
apu-config.in     dbd                LICENSE         strmatch
buckets           dbm                Makefile.in     test
build             docs               Makefile.win    uri
build.conf        encoding           memcache        xlate
buildconf         export_vars.sh.in  misc            xml
build-outputs.mk  hooks              NOTICE
//进入源码包查看被解压出来的东西
[root@lnh apr-util-1.6.1]# ./configure --prefix=/usr/local/src/apr-util --with-apr=/usr/local/src/apr
...
configure: creating ./config.status
config.status: creating Makefile
config.status: creating export_vars.sh
config.status: creating build/pkg/pkginfo
config.status: creating apr-util.pc
config.status: creating apu-1-config
config.status: creating include/private/apu_select_dbm.h
config.status: creating include/apr_ldap.h
config.status: creating include/apu.h
config.status: creating include/apu_want.h
config.status: creating test/Makefile
config.status: creating include/private/apu_config.h
config.status: executing default commands
//生成Makefile文件,需要伴随着上一个指定的依赖
[root@lnh apr-util-1.6.1]# make
...
gcc -E -DHAVE_CONFIG_H  -DLINUX -D_REENTRANT -D_GNU_SOURCE   -I/root/xbz/apr-util-1.6.1/include -I/root/xbz/apr-util-1.6.1/include/private  -I/usr/local/src/apr/include/apr-1    exports.c | grep "ap_hack_" | sed -e 's/^.*[)]\(.*\);$/\1/' >> aprutil.exp
gcc -E -DHAVE_CONFIG_H  -DLINUX -D_REENTRANT -D_GNU_SOURCE   -I/root/xbz/apr-util-1.6.1/include -I/root/xbz/apr-util-1.6.1/include/private  -I/usr/local/src/apr/include/apr-1    export_vars.c | sed -e 's/^\#[^!]*//' | sed -e '/^$/d' >> aprutil.exp
sed 's,^\(location=\).*$,\1installed,' < apu-1-config > apu-config.out
make[1]: Leaving directory '/root/xbz/apr-util-1.6.1'
//编译生成的Makefile文件,出现make[1]: Leaving directory '/root/xbz/apr-util-1.6.1'这个没有关系可以继续进行下一步安装
[root@lnh apr-util-1.6.1]# make install
...
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
/usr/bin/install -c -m 644 aprutil.exp /usr/local/src/apr-util/lib
/usr/bin/install -c -m 755 apu-config.out /usr/local/src/apr-util/bin/apu-1-config
//进行安装
[root@lnh apr-util-1.6.1]# cd /usr/local/src/apr-util/
[root@lnh apr-util]# ls
bin  include  lib
//切换到apr-util安装目录进行查看,默认情况下,系统搜索库文件的路径只有/lib,/usr/lib,我们需要进行修改在/etc/ld.so.conf.d/中创建以.conf为后缀名的文件,而后把要增添的路径直接写至此文件中。此时库文件增添的搜索路径重启后有效,若要使用增添的路径立即生效则要使用ldconfig命令
[root@lnh apr-util]# cd /etc/ld.so.conf.d/
[root@lnh ld.so.conf.d]# echo /usr/local/src/apr-util/ >apr-util.conf 
[root@lnh ld.so.conf.d]# cd -
/usr/local/src/apr-util
//切换到上一个工作目录
[root@lnh apr-util]# ln -s /usr/local/src/apr-util/include/ /usr/include/apr
-util
//将头文件软链接到/usr/include目录下

折叠

安装httpd

[root@lnh xbz]# tar -xf httpd-2.4.54.tar.gz 
[root@lnh xbz]# ls
apr-1.7.0         apr-util-1.6.1         httpd-2.4.54
apr-1.7.0.tar.gz  apr-util-1.6.1.tar.gz  httpd-2.4.54.tar.gz
//解压到当前目录
[root@lnh xbz]# cd httpd-2.4.54/
[root@lnh httpd-2.4.54]# ls
ABOUT_APACHE     CMakeLists.txt  InstallBin.dsp  README
acinclude.m4     config.layout   LAYOUT          README.CHANGES
Apache-apr2.dsw  configure       libhttpd.dep    README.cmake
Apache.dsw       configure.in    libhttpd.dsp    README.platforms
apache_probes.d  docs            libhttpd.mak    ROADMAP
ap.d             emacs-style     LICENSE         server
build            httpd.dep       Makefile.in     srclib
BuildAll.dsp     httpd.dsp       Makefile.win    support
BuildBin.dsp     httpd.mak       modules         test
buildconf        httpd.spec      NOTICE          VERSIONING
CHANGES          include         NWGNUmakefile
changes-entries  INSTALL         os
//查看被解压出来的东西
[root@lnh httpd-2.4.54]# ./configure --prefix=/usr/local/src/httpd --with-apr=/usr/local/src/apr --with-apr-util=/usr/local/src/apr-util
...
config.status: creating build/config_vars.sh
config.status: creating include/ap_config_auto.h
config.status: executing default commands
configure: summary of build options:

    Server Version: 2.4.54
    Install prefix: /usr/local/src/httpd
    C compiler:     gcc
    CFLAGS:          -g -O2 -pthread  
    CPPFLAGS:        -DLINUX -D_REENTRANT -D_GNU_SOURCE  
    LDFLAGS:           
    LIBS:             
    C preprocessor: gcc -E

//生成Makefile文件
[root@lnh httpd-2.4.54]# make
...
/usr/local/src/apr/build-1/libtool --silent --mode=link gcc  -g -O2 -pthread           -o mod_rewrite.la -rpath /usr/local/src/httpd/modules -module -avoid-version  mod_rewrite.lo 
make[4]: Leaving directory '/root/xbz/httpd-2.4.54/modules/mappers'
make[3]: Leaving directory '/root/xbz/httpd-2.4.54/modules/mappers'
make[2]: Leaving directory '/root/xbz/httpd-2.4.54/modules'
make[2]: Entering directory '/root/xbz/httpd-2.4.54/support'
make[2]: Leaving directory '/root/xbz/httpd-2.4.54/support'

make[1]: Leaving directory '/root/xbz/httpd-2.4.54'
//编译生成Makefile文件,出现的一些没有读取到的问题没有关系,继续进行下一步
[root@lnh httpd-2.4.54]# make install
...
Installing man pages and online manual
mkdir /usr/local/src/httpd/man
mkdir /usr/local/src/httpd/man/man1
mkdir /usr/local/src/httpd/man/man8
mkdir /usr/local/src/httpd/manual
make[1]: Leaving directory '/root/xbz/httpd-2.4.54'
//进行安装
[root@lnh httpd-2.4.54]# cd /usr/local/src/httpd/
[root@lnh httpd]# ls
bin    cgi-bin  error   icons    logs  manual
build  conf     htdocs  include  man   modules
//切换到httpd的安装目录进行查看,默认情况下,系统搜索库文件的路径只有/lib,/usr/lib
[root@lnh httpd]# ln -s /usr/local/src/httpd/include/ /usr/include/httpd
[root@lnh httpd]# ll  /usr/include/httpd
lrwxrwxrwx. 1 root root 29 Jul 12 21:23 /usr/include/httpd -> /usr/local/src/httpd/include/
//将头文件软链接到/usr/include目录下
[root@lnh httpd]# echo "export PATH=$PATH:/usr/local/src/httpd/bin" > /etc/profile.d/httpd.sh
[root@lnh httpd]# source /etc/profile.d/httpd.sh 
//配置httpd的全局环境变量,并生成效果
[root@lnh httpd]# which httpd 
/usr/local/src/httpd/bin/httpd
[root@lnh httpd]# vim /etc/man_db.conf
MANDATORY_MANPATH                 /usr/man
MANDATORY_MANPATH                 /usr/share/man
MANDATORY_MANPATH                 /usr/local/share/man
MANDATORY_MANPATH                 /usr/local/src/httpd/man
//添加后面这一行
[root@lnh ~]# httpd
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:fe57:f6f5%ens33. Set the 'ServerName' directive globally to suppress this message
httpd (pid 35719) already running
//启动服务
[root@lnh ~]# ss -antl
State   Recv-Q  Send-Q   Local Address:Port     Peer Address:Port  Process  
LISTEN  0       128            0.0.0.0:22            0.0.0.0:*              
LISTEN  0       128                  *:80                  *:*              
LISTEN  0       128               [::]:22               [::]:*
//查看端口              
[root@lnh ~]# systemctl stop firewalld.service
//关闭防火墙

折叠

服务80端口

详解apache编译安装httpd-2.4.54及三种风格的init程序特点和区别

源码编译报错信息处理

checking for APR... no
configure: error: APR not found.  Please read the documentation.
//解决方案
[root@lnh xbz]# wget https://mirrors.aliyun.com/apache/apr/apr-1.7.0.tar.gz
[root@lnh xbz]# wget https://mirrors.aliyun.com/apache/apr/apr-util-1.6.1.tar.gz
提前把这两个依赖包安装好才可以进行生成Makefile文件

无法进行生成两个依赖包的Makefile文件
//解决方案
[root@lnh xbz]# dnf -y install gcc gcc-c++ make wget
提前下载编译工具

init程序的三种风格

  • SysV⻛格:init(centos5),实现系统初始化时,随后的初始化操作都是借助于脚本来实现的,(/etc/inittab)
  • Upstart风格:init(centos6),由ubuntu研发的,通过总线形式以接近于并行的方式工作,效率比SysV高,配置文件(/etc/inittab,/etc/init/*.conf)
  • Systemd风格:systemd(centos7),启动速度快,系统引导时实现服务并行启动,比前两者的效率都高,配置文件(/usr/lib/systemd/system,/etc/systemd/system)

init程序三种风格的特点

SysV⻛格特点:

  • 脚本中含有大量的命令,每个命令都要启动一个进程,命令执行完以后就要终止这个进程。如此一来,系统初始化时将大量的创建进程,销毁进程,工作效率会非常低
  • 服务间可能会存在依赖关系,必须严格按照一定的顺序来启动服务,前一个服务没启动完后面的服务就无法执行启动过程。不能并行进行

Upstart风格特点:

  • 基于总线方式能够让进程间互相通信的一个应用程序
  • 不用等服务启动完成,只要一初始化就可以把自己的状态返回给其他进程

Systemd风格特点:

  • 启动速度比SysV和Upstart都快
  • 不需要通过任何脚本来启动服务,systemd自身就可以启动服务,其本身就是一个强大的解释器,启动服务时不需要sh/bash的参与
  • systemd不真正在系统初始化时去启动任何一个服务只要服务没用到,它告诉你启动了,实际上并没有启动。仅当第一次去访问时才会真正启动服务

到此这篇关于apache编译安装httpd-2.4.54以及三种风格的init程序特点和区别的文章就介绍到这了,更多相关apache编译安装httpd-2.4.54内容请搜索三水点靠木以前的文章或继续浏览下面的相关文章希望大家以后多多支持三水点靠木!


Tags in this post...

Servers 相关文章推荐
Nginx 负载均衡是什么以及该如何配置
Mar 31 Servers
详解nginx location指令
Jan 18 Servers
nginx中封禁ip和允许内网ip访问的实现示例
Mar 17 Servers
tomcat的catalina.out日志按自定义时间格式进行分割的操作方法
Apr 02 Servers
CentOS下安装Jenkins的完整步骤
Apr 07 Servers
Windows Server 2016 配置 IIS 的详细步骤
Apr 28 Servers
Windows Server 2008 修改远程登录端口以及配置防火墙
Apr 28 Servers
解决IIS7下无法绑定https主机的问题
Apr 29 Servers
使用Nginx+Tomcat实现负载均衡的全过程
May 30 Servers
永中文档在线转换预览基于nginx配置部署方案
Jun 10 Servers
nginx之内存池的实现
Jun 28 Servers
Shell中的单中括号和双中括号的用法详解
Dec 24 Servers
Apache Kafka 分区重分配的实现原理解析
zabbix 代理服务器的部署与 zabbix-snmp 监控问题
Jul 15 #Servers
Nginx代理Redis哨兵主从配置的实现
Jul 15 #Servers
Nginx文件已经存在全局反向代理问题排查记录
Jul 15 #Servers
搭建zabbix监控以及邮件报警的超级详细教学
Jul 15 #Servers
nginx七层负载均衡配置详解
Jul 15 #Servers
Linux安装Docker详细教程
Jul 07 #Servers
You might like
从零开始学YII2框架(一)通过Composer安装Yii2框架
2014/08/20 PHP
php中fsockopen用法实例
2015/01/05 PHP
laravel安装zend opcache加速器教程
2015/03/02 PHP
利用PHP fsockopen 模拟POST/GET传送数据的方法
2015/09/22 PHP
深入解析WordPress中加载模板的get_template_part函数
2016/01/11 PHP
php redis实现文章发布系统(用户投票系统)
2017/03/04 PHP
Javascript的一种模块模式
2010/09/08 Javascript
动态添加option及createElement使用示例
2014/01/26 Javascript
详解JavaScript设计模式开发中的桥接模式使用
2016/05/18 Javascript
HTML5开发Kinect体感游戏的实例应用
2017/09/18 Javascript
ES6 javascript中class静态方法、属性与实例属性用法示例
2017/10/30 Javascript
angularjs数组判断是否含有某个元素的实例
2018/02/27 Javascript
json对象及数组键值的深度大小写转换问题详解
2018/03/30 Javascript
微信小程序 腾讯地图SDK 获取当前地址实现解析
2019/08/12 Javascript
vscode中eslint插件的配置(prettier配置无效)
2019/09/10 Javascript
[02:20]DOTA2中文配音宣传片
2013/05/22 DOTA
Python实现模拟时钟代码推荐
2015/11/08 Python
pandas表连接 索引上的合并方法
2018/06/08 Python
Python设计模式之外观模式实例详解
2019/01/17 Python
numpy下的flatten()函数用法详解
2019/05/27 Python
Django 接收Post请求数据,并保存到数据库的实现方法
2019/07/12 Python
Python符号计算之实现函数极限的方法
2019/07/15 Python
Python @property装饰器原理解析
2020/01/22 Python
Tensorflow 使用pb文件保存(恢复)模型计算图和参数实例详解
2020/02/11 Python
Tensorflow 模型转换 .pb convert to .lite实例
2020/02/12 Python
Python中import导入不同目录的模块方法详解
2020/02/18 Python
Python列表倒序输出及其效率详解
2020/03/04 Python
Python带参数的装饰器运行原理解析
2020/06/09 Python
浅谈css3中calc在less编译时被计算的解决办法
2017/12/04 HTML / CSS
深入剖析HTML5 内联框架iFrame
2016/05/04 HTML / CSS
十佳青年个人事迹材料
2014/01/28 职场文书
文秘班元旦晚会活动策划方案
2014/08/28 职场文书
在教室放鞭炮的检讨书
2014/09/28 职场文书
食堂管理制度范本
2015/08/04 职场文书
2016学校元旦晚会经典开场白台词
2015/12/03 职场文书
ant design vue的form表单取值方法
2022/06/01 Vue.js