• CentOS6.8编译安装Apache2.4.*以上版本


    Centos6.8下编译安装Apache 2.4.38详细过程

    环境配置:

    yum -y install gcc gcc++ zlib zlib-devel  pcre pcre-devel

    检查一下,系统是否已安装老版本的httpd,如果安装了,将其卸载了。

    #rpm -qa| grep httpd

    #rpm -e nodeps httpd-xxx-xxx.el6.xxx.x86_64

    # service iptables stop

    操作步骤:

    一、下载源码安装包

    # cd /usr/local/src
    # wget 'http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.38.tar.gz'

    二、解压安装

    # tar zxf httpd-2.4.25.tar.gz
    # cd httpd-2.4.25
    # ./configure --prefix=/usr/local/apache --enable-so --enable-rewrite --with-mpm=worker

    在这过程中报错如下:

    checking for chosen layout... Apache
    checking for working mkdir -p... yes
    checking for grep that handles long lines and -e... /bin/grep
    checking for egrep... /bin/grep -E
    checking build system type... x86_64-unknown-linux-gnu
    checking host system type... x86_64-unknown-linux-gnu
    checking target system type... x86_64-unknown-linux-gnu
    configure: 
    configure: Configuring Apache Portable Runtime library...
    configure: 
    checking for APR... no
    configure: error: APR not found.  Please read the documentation.

    解决APR not found 过程如下:

    # cd /usr/local/src
    # wget http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz
    # tar zxf apr-1.5.2.tar.gz
    # ./configure --prefix=/usr/local/apr 
    # make && make install

    在编译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

    解决方法如下:

    在configure里面 RM='$RM -f' 这里的$RM后面一定有一个空格。 如果后面没有空格,直接连接减号,就依然会报错。把RM='$RM'改为RM='$RM -f'

    或:此时使用vim 修改configure文件,注释掉 $RM “$cfgfile”这一行。

    接着重新编译Apache:

    ./configure --prefix=/usr/local/apache --enable-so --enable-rewrite --with-mpm=worker --with-apr=/usr/local/apr

    报错如下:

    checking for chosen layout... Apache
    checking for working mkdir -p... yes
    checking for grep that handles long lines and -e... /bin/grep
    checking for egrep... /bin/grep -E
    checking build system type... x86_64-unknown-linux-gnu
    checking host system type... x86_64-unknown-linux-gnu
    checking target system type... x86_64-unknown-linux-gnu
    configure: 
    configure: Configuring Apache Portable Runtime library...
    configure: 
    checking for APR... yes
      setting CC to "gcc"
      setting CPP to "gcc -E"
      setting CFLAGS to " -g -O2 -pthread"
      setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE"
      setting LDFLAGS to " "
    configure: 
    configure: Configuring Apache Portable Runtime Utility library...
    configure: 
    checking for APR-util... no
    configure: error: APR-util not found.  Please read the documentation.

    解决APR-util not found过程:

    # wget 'http://archive.apache.org/dist/apr/apr-util-1.5.2.tar.gz'
    # tar zxf apr-util-1.5.2.tar.gz
    # cd apr-util-1.5.2
    # ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
    # make && make install

    编译完成后,我们再次重新编译Apache:

    # ./configure --prefix=/usr/local/apache --enable-so --enable-rewrite --with-mpm=worker --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
    # echo $?

    enable-so 允许apache支持动态模块 enable-rewrite 支持URL重定向 with-mpm=worker apache进程模型为worker 默认为prefork

    最后:

    # make && make install
    # echo $?


    创建启动脚本
    # cp /usr/local/apache/bin/httpdctl /etc/init.d/httpd
    修改启动脚本
    * 然后修改httpd启动脚本文件,让它能够支持service和chkconfig命令 [ vim /etc/init.d/httpd 在前面有“#”的注释的任意地方,加入下面2行:]
    # chkconfig: 35 20 80
    # description: httpd

    将httpd添加为开机启动
    chkconfig --add httpd
    这行命令的意思是在/etc/rc.d/rc*/ 添加/etc/init.d/httpd这个文件
    chkconfig --list |grep httpd 查看是否将httpd添加为系统服务
    chkconfig httpd on 开启开机启动httpd服务

    测试

    打开浏览器。输入linux的ip地址。
    显示出 It works!
    至此成功安装apache

    查看编译后的Apache版本号:

  • 相关阅读:
    arcsde 和oracle(双机热备)分布式安装(转载)
    ArcGIS Server分布式部署
    华为软件编程规范和范例(转载)
    常用Java开源库
    通过Word 2007发布Blog
    django中的models模块及数据库一些基本操作
    网页设计与后台程序解决方案模板引擎之Smarty
    Session 和 Cookie
    ul及li水平居中显示
    HTTP协议简介
  • 原文地址:https://www.cnblogs.com/flower-0626/p/12525066.html
Copyright © 2020-2023  润新知