歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux技術

Apache 2.4.20 編譯安裝

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
Copyright © Linux教程網 All Rights Reserved