湖濱散記部落格的樹心幽徑[login][主頁]
240:20120814再裝Apache網頁伺服器及PHP

(1)Download httpd-2.4.2.tar.gz
[webadm@life2 lnx]$ date
二  8月 14 21:16:02 CST 2012
[webadm@life2 lnx]$  wget http://apache.stu.edu.tw//httpd/httpd-2.4.2.tar.gz

(2) check previous version
[webadm@life2 lnx]$ httpd -v
Server version: Apache/2.2.22 (Unix)
Server built:   Apr 30 2012 09:55:05
[webadm@life2 lnx]$ httpd -l
Compiled in modules:
  core.c
  prefork.c
  http_core.c
  mod_so.c
[webadm@life2 lnx]$

[webadm@life2 lnx]$ whereis httpd
httpd: /sbin/httpd.event /sbin/httpd.worker /sbin/httpd /usr/sbin/httpd.event /usr/sbin/httpd.worker /usr/sbin/httpd /etc/httpd /lib/httpd /usr/lib/httpd /usr/share/man/man8/httpd.8.gz

[webadm@life2 lnx]$ whereis apachectl
apachectl: /sbin/apachectl /usr/sbin/apachectl /usr/share/man/man8/apachectl.8.gz
[webadm@life2 lnx]$


(3) decompress httpd-2.4.2.tar.gz
[webadm@life2 lnx]$ tar xvzf httpd-2.4.2.tar.gz


[root@life lnx]# cd httpd-2.4.2/
[root@life httpd-2.4.2]# ls
ABOUT_APACHE     BuildBin.dsp   httpd.dsp       Makefile.in       ROADMAP
acinclude.m4     buildconf      httpd.spec      Makefile.win      server
Apache-apr2.dsw  CHANGES        include         modules           srclib
Apache.dsw       config.layout  INSTALL         NOTICE            support
apache_probes.d  configure      InstallBin.dsp  NWGNUmakefile     test
ap.d             configure.in   LAYOUT          os                VERSIONING
build            docs           libhttpd.dsp    README
BuildAll.dsp     emacs-style    LICENSE         README.platforms
[root@life httpd-2.4.2]#

(4) configure httpd-2.4.2 failure
[webadm@life2 lnx]$ cd httpd-2.4.2
[webadm@life2 httpd-2.4.2]$ ./configure --enable-so --enable-unique-id --prefix=/usr/local/apache2
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/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

Configuring Apache Portable Runtime library ...

checking for APR... no
configure: error: APR not found.  Please read the documentation.
[webadm@life2 httpd-2.4.2]$


(5) not install libapreq2-2.13 

(6) install apr
[root@life2 lnx]# wget http://ftp.twaren.net/Unix/Web/apache//apr/apr-1.4.6.tar.gz

[webadm@life2 lnx]$ tar xvzf apr-1.4.6.tar.gz


[root@life2 lnx]# cd apr-1.4.6/
[root@life apr-1.4.6]# ls
apr-config.in  atomic            configure     include     Makefile.in   NWGNUmakefile  support
apr.dep        build             configure.in  libapr.dep  Makefile.win  passwd         tables
apr.dsp        buildconf         docs          libapr.dsp  memory        poll           test
apr.dsw        build.conf        dso           libapr.mak  misc          random         threadproc
apr.mak        build-outputs.mk  emacs-mode    libapr.rc   mmap          README         time
apr.pc.in      CHANGES           file_io       LICENSE     network_io    shmem          user
apr.spec       config.layout     helpers       locks       NOTICE        strings
[root@life apr-1.4.6]#

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

[root@life2 apr-1.4.6]# make


[root@life2 apr-1.4.6]# make install


(7) install apr-util

[root@life2 lnx]# wget http://ftp.twaren.net/Unix/Web/apache//apr/apr-util-1.4.1.tar.gz

[root@life2 lnx]# tar xvzf apr-util-1.4.1.tar.gz
[root@life2 lnx]# cd apr-util-1.4.1/
[root@life2 apr-util-1.4.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

[root@life2 apr-util-1.4.1]# make

[root@life2 apr-util-1.4.1]# make install
:

(8) re confiure httpd

[root@life2 apr-util-1.4.1]# cd ..
[root@life2 lnx]# cd httpd-2.4.2/

[root@life2 httpd-2.4.2]# ./configure --enable-so --enable-unique-id --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
:
Configuring Apache Portable Runtime Utility library...
:
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

:
[root@life2 httpd-2.4.2]# ./configure --help | grep pcre
  --with-pcre=PATH        Use external PCRE library


(9) install pcre


[root@life2 lnx]# wget http://sourceforge.net/projects/pcre/files/pcre/8.31/pcre-8.31.tar.gz/download

[root@life2 lnx]# mv download pcre-8.31.tar.gz



[root@life2 lnx]# tar xvzf pcre-8.31.tar.gz
[root@life2 lnx]# cd pcre-8.31/

 

[root@life2 pcre-8.31]# ./configure --prefix=/usr/local/pcre

[root@life2 pcre-8.31]# make

[root@life2 pcre-8.31]# make install


(10) re confiure success and build httpd
[root@life2 pcre-8.31]# cd ../httpd-2.4.2/
[root@life2 httpd-2.4.2]# ./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

[root@life2 httpd-2.4.2]# make

[root@life2 httpd-2.4.2]# make install


[root@life2 httpd-2.4.2]#  /usr/local/apache2/bin/httpd -v
Server version: Apache/2.4.2 (Unix)
Server built:   Aug 14 2012 21:35:22
[root@life2 httpd-2.4.2]#


(11) excute httpd success
[root@life2 httpd-2.4.2]# /usr/local/apache2/bin/apachectl start
[root@life2 httpd-2.4.2]# ps ax|grep httpd
 4355 ?        Ss     0:00 /usr/local/apache2/bin/httpd -k start
 4356 ?        Sl     0:00 /usr/local/apache2/bin/httpd -k start
 4357 ?        Sl     0:00 /usr/local/apache2/bin/httpd -k start
 4358 ?        Sl     0:00 /usr/local/apache2/bin/httpd -k start
 4447 pts/0    R+     0:00 grep --color=auto httpd
[root@life2 httpd-2.4.2]#

http://localhost/
:
It works!


(12)
[root@life2 lnx]# wget http://tw.php.net/get/php-5.4.5.tar.gz/from/tw2.php.net/mirror
[root@life2 lnx]# mv mirror php-5.4.5.tar.gz

(13)
[root@life2 lnx]# tar xvzf php-5.4.5.tar.gz
[root@life2 lnx]# cd php-5.4.5/


[root@life2 php-5.4.5]# ./configure --with-apxs2=/usr/local/apache2/bin/apxs  --with-mysql

[root@life2 php-5.4.5]# make


[root@life2 php-5.4.5]# make test



[root@life2 php-5.4.5]# make install
:
libtool: install: warning: remember to run `libtool --finish /home/webadm/lnx/php-5.4.5/libs'

:
[root@life2 php-5.4.5]# libtool --finish /home/webadm/lnx/php-5.4.5/libs
---------------------------------
[root@life2 php-5.4.5]#


(14)
root@life2 php-5.4.5]# cd /usr/local/apache2/conf
[root@life2 conf]# vi httpd.conf
:

[root@life2 conf]# cat httpd.conf|grep php
LoadModule php5_module        modules/libphp5.so
    DirectoryIndex index.php index.html
    AddType application/x-httpd-php .php .phtml .php3
[root@life2 conf]# cat httpd.conf|grep ServerName
# ServerName gives the name and port that the server uses to identify itself.
ServerName life.2kmvs.km.edu.tw:80
[root@life2 conf]#
[root@life2 conf]# cat httpd.conf|grep www
User www
Group www
:

[root@life2 conf]# groupadd www
[root@life2 conf]# useradd www -g www

[root@life2 conf]#  /usr/local/apache2/bin/apachectl stop
[root@life2 conf]# ps ax|grep httpd
  490 pts/0    S+     0:00 grep --color=auto httpd
[root@life2 conf]#  /usr/local/apache2/bin/apachectl start
[root@life2 conf]# ps ax|grep httpd
  494 ?        Ss     0:00 /usr/local/apache2/bin/httpd -k start
  495 ?        Sl     0:00 /usr/local/apache2/bin/httpd -k start
  496 ?        Sl     0:00 /usr/local/apache2/bin/httpd -k start
  498 ?        Sl     0:00 /usr/local/apache2/bin/httpd -k start
  592 pts/0    S+     0:00 grep --color=auto httpd
[root@life2 conf]#
[webadm@life2 htdocs]$ cat index.php
<?php
echo "Hi!<hr>";
echo phpinfo();
?>
[webadm@life2 htdocs]$ pwd
/usr/local/apache2/htdocs
[webadm@life2 htdocs]$

http://localhost/index.php
success.


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