您的位置:首页 > 服务器 > linux教程

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

作者:自由哥 来源:建站技术网

2022-11-22 08:51:14

目录
  • 源码包编译实例
    • 下载编译工具,httpd以及其两个依赖包的源码包
    • 安装apr
    • 安装apr-util
    • 安装httpd
    • 源码编译报错信息处理
  • init程序的三种风格
    • init程序三种风格的特点

      源码包编译实例

      下面通过编译安装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]# lsapr-1.7.0.tar.gz  apr-util-1.6.1.tar.gz  httpd-2.4.54.tar.gz

      安装apr

      [root@lnh xbz]# lsapr-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]# lsapr-config.in  build-outputs.mk  helpers       misc           stringsapr.dep        CHANGES           include       mmap           supportapr.dsp        CMakeLists.txt    libapr.dep    network_io     tablesapr.dsw        config.layout     libapr.dsp    NOTICE         testapr.mak        configure         libapr.mak    NWGNUmakefile  threadprocapr.pc.in      configure.in      libapr.rc     passwd         timeapr.spec       docs              LICENSE       poll           toolsatomic         dso               locks         random         userbuild          emacs-mode        Makefile.in   READMEbuild.conf     encoding          Makefile.win  README.cmakebuildconf      file_io           memory        shmem//进入这个源码包可以看见里面被解压出来的东西[root@lnh apr-1.7.0]# ./configure --prefix=/usr/local/src/apr...configure: creating ./config.statusconfig.status: creating Makefileconfig.status: creating include/apr.hconfig.status: creating build/apr_rules.mkconfig.status: creating build/pkg/pkginfoconfig.status: creating apr-1-configconfig.status: creating apr.pcconfig.status: creating test/Makefileconfig.status: creating test/internal/Makefileconfig.status: creating include/arch/unix/apr_private.hconfig.status: executing libtool commandsrm: cannot remove 'libtoolT': No such file or directoryconfig.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.expsed 's,^/(location=/).*$,/1installed,' < apr-1-config > apr-config.outsed -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.outmake[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-1for 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]# lsbin  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 4drwxr-xr-x. 2 root root 4096 Jul 12 20:18 apr-1lrwxrwxrwx. 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]# lsapr-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]# lsapr-1.7.0         apr-util-1.6.1         httpd-2.4.54.tar.gzapr-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]# lsaprutil.dep       CHANGES            include         NWGNUmakefileaprutil.dsp       CMakeLists.txt     ldap            READMEaprutil.dsw       config.layout      libaprutil.dep  README.cmakeaprutil.mak       configure          libaprutil.dsp  README.FREETDSapr-util.pc.in    configure.in       libaprutil.mak  redisapr-util.spec     crypto             libaprutil.rc   renames_pendingapu-config.in     dbd                LICENSE         strmatchbuckets           dbm                Makefile.in     testbuild             docs               Makefile.win    uribuild.conf        encoding           memcache        xlatebuildconf         export_vars.sh.in  misc            xmlbuild-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.statusconfig.status: creating Makefileconfig.status: creating export_vars.shconfig.status: creating build/pkg/pkginfoconfig.status: creating apr-util.pcconfig.status: creating apu-1-configconfig.status: creating include/private/apu_select_dbm.hconfig.status: creating include/apr_ldap.hconfig.status: creating include/apu.hconfig.status: creating include/apu_want.hconfig.status: creating test/Makefileconfig.status: creating include/private/apu_config.hconfig.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.expgcc -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.expsed 's,^/(location=/).*$,/1installed,' < apu-1-config > apu-config.outmake[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 formore 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]# lsbin  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]# lsapr-1.7.0         apr-util-1.6.1         httpd-2.4.54apr-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]# lsABOUT_APACHE     CMakeLists.txt  InstallBin.dsp  READMEacinclude.m4     config.layout   LAYOUT          README.CHANGESApache-apr2.dsw  configure       libhttpd.dep    README.cmakeApache.dsw       configure.in    libhttpd.dsp    README.platformsapache_probes.d  docs            libhttpd.mak    ROADMAPap.d             emacs-style     LICENSE         serverbuild            httpd.dep       Makefile.in     srclibBuildAll.dsp     httpd.dsp       Makefile.win    supportBuildBin.dsp     httpd.mak       modules         testbuildconf        httpd.spec      NOTICE          VERSIONINGCHANGES          include         NWGNUmakefilechanges-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.shconfig.status: creating include/ap_config_auto.hconfig.status: executing default commandsconfigure: 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 manualmkdir /usr/local/src/httpd/manmkdir /usr/local/src/httpd/man/man1mkdir /usr/local/src/httpd/man/man8mkdir /usr/local/src/httpd/manualmake[1]: Leaving directory '/root/xbz/httpd-2.4.54'//进行安装[root@lnh httpd-2.4.54]# cd /usr/local/src/httpd/[root@lnh httpd]# lsbin    cgi-bin  error   icons    logs  manualbuild  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/httpdlrwxrwxrwx. 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.confMANDATORY_MANPATH                 /usr/manMANDATORY_MANPATH                 /usr/share/manMANDATORY_MANPATH                 /usr/local/share/manMANDATORY_MANPATH                 /usr/local/src/httpd/man//添加后面这一行[root@lnh ~]# httpdAH00558: 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 messagehttpd (pid 35719) already running//启动服务[root@lnh ~]# ss -antlState   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端口

      源码编译报错信息处理

      checking for APR... noconfigure: 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

      猜你喜欢

      一、自动化部署git项目#!/bin/bash # 清除项目进程和历史文件pkill -f start.pysleep 1cd /root/automation |rm -rf testProduce/ # 获取项目最新git代码(前提服务

      2022-11-22 08:51:17

      目录源码包编译实例下载编译工具,httpd以及其两个依赖包的源码包安装apr安装apr-util安装httpd源码编译报错信息处理init程序的三种风格init程序三种风格的特点源码

      2022-11-22 08:51:14

      目录背景注意(重点)步骤1、安装jdk2、安装配置mysql5.73、安装SonarQube4、配置数据库和SonarQube5、安装中文语音包背景最近公司技术大佬同事告知,sonarlint可以

      2022-11-22 08:51:14

      目录配置发送端:从server发送到syslog配置接收端:配置协议,端口号,接收条件,存储位置取消注释如下代码:接收条件配置创建日志接收模板结语配置发送端:从serv

      2022-11-22 08:51:11

      目录一、基于IP二、基于主机名三、基于端口记事本打开httpd.conf文件 ,该文件在apache的目录下,如: D:/AppServ/Apache2.2/conf,修改如下两处:LoadModule vhos

      2022-11-22 08:51:11

      目录Apache Bench 简介ab的原理ab的安装参数介绍ab测试案例示例2Apache Bench 简介Apache Bench 是 Apache 服务器自带的一个web压力测试工具,简称 ab 。ab 非常实

      2022-11-22 08:51:06

      目录1.当从一个远程服务器传输文件到另一个服务器上(你想传给别人文件)2.在本地服务器,从另一个服务器中获取文件(你想从别人获取文件)scp是secure copy的简写, 是

      2022-11-22 08:51:06

      目录nmap工具检测开放端口Nmap的扫描参数telnet查看端口是否开放curl查看链接端口是否开放nc(netcat)命令来查看远程 Linux 系统中某个端口是否开启netstat 工具查

      2022-11-22 08:51:00

      由于我将xshell更新到了Xshell v5.0 Build 1332,使得我在连接阿里云服务器的时候遇到了一些问题。原来我登录到服务器的时候直接输入登录密码就行了,但是现在由于

      2022-11-22 08:51:00

      目录一:关于ping的问题1.虚拟机ping百度2.windows下ping linux的ip地址3.linux下ping windows二:防火墙的问题三:ssh服务四:VM中的还原默认设置还原后的更改设置五

      2022-11-22 08:50:57

      © 2007-2021 建站技术网版权所有联系QQ:2140427459