当前位置: 代码迷 >> 综合 >> LAMP 架构的编译安装及错误完全分析
  详细解决方案

LAMP 架构的编译安装及错误完全分析

热度:57   发布时间:2023-12-08 21:34:21.0

本次试验用的是新安装的系统,以此保证纯净,站在第一次编译安装lamp的角度,分析各种错误,从错误开始入手。

至于lamp是干什么用的,我就不赘述了,直接开始。

本文中的软件我都已经下好了,并且打包好了,如果有需要的朋友,可以自己下载我的软件包


首先交代一下系统的版本 

[root@localhost libevent-2.0.18-stable]# lsb_release -a
LSB Version:    :core-4.0-ia32:core-4.0-noarch:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: RedHatEnterpriseServer
Description:    Red Hat Enterprise Linux Server release 6.0 (Santiago)
Release:        6.0
Codename:       Santiago

一、apache的编译安装

为了方便管理,编译安装时最好养成集中管理的习惯,在这我先定义一个文件夹/usr/src/lamp

[root@localhost ~]# mkdir /usr/local/lamp

apache的编译安装很简单,但是我们需要安装一些包便于apache功能的扩展

1、apr-1.4.6.tar.gz 的安装

[root@localhost lamp]# tar xf apr-1.4.6.tar.gz -C /usr/src/lamp/

[root@localhost apr-1.4.6]# pwd 
/usr/src/lamp/apr-1.4.6

[root@localhost apr-1.4.6]# ./configure --enable-threads --disable-ipv6 --with-devrandowm=/dev/random && make && make install 

2、libiconv-1.13.tar.gz的安装

[root@localhost libiconv-1.13]# ./configure --enable-static && make && make install

3、apr-iconv-1.2.1.tar.gz的安装

[root@localhost lamp]# tar xf apr-iconv-1.2.1.tar.gz -C /usr/src/lamp/

[root@localhost apr-iconv-1.2.1]# ./configure --with-apr=/usr/local/apr/bin/apr-1-config 

[root@localhost lamp]# make  && make install 

[root@localhost apr-iconv-1.2.1]# ln -s /usr/src/lamp/apr-iconv-1.2.1/lib/libapriconv-1.la  /usr/src/lamp/apr-iconv-12.1/lib/libapriconv.la

4、安装openssl nss-devel

[root@localhost lamp]# yum install openssl* nss-devel -y

5、安装apr-util-1.4.1.tar.gz

[root@localhost lamp]# tar xf apr-util-1.4.1.tar.gz -C /us
r/src/lamp/

[root@localhost apr-util-1.4.1]# ./configure --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-iconv=./apr-iconv --with-openssl=/usr --with-nss=/usr --with-mysql=/usr/local/mysql --with-iconv=/usr/local && make && make install

6、安装两个rpm包 

libzip-0.9-3.1.el6.i686.rpm
libzip-devel-0.9-3.1.el6.i686.rpm

[root@localhost lamp]# rpm -ivh libzip-0.9-3.1.el6.i686.rpm
warning: libzip-0.9-3.1.el6.i686.rpm: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Preparing...                                              ########################################### [100%]
   1:libzip                                               ########################################### [100%]
[root@localhost lamp]# rpm -ivh libzip-devel-0.9-3.1.el6.i686.rpm 
warning: libzip-devel-0.9-3.1.el6.i686.rpm: Header V4 DSA/SHA1 Signature, key ID 192a7d7d: NOKEY
Preparing...                                              ########################################### [100%]
   1:libzip-devel                                         ########################################### [100%]


7、安装pcre-7.9.tar.gz

[root@localhost lamp]# tar xf pcre-7.9.tar.gz -C /usr/src/lamp/

[root@localhost pcre-7.9]#  ./configure --enable-utf8 --enable-rebuild-chartables --enable-newline-is-any --enable-pcregrep-libz --enable-pcregrep-libbz2

make && make install 

8、安装httpd-2.2.22.tar.gz

[root@localhost lamp]# tar xf httpd-2.2.22.tar.gz -C /usr/src/lamp/

[root@localhost httpd-2.2.22]# pwd
/usr/src/lamp/httpd-2.2.22

[root@localhost httpd-2.2.22]# ./configure --enable-modules=all --enable-mods-shared=all --enable-cache --enable-disk-cache --enable-dumpio --enable-echo --enable-example --enable-logio --enable-mime-magic --enable-expires --enable-headers --enable-unique-id --enable-proxy --enable-proxy-balancer --enable-proxy-http --enable-proxy-ajp --enable-proxy-connect --enable-ssl  --enable-static-ab --enable-http --enable-info --enable-cgi --enable-vhost-alias --enable-so --enable-rewrite --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr/bin/apu-1-config --with-pcre=/usr/local --with-ssl=/usr --with-mpm=prefork

make && make install

9、apache的配置文件修改

[root@localhost conf]# pwd
/usr/local/apache2/conf
[root@localhost conf]# ls
extra  httpd.conf  magic  mime.types  original

[root@localhost conf]# vi httpd.conf




去掉下面几个Include前面的#号



[root@localhost extra]# pwd
/usr/local/apache2/conf/extra
[root@localhost extra]# vi httpd-languages.conf



[root@localhost bin]# pwd
/usr/local/apache2/bin
[root@localhost bin]# cp apachectl /etc/init.d/apache

[root@localhost ~]# service apache start

至于mysql5.6的编译安装可以参考http://blog.csdn.net/avilifans/article/details/11553719

10、PHP的安装-----我这里用了5.3.27版本的php,没有用之前下载的5.3.10

./configure --with-apxs2=/usr/local/apache2/bin/apxs --disable-
ipv6 --with-libxml-dir=/usr --with-openssl=/usr --with-zlib=/usr --wit
h-bz2=/usr --with-curl=/usr  --enable-ftp --with-mysql=/usr/local/mysq
l --with-mysql-sock=/var/run/mysqld/mysql5.socket  --with-mysqli=/usr/
local/mysql/bin/mysql_config


.
######错误###########错误###########错误###########错误###########错误###########错误###########错误###########错误#####
错误1
APR Version: 1.4.5
checking for chosen layout... apr
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/usr/src/lamp/httpd-2.2.22/srclib/apr':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
configure failed for srclib/apr

出现这种错误 很明显,没有安装gcc、c语言编译器

yum install gcc  -y

-------------------------------

错误 2

config.status: creating test/internal/Makefile
config.status: creating include/arch/unix/apr_private.h
config.status: executing libtool commands
rm: cannot remove `libtoolT': No such file or directory
config.status: executing default commands
config.status: include/apr.h is unchanged

首先yum install libtool还是一样报错,在configure里面 RM='$RM  -f'   这里的$RM后面一定有一个空格。 如果后面没有空格,直接连接减号,就依

然会报错。把RM='$RM'改为RM='$RM  -f‘

-------------------------------

错误3

checking bzlib.h usability... no
checking bzlib.h presence... no
checking for bzlib.h... no
checking for BZ2_bzopen in -lbz2... no
checking readline/readline.h usability... no
checking readline/readline.h presence... no
checking for readline/readline.h... no
checking readline/history.h usability... no
checking readline/history.h presence... no
checking for readline/history.h... no
checking for readline in -lreadline... no
** Cannot --enable-pcregrep-libbz2 because bzlib.h was not found

yum  install bzip2-devel   -y

------------------------------

错误4

 /bin/sh ./libtool --tag=CXX   --mode=compile  -DHAVE_CONFIG_H -I.      -c -o pcrecpp.lo pcrecpp.cc
libtool: ignoring unknown tag CXX
libtool: unrecognized option `-DHAVE_CONFIG_H'
Try `libtool --help' for more information.
make[1]: *** [pcrecpp.lo] Error 1
make[1]: Leaving directory `/usr/src/lamp/pcre-7.9'
make: *** [all] Error 2

yum install gcc-c++ -y