Apache 2.4.20 编译安装
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Apache 2.4.20 编译安装相关的知识,希望对你有一定的参考价值。
1.安装版本
Apache版本:2.4.20
2.安装编译环境
[[email protected] ~]# yum -y install gcc gcc-c++ pcre pcre-devel
源码安装apr和apr-util,第6步中有安装方法。
3.下载Apache
[[email protected] ~]# cd /usr/local/src/
[[email protected] src]# wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.4.20.tar.bz2
或者
访问网站:http://www.apache.org/dyn/closer.cgi 选择一个镜像网站,下载Apache。
4.解压
[[email protected] src]# tar jxvf httpd-2.4.20.tar.bz2
5.创建apache安装目录
[[email protected] src]# mkdir /usr/local/apache
6.配置编译参数:
[[email protected] src]# cd httpd-2.4.20
[[email protected] 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库
解决办法:
下载:
[[email protected] src]# wget http://mirror.bit.edu.cn/apache/apr/apr-util-1.5.4.tar.bz2
[[email protected] src]# wget http://mirror.bit.edu.cn/apache/apr/apr-1.5.2.tar.bz2
安装apr:
[[email protected] src]# tar jxvf apr-1.5.2.tar.bz2
[[email protected] src]# mkdir /usr/local/apr
[[email protected] src]#cd apr-1.5.2
[[email protected] apr-1.5.2]# ./configure --prefix=/usr/local/apr
[[email protected] apr-1.5.2]# make && make install
安装apr-util:
[[email protected] apr-1.5.2]# cd ..
[[email protected] src]# tar jxvf apr-util-1.5.4.tar.bz2
[[email protected] src]# mkdir /usr/local/apr-util
[[email protected] src]# cd apr-util-1.5.4
[[email protected] apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
[[email protected] apr-util-1.5.4]# make && make install
报错:“configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/”
解决办法:[[email protected] httpd-2.4.20]# yum -y install pcre pcre-devel
再次运行configure,注意选项中添加指定apr、apr-uitl路径。
[[email protected] 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 \
> --with-apr=/usr/local/apr \
> --with-apr=/usr/local/apr-util
[[email protected] httpd-2.4.20]# echo $?
0
[[email protected] httpd-2.4.20]# make
[[email protected] httpd-2.4.20]# make install
7.启动httpd
[[email protected] ~]# /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”
解决办法:
[[email protected] ~]# vim /usr/local/apache/conf/httpd.conf
改为:ServerName localhost
再次执行启动命令
[[email protected] ~]# /usr/local/apache/bin/apachectl start
[[email protected] ~]# ps aux |grep httpd
root 58317 0.0 0.1 70272 2120 ? Ss 15:53 0:00 /usr/local/apache/bin/httpd -k start
daemon 58318 0.0 0.2 414532 4148 ? Sl 15:53 0:00 /usr/local/apache/bin/httpd -k start
daemon 58319 0.0 0.2 414532 4160 ? Sl 15:53 0:00 /usr/local/apache/bin/httpd -k start
daemon 58320 0.0 0.2 414532 4156 ? Sl 15:53 0:00 /usr/local/apache/bin/httpd -k start
root 58403 0.0 0.0 103308 852 pts/1 S+ 15:53 0:00 grep httpd
8.配置服务
[[email protected] ~]# cd /usr/local/apache/bin/
[[email protected] bin]# cp apachectl /etc/init.d/httpd
[[email protected] bin]# vim /etc/init.d/httpd
在#!/bin/sh下中添加一下内容:
#chkconfig: 35 85 15
#description: apache
[[email protected] bin]# chkconfig --add httpd
[[email protected] bin]# chkconfig --level 35 httpd on
如果有兴趣可以加入Linux运维架构交流群249358926大家一起讨论。
本文出自 “Scorpions丶毒” 博客,请务必保留此出处http://scorpions.blog.51cto.com/7138036/1783080
以上是关于Apache 2.4.20 编译安装的主要内容,如果未能解决你的问题,请参考以下文章