1. 程式人生 > >apache httpd 2.4.3編譯安裝

apache httpd 2.4.3編譯安裝

2012-10-26

周海漢

2012.10.26

前言

新版apache 2.4.3直接configure會報錯,缺了兩個模組apr和pcre,這是需要單獨下載和編譯的。方法和過程如下所示。

下載

[[email protected] ~]$ wget http://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.4.3.tar.gz

編譯 [[email protected] httpd-2.4.3]$ ./configure 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.

httpd 2.4安裝文件: http://httpd.apache.org/docs/2.4/install.html APR and APR-Util Apache Portable Runtime (APR),apache 可移植執行。 地址:http://apr.apache.org/ 最新版包括3個元件: APR 1.4.6, released Feb 14, 2012 APR-util 1.5.1, released October 5, 2012 APR-iconv 1.2.1, released November 26, 2007

這是原文說明:

Make sure you have APR and APR-Util already installed on your system. If you don’t, or prefer to not use the system-provided versions, download the latest versions of both APR and APR-Util from Apache APR(http://apr.apache.org/), unpack them into ./srclib/apr and ./srclib/apr-util (be sure the domain names do not have version numbers; for example, the APR distribution must be under ./srclib/apr/) and use ./configure’s –with-included-apr option. On some platforms, you may have to install the corresponding -dev packages to allow httpd to build against your installed copy of APR and APR-Util.

安裝apr

[[email protected] srclib]$ wget http://labs.mop.com/apache-mirror//apr/apr-1.4.6.tar.gz

[[email protected] srclib]$ wget http://labs.mop.com/apache-mirror//apr/apr-util-1.5.1.tar.gz

[[email protected] srclib]$ wget http://labs.mop.com/apache-mirror//apr/apr-iconv-1.2.1.tar.gz

[[email protected]

srclib]$ ln -s apr-1.4.6 apr [[email protected] srclib]$ ln -s apr-iconv-1.2.1 apr-iconv [[email protected] srclib]$ ln -s apr-util-1.5.1 apr-util

[[email protected] httpd-2.4.3]$ ./configure –with-include-apr configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

安裝pcre

Perl-Compatible Regular Expressions Library (PCRE),Perl相容正則表示式庫,新版httpd不再隨包釋出,需要到 http://www.pcre.org 下載,也可以裝現成版本。如果安裝後找不到,用–with-pcre指定pcre路徑。可能需要安裝相應的dev版本。 可以從ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/或https://sourceforge.net/projects/pcre/files/pcre/下載原始碼。 [[email protected] srclib]$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.31.tar.gz [[email protected] pcre-8.31]$ ./configure [[email protected] pcre-8.31]$ make [[email protected] pcre-8.31]$ sudo make install

[[email protected] httpd-2.4.3]$ ./configure –with-include-apr [[email protected] httpd-2.4.3]$ make [[email protected] httpd-2.4.3]$ rpm -qa | grep httpd httpd-2.2.3-43.el5.centos httpd-manual-2.2.3-43.el5.centos

安裝

編譯通過,安裝,和原來的版本不會衝突 [[email protected] httpd-2.4.3]$ sudo make install

預設安裝到了/usr/local/apache2/

啟動httpd [[email protected] bin]# ./apachectl -k start /usr/local/apache2/bin/httpd: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory [[email protected] lib]$ ldconfig /usr/local/lib [[email protected] bin]# ./apachectl -k start AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, using 192.168.10.47. Set the ‘ServerName’ directive globally to suppress this message

這是一個警告資訊,可以忽略。此時httpd已經執行起來,可以通過瀏覽器訪問了。 但為了不顯示警告,可以修改一下httpd.conf [[email protected] apache2]# vi conf/httpd.conf 修改#ServerName www.example.com:80為 ServerName 192.168.10.47:80 [[email protected] apache2]# ./bin/apachectl -k stop [[email protected] apache2]# ./bin/apachectl -k start [[email protected] apache2]# 已經沒有警告資訊,用瀏覽器訪問顯示it works.

如非註明轉載, 均為原創. 本站遵循知識共享CC協議,轉載請註明來源