湖濱散記部落格的樹心幽徑[login][主頁]
289:20140312在Linux用原始碼安裝httpd2.4.7網頁伺服程式

(1)下載httpd-2.4.7.tar.gz
[webadm@pig ~]$ wget http://ftp.twaren.net/Unix/Web/apache//httpd/httpd-2.4.7.tar.gz
:
2014-03-11 17:16:33 (1.16 MB/s) - `httpd-2.4.7.tar.gz' saved [6747087/6747087]

(2)目前機器現況
[webadm@pig ~]$ pwd
/home/webadm
[webadm@pig ~]$ date
二  3月 11 17:14:46 CST 2014
[webadm@pig ~]$ uname -a
Linux pig.kmvs.km.edu.tw 3.3.4-5.fc17.i686.PAE #1 SMP Mon May 7 17:37:39 UTC 201                                             2 i686 i686 i386 GNU/Linux
[webadm@pig ~]$


(3)解開httpd-2.4.7.tar.gz
[webadm@pig ~]$ tar xvzf httpd-2.4.7.tar.gz

(4)查看安裝說明檔

(5)第1次httpd-2.4.7自動組態失敗

[webadm@pig httpd-2.4.7]$ ./configure --prefix=/usr/local/apache2
:
checking for APR... no
configure: error: APR not found.  Please read the documentation.

(6)第2次httpd-2.4.7自動組態失敗
[webadm@pig httpd-2.4.7]$ ./configure --prefix=/usr/local/apache2 --with-included-apr
:
configure: error: Bundled APR requested but not found at ./srclib/. Download and unpack the corresponding apr and apr-util packages to ./srclib/.

(7)下載apr-1.5.0.tar.gz
[webadm@pig ~]$ wget http://ftp.tc.edu.tw/pub/Apache//apr/apr-1.5.0.tar.gz

2014-03-11 17:26:06 (2.71 MB/s) - `apr-1.5.0.tar.gz' saved [1016391/1016391]


(8)解開apr-1.5.0.tar.gz
[webadm@pig ~]$ tar xvzf apr-1.5.0.tar.gz

(9)查看apr-1.5.0的README

(10)apr第1次自動組態失敗
[webadm@pig apr-1.5.0]$ ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
configure: WARNING: unrecognized options: --with-apr
:
configure: error: in `/home/webadm/apr-1.5.0':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details


(11)安裝gcc
[webadm@pig apr-1.5.0]$ su
密碼:
[root@pig apr-1.5.0]# gcc -v
bash: gcc: 找不到指令...
是否要安裝「gcc」套件以提供「gcc」指令? [N/y] y
:
gcc version 4.7.2 20120921 (Red Hat 4.7.2-2) (GCC)

(12)apr第2次自動組態仍然失敗
[webadm@pig apr-1.5.0]$ ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
:
rm: cannot remove `libtoolT': No such file or directory
config.status: executing default commands
configure: WARNING: unrecognized options: --with-apr

(13)
[root@pig srclib]# cp ../../apr-1.5.0.tar.gz .
[root@pig srclib]# ls
apr-1.5.0.tar.gz  Makefile.in
[root@pig srclib]# tar xvzf apr-1.5.0.tar.gz

(14)
[root@pig apr-1.5.0]# ./configure
:
config.status: executing libtool commands
rm: cannot remove `libtoolT': No such file or directory
config.status: executing default commands

(15)vi configure
:
# $RM "$cfgfile"

(16)

[root@pig apr-1.5.0]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
:
configure: WARNING: unrecognized options: --with-apr

[root@pig apr-1.5.0]# make
[root@pig apr-1.5.0]# make install

(17)
[root@pig httpd-2.4.7]# ./configure --enable-so --enable-unique-id --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
:
checking for APR-util... configure: error: the --with-apr-util parameter is incorrect. It must specify an install prefix, a build directory, or an apu-config file.
[root@pig httpd-2.4.7]#

(18)
[root@pig webadm]# wget http://ftp.tc.edu.tw/pub/Apache//apr/apr-util-1.5.3.tar.gz

[root@pig webadm]# tar xvzf apr-util-1.5.3.tar.gz

[root@pig webadm]# cd apr-util-1.5.3/
[root@pig apr-util-1.5.3]#  ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
[root@pig apr-util-1.5.3]# make
[root@pig apr-util-1.5.3]# make install


(19)
[root@pig httpd-2.4.7]# ./configure --enable-so --enable-unique-id --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
:
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/


(20)下載並安裝 pcre-8.34.tar.gz
[root@pig webadm]# wget http://sourceforge.net/projects/pcre/files/pcre/8.34/pcre-8.34.tar.gz/download
:
2014-03-12 12:01:49 (1.41 MB/s) - `download' saved [1933734/1933734]
[root@pig webadm]# mv download pcre-8.34.tar.gz
[root@pig webadm]# tar xvzf pcre-8.34.tar.gz
[root@pig webadm]# cd pcre-8.34/
[root@pig pcre-8.34]# ./configure --prefix=/usr/local/pcre
:
configure: error: You need a C++ compiler for C++ support.
[root@pig pcre-8.34]# ./configure --prefix=/usr/local/pcre --with-apr=/usr/local/apr/bin/apr-1-config
:
[root@pig pcre-8.34]#
configure: error: You need a C++ compiler for C++ support.

(21)yum install gcc-c++

[root@pig pcre-8.34]# yum list gcc-c++
Loaded plugins: langpacks, presto, refresh-packagekit
updates/metalink                                                                                      | 4.3 kB     00:00
Available Packages
gcc-c++.i686                                               4.7.2-2.fc17                                               updates

[root@pig pcre-8.34]#  yum list gcc
Loaded plugins: langpacks, presto, refresh-packagekit
Installed Packages
gcc.i686                                                4.7.2-2.fc17                                                 @updates

[root@pig pcre-8.34]# yum install gcc-c++
:
Installed:
  gcc-c++.i686 0:4.7.2-2.fc17

Dependency Installed:
  libstdc++-devel.i686 0:4.7.2-2.fc17

Dependency Updated:
  libstdc++.i686 0:4.7.2-2.fc17

Complete!

(22)
[root@pig pcre-8.34]# ./configure --prefix=/usr/local/pcre --with-apr=/usr/local/apr/bin/apr-1-config

:
pcre-8.34 configuration summary:

    Install prefix .................. : /usr/local/pcre
    C preprocessor .................. : gcc -E
    C compiler ...................... : gcc
    C++ preprocessor ................ : g++ -E
    C++ compiler .................... : g++
    Linker .......................... : /bin/ld
    C preprocessor flags ............ :
    C compiler flags ................ : -g -O2 -fvisibility=hidden
    C++ compiler flags .............. : -O2 -fvisibility=hidden -fvisibility-inlines-hidden
    Linker flags .................... :
    Extra libraries ................. :

    Build 8 bit pcre library ........ : yes
    Build 16 bit pcre library ....... : no
    Build 32 bit pcre library ....... : no
    Build C++ library ............... : yes
    Enable JIT compiling support .... : no
    Enable UTF-8/16/32 support ...... : no
    Unicode properties .............. : no
    Newline char/sequence ........... : lf
    \R matches only ANYCRLF ......... : no
    EBCDIC coding ................... : no
    EBCDIC code for NL .............. : n/a
    Rebuild char tables ............. : no
    Use stack recursion ............. : yes
    POSIX mem threshold ............. : 10
    Internal link size .............. : 2
    Nested parentheses limit ........ : 250
    Match limit ..................... : 10000000
    Match limit recursion ........... : MATCH_LIMIT
    Build shared libs ............... : yes
    Build static libs ............... : yes
    Use JIT in pcregrep ............. : no
    Buffer size for pcregrep ........ : 20480
    Link pcregrep with libz ......... : no
    Link pcregrep with libbz2 ....... : no
    Link pcretest with libedit ...... : no
    Link pcretest with libreadline .. : no
    Valgrind support ................ : no
    Code coverage ................... : no
[root@pig pcre-8.34]# make
[root@pig pcre-8.34]# make install

(23)重新組態httpd-2.4.7

[root@pig httpd-2.4.7]# ./configure --enable-so --enable-unique-id --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util  --with-pcre=/usr/local/pcre

:
config.status: executing default commands
[root@pig httpd-2.4.7]# make
:
make[2]: *** [exports.lo] Error 1
make[2]: Leaving directory `/home/webadm/httpd-2.4.7/server'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/webadm/httpd-2.4.7/server'
make: *** [all-recursive] Error 1


(24)
[root@pig httpd-2.4.7]# ./configure --enable-so --enable-unique-id \
--prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util  \
--with-pcre=/usr/local/pcre --with-included-apr
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... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
configure: error: Bundled APR requested but not found at ./srclib/. Download and unpack the corresponding apr and apr-util packages to ./srclib/.
[root@pig httpd-2.4.7]#

(25)在 ./srclib下置入下載並解開的 apr 和 apr-util
[root@pig httpd-2.4.7]# ls srclib/
apr-1.5.0  apr-1.5.0.tar.gz  Makefile  Makefile.in

[root@pig httpd-2.4.7]# cd srclib/
[root@pig srclib]# mv apr-1.5.0 apr

[root@pig srclib]# cp ../../apr-util-1.5.3.tar.gz .
[root@pig srclib]# tar xvzf apr-util-1.5.3.tar.gz

[root@pig srclib]# ls
apr  apr-1.5.0.tar.gz  apr-util-1.5.3  apr-util-1.5.3.tar.gz  Makefile  Makefile.in

[root@pig srclib]# mv apr-util-1.5.3 apr-util

[root@pig srclib]# ls
apr  apr-1.5.0.tar.gz  apr-util  apr-util-1.5.3.tar.gz  Makefile  Makefile.in


(26)重新組態httpd-2.4.7
[root@pig httpd-2.4.7]# ./configure --enable-so --enable-unique-id --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util  --with-pcre=/usr/local/pcre --with-included-apr

[root@pig httpd-2.4.7]# make
:
make[1]: Leaving directory `/home/webadm/httpd-2.4.7'


[root@pig httpd-2.4.7]# make install


(27)第1次啟動成功
[root@pig httpd-2.4.7]# /usr/local/apache2/bin/apachectl start
[root@pig httpd-2.4.7]# ps ax |grep httpd
30197 ?        Ss     0:00 /usr/local/apache2/bin/httpd -k start
30198 ?        Sl     0:00 /usr/local/apache2/bin/httpd -k start
30199 ?        Sl     0:00 /usr/local/apache2/bin/httpd -k start
30200 ?        Sl     0:00 /usr/local/apache2/bin/httpd -k start
30283 pts/0    S+     0:00 grep --color=auto httpd
[root@pig httpd-2.4.7]#


(28)修改httpd.conf以支援usrdir

[root@pig conf]# vi httpd.conf

[root@pig conf]# cat httpd.conf |grep userdir
LoadModule userdir_module modules/mod_userdir.so
Include conf/extra/httpd-userdir.conf
[root@pig conf]#

[root@pig conf]# cat extra/httpd-userdir.conf
# Settings for user home directories
#
# Required module: mod_authz_core, mod_authz_host, mod_userdir

#
# UserDir: The name of the directory that is appended onto a user's home
# directory if a ~user request is received.  Note that you must also set
# the default access control for these directories, as in the example below.
#
UserDir public_html

#
# Control access to UserDir directories.  The following is an example
# for a site where these directories are restricted to read-only.
#
<Directory "/home/*/public_html">
    AllowOverride FileInfo AuthConfig Limit Indexes
    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
    Require method GET POST OPTIONS
</Directory>

[root@pig conf]#


(29)重啟httpd
[root@pig conf]# /usr/local/apache2/bin/httpd -v
Server version: Apache/2.4.7 (Unix)
Server built:   Mar 12 2014 14:23:39
[root@pig conf]#


[root@pig conf]# /usr/local/apache2/bin/apachectl stop
[root@pig conf]# /usr/local/apache2/bin/apachectl start
[root@pig conf]# ps ax|grep httpd
30439 ?        Ss     0:00 /usr/local/apache2/bin/httpd -k start
30440 ?        Sl     0:00 /usr/local/apache2/bin/httpd -k start
30441 ?        Sl     0:00 /usr/local/apache2/bin/httpd -k start
30442 ?        Sl     0:00 /usr/local/apache2/bin/httpd -k start
30526 pts/0    S+     0:00 grep --color=auto httpd


(30)用戶網頁可順利顯示

http://163.25.20.91/~webadm/index.html




select id,article_id,topic,text from lt_articles_text where article_id =289; ok. update lt_articles set num_reads=num_reads +1 where id=289; ok.