ustbwang 发表于 2015-11-15 15:26:14

CentOS 5.5下LAMP环境搭建之源码安装Apache2(httpd-2.4.3)

  CentOS 5.5下LAMP环境搭建之源码安装Apache2(httpd-2.4.3)
  
  由于安装CentOS5.5的设置可能不一样,所以有些软件在系统安装时就顺便安装了。下面的步骤仅供参考。
  

1、软件准备
  apr-1.4.6.tar.gz (http://apr.apache.org/download.cgi)
  apr-util-1.5.1.tar.gz (http://apr.apache.org/download.cgi)
  httpd-2.4.3.tar.gz (http://httpd.apache.org/download.cgi)
  pcre-8.31.tar.gz (http://www.pcre.org/,
http://sourceforge.net/projects/pcre/files/pcre/8.31/)
  

2、编译工具准备
  安装gcc、gcc-c++
  

# yum install gcc gcc-c++
  
  

3、查询和删除系统安装的httpd或apache

# rpm -q httpd apache
httpd-2.2.3-43.el5.centos
package apache is not installed
# yum erase httpd
  

4、安装依赖的库

(1)解压放置apr和apr-util的源码
  将apr-1.4.6.tar.gz、apr-util-1.5.1.tar.gz和httpd-2.4.3.tar.gz解压到/usr/local/src目录下

# pwd
/usr/local/src
# tar -zxf apr-1.4.6.tar.gz
# tar -zxf apr-util-1.5.1.tar.gz
# tar -zxf httpd-2.4.3.tar.gz
  将apr和apr-util移动到httpd-2.4.3的srclib目录,并去掉版本号

# mv apr-1.4.6 httpd-2.4.3/srclib/apr
# mv apr-util-1.5.1 httpd-2.4.3/srclib/apr-util
  

(2)编译安装pcre

# tar -zxf pcre-8.31.tar.gz
# cd pcre-8.31
# ./configure --prefix=/usr/local/pcre
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
……
pcre-8.31 configuration summary:
Install prefix .................. : /usr/local/pcre
C preprocessor .................. : gcc -E
C compiler ...................... : gcc
C++ preprocessor ................ : g++ -E
C++ compiler .................... : g++
Linker .......................... : /usr/bin/ld
C preprocessor flags ............ :
C compiler flags ................ : -O2
C++ compiler flags .............. : -O2
Linker flags .................... :
Extra libraries ................. :
Build 8 bit pcre library ........ : yes
Build 16 bit pcre library ....... : no
Build C++ library ............... : yes
Enable JIT compiling support .... : no
Enable UTF-8/16 support ......... : no
Unicode properties .............. : no
Newline char/sequence ........... : lf
\R matches only ANYCRLF ......... : no
EBCDIC coding ................... : no
Rebuild char tables ............. : no
Use stack recursion ............. : yes
POSIX mem threshold ............. : 10
Internal link size .............. : 2
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
# make && make install
rm -f pcre_chartables.c
ln -s ./pcre_chartables.c.dist pcre_chartables.c
makeall-am
make: Entering directory `/usr/local/src/pcre-8.31'
……
make: Leaving directory `/usr/local/src/pcre-8.31'
make: Leaving directory `/usr/local/src/pcre-8.31'
make: Leaving directory `/usr/local/src/pcre-8.31'
# ls -l /usr/local/pcre
total 16
drwxr-xr-x 2 root root 4096 Oct 29 01:32 bin
drwxr-xr-x 2 root root 4096 Oct 29 01:32 include
drwxr-xr-x 3 root root 4096 Oct 29 01:32 lib
drwxr-xr-x 4 root root 4096 Oct 29 01:32 share
  

5、编译安装apache(httpd-2.4.3)

# ./configure --prefix=/usr/local/apache2 --with-included-apr --with-pcre=/usr/local/pcre
checking for chosen layout... Apache
checking for working mkdir -p... yes
……
config.status: creating build/config_vars.sh
config.status: creating include/ap_config_auto.h
config.status: executing default commands
# make && make install
Making all in srclib
make: Entering directory `/usr/local/src/httpd-2.4.3/srclib'
Making all in apr
……
mkdir /usr/local/apache2/man
mkdir /usr/local/apache2/man/man1
mkdir /usr/local/apache2/man/man8
mkdir /usr/local/apache2/manual
make: Leaving directory `/usr/local/src/httpd-2.4.3'
# cd /usr/local/apache2/bin
# ./apachectl -k start
  

6、测试
  用浏览器打开http://localhost,看apache是否能访问,如下




  参考资料:
  1、http://httpd.apache.org/docs/2.4/install.html
  2、http://shenlan.blog.iyunv.com/55742/458848
  3、http://stackoverflow.com/questions/10663180/http-install-error-in-libpcre

版权声明:本文为博主原创文章,未经博主允许不得转载。
页: [1]
查看完整版本: CentOS 5.5下LAMP环境搭建之源码安装Apache2(httpd-2.4.3)