标签:linux httpd apache 2.4.20 apache 编译安装
1.安装版本
Apache版本:2.4.20
2.安装编译环境
[root@Kry123 ~]# yum -y install gcc gcc-c++ pcre pcre-devel
源码安装apr和apr-util,第6步中有安装方法。
3.下载Apache
[root@Kry123 ~]# cd /usr/local/src/
[root@Kry123 src]# wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.4.20.tar.bz2
或者
访问网站:http://www.apache.org/dyn/closer.cgi 选择一个镜像网站,下载Apache。
4.解压
[root@Kry123 src]# tar jxvf httpd-2.4.20.tar.bz2
5.创建apache安装目录
[root@Kry123 src]# mkdir /usr/local/apache
6.配置编译参数:
[root@Kry123 src]# cd httpd-2.4.20
[root@Kry123 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库
解决办法:
下载:
[root@Kry123 src]# wget http://mirror.bit.edu.cn/apache/apr/apr-util-1.5.4.tar.bz2
[root@Kry123 src]# wget http://mirror.bit.edu.cn/apache/apr/apr-1.5.2.tar.bz2
安装apr:
[root@Kry123 src]# tar jxvf apr-1.5.2.tar.bz2
[root@Kry123 src]# mkdir /usr/local/apr
[root@Kry123 src]#cd apr-1.5.2
[root@Kry123 apr-1.5.2]# ./configure --prefix=/usr/local/apr
[root@Kry123 apr-1.5.2]# make && make install
安装apr-util:
[root@Kry123 apr-1.5.2]# cd ..
[root@Kry123 src]# tar jxvf apr-util-1.5.4.tar.bz2
[root@Kry123 src]# mkdir /usr/local/apr-util
[root@Kry123 src]# cd apr-util-1.5.4
[root@Kry123 apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
[root@Kry123 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/”
解决办法:[root@Kry123 httpd-2.4.20]# yum -y install pcre pcre-devel
再次运行configure,注意选项中添加指定apr、apr-uitl路径。
[root@Kry123 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
[root@Kry123 httpd-2.4.20]# echo $?
0
[root@Kry123 httpd-2.4.20]# make
[root@Kry123 httpd-2.4.20]# make install
7.启动httpd
[root@Kry123 ~]# /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”
解决办法:
[root@Kry123 ~]# vim /usr/local/apache/conf/httpd.conf
改为:ServerName localhost
再次执行启动命令
[root@Kry123 ~]# /usr/local/apache/bin/apachectl start
[root@Kry123 ~]# 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.配置服务
[root@Kry123 ~]# cd /usr/local/apache/bin/
[root@Kry123 bin]# cp apachectl /etc/init.d/httpd
[root@Kry123 bin]# vim /etc/init.d/httpd
在#!/bin/sh下中添加一下内容:
#chkconfig: 35 85 15
#description: apache
[root@Kry123 bin]# chkconfig --add httpd
[root@Kry123 bin]# chkconfig --level 35 httpd on
如果有兴趣可以加入Linux运维架构交流群249358926大家一起讨论。
本文出自 “Scorpions丶毒” 博客,请务必保留此出处http://scorpions.blog.51cto.com/7138036/1783080
标签:linux httpd apache 2.4.20 apache 编译安装
原文地址:http://scorpions.blog.51cto.com/7138036/1783080