jingjihui 发表于 2018-11-20 07:36:08

Apache 2.4.20 编译安装

  1.安装版本
  Apache版本:2.4.20
  

  2.安装编译环境
  # yum -y install gcc gcc-c++ pcre pcre-devel
  源码安装apr和apr-util,第6步中有安装方法。
  

  3.下载Apache
  # cd/usr/local/src/
  # wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.4.20.tar.bz2
  或者
  访问网站:http://www.apache.org/dyn/closer.cgi   选择一个镜像网站,下载Apache。
  

  

  4.解压
  # tar jxvf httpd-2.4.20.tar.bz2
  

  5.创建apache安装目录
  #mkdir /usr/local/apache
  

  6.配置编译参数:
  # cd httpd-2.4.20
  # ./configure \
  --prefix=/usr/local/apache \
  --with-included-apr \
  --enable-so \
  --enable-deflate=shared \
  --enable-expires=shared \
  --enable-rewrite=shared \
  --with-pcre
  

  报错:
  “configure: error: Bundled APR requested but not found at ./srclib/. Download and unpack the corresponding apr and apr-util packages to ./srclib/.” 是因为没有安装APR库
  解决办法:
  下载:
  # wget http://mirror.bit.edu.cn/apache/apr/apr-util-1.5.4.tar.bz2
  # wget http://mirror.bit.edu.cn/apache/apr/apr-1.5.2.tar.bz2
  安装apr:
  # tar jxvf apr-1.5.2.tar.bz2
  # mkdir /usr/local/apr
  #cd apr-1.5.2
  # ./configure --prefix=/usr/local/apr
  # make && make install
  安装apr-util:
  # cd..
  # tar jxvf apr-util-1.5.4.tar.bz2
  # mkdir /usr/local/apr-util

  # cd apr-util-1.5.4
  # ./configure --prefix=/usr/local/apr-util--with-apr=/usr/local/apr/
  # make && make install
  

  报错:“configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/”
  解决办法:# yum -y install pcre pcre-devel
  

  
  再次运行configure,注意选项中添加指定apr、apr-uitl路径。

  # ./configure \
  > --prefix=/usr/local/apache \
  > --with-included-apr \
  > --enable-so \
  >--enable-deflate=shared \
  >--enable-expires=shared \
  >--enable-rewrite=shared \
  >--with-pcre \
  > --with-apr=/usr/local/apr \
  > --with-apr=/usr/local/apr-util
  # echo $?
  0
  # make
  # make install
  

  7.启动httpd
  # /usr/local/apache/bin/apachectl start
   报错:“AH00557: httpd: apr_sockaddr_info_get() failed for Kry123
  AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message”
  解决办法:

  # vim /usr/local/apache/conf/httpd.conf
  改为:ServerName localhost
  

  再次执行启动命令
  # /usr/local/apache/bin/apachectl start
  # ps aux|grep httpd
  root   583170.00.1702722120 ?      Ss   15:53   0:00 /usr/local/apache/bin/httpd -k start
  daemon   583180.00.2 4145324148 ?      Sl   15:53   0:00 /usr/local/apache/bin/httpd -k start
  daemon   583190.00.2 4145324160 ?      Sl   15:53   0:00 /usr/local/apache/bin/httpd -k start
  daemon   583200.00.2 4145324156 ?      Sl   15:53   0:00 /usr/local/apache/bin/httpd -k start
  root   584030.00.0 103308   852 pts/1    S+   15:53   0:00 grep httpd
  

  8.配置服务
  # cd/usr/local/apache/bin/
  # cp apachectl /etc/init.d/httpd
  # vim /etc/init.d/httpd
  在#!/bin/sh下中添加一下内容:
  #chkconfig: 35 85 15
  #description: apache
  # chkconfig --add httpd
  # chkconfig --level 35 httpd on
  

  如果有兴趣可以加入Linux运维架构交流群249358926大家一起讨论。

  


  




页: [1]
查看完整版本: Apache 2.4.20 编译安装