LAMP--环境搭建及报错解决

  环境:CentOS 6.5

  ★安装mysql

  cd /usr/local/src

  wget http://syslab.comsenz.com/downlo … -icc-glibc23.tar.gz

  tar zxvf /usr/local/src/mysql-5.1.40-linux-i686-icc-glibc23.tar.gz  解压

  mv mysql-5.1.40-linux-i686-icc-glibc23 /usr/local/mysql

  useradd -s /sbin/nologin mysql

  cd /usr/local/mysql

  mkdir -p /data/mysql

  chown -R mysql:mysql /data/mysql

  ./scripts/mysql_install_db –user=mysql –datadir=/data/mysql

  cp support-files/my-large.cnf /etc/my.cnf

  cp support-files/mysql.server /etc/init.d/mysqld

  chmod 755 /etc/init.d/mysqld

  vim /etc/init.d/mysqld       #修改basedir=/usr/local/mysql  datadir=/data/mysql

  chkconfig –add mysqld

  chkconfig mysqld on

  service mysqld start

  ★安装apache

  因为我之前已经在自己的虚拟机上安装过apache了,这次安装为第二次安装。通常安装apache第一次比较顺利,再次安装则可能出现各种各样的问题。

  ==>安装2.2版本的apache

  cd /usr/local/src

  wget http://syslab.comsenz.com/downloads/linux/httpd-2.2.16.tar.gz

  tar zxvf httpd-2.2.16.tar.gz    解压

  cd httpd-2.2.16.tar.gz

  ./configure –prefix=/usr/local/apache2 –with-included-apr  –with-pcre –enable-mods-shared=most    使用此命令进行编译

  apr支持apache在不同的平台上使用

  出现报错:configure: error: Size of "void *" is less than size of "long"

  百度中有说法:

  增加 ap_cv_void_ptr_lt_long=no

  移除–with-pcre=/xxx/xxx/pcre选项

  ◆首先我们尝试第一种方案:

  ./configure –prefix=/usr/local/apache2 –with-included-apr  –with-pcre –enable-mods-shared=most ap_cv_void_ptr_lt_long=no  使用此命令进行编译

  结果显示 config.status: executing default commands  好了,编译问题解决

  ◆接下来我们make一下

  make也不顺利,出现了一下信息的报错提示

  undefined reference to `pcre_info'

  collect2: ld returned 1 exit status

  make[1]: *** [httpd] 错误 1

  make[1]: Leaving directory `/usr/local/src/httpd-2.2.16'

  make: *** [all-recursive] 错误 1

  查阅资料获得,2.2版本的apache的安装实际上是使用自身的apr,将安装时系统已经存在的apr删除后,在进行编译应该就没有问题了(猜测与我已经安装过一次了有关系)

  ==>安装2.4版本的apache

  CentOS6中,之前使用yum安装的apr已经不适用于httpd-2.4版本了,所以需要源码编译安装apr和apr-util

  ◆安装apr

  cd /usr/local/src

  wget http://mirrors.cnnic.cn/apache/apr/apr-1.5.1.tar.bz2

  tar jxvf apr-1.5.1.tar.bz2

  cd apr-1.5.1

  ./configure –prefix=/usr/local/apr

  make

  make install

  ◆安装apr-util

  cd /usr/local/src

  wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.5.4.tar.gz

  tar zxvf apr-util-1.5.4.tar.gz

  cd apr-util-1.5.4

  ./configure –with-apr=/usr/local/apr/

  make

  make install

  ◆安装apache

  cd /usr/local/src

  wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.10.tar.bz2

  ./configure –prefix=/usr/local/apache2 –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util/

  make

  make install

  ★安装php

  wget http://cn2.php.net/distributions/php-5.3.28.tar.gz

  tar zxf php-5.3.28.tar.gz

  cd php-5.3.28

  ./configure   –prefix=/usr/local/php   –with-apxs2=/usr/local/apache2/bin/apxs   –with-config-file-path=/usr/local/php/etc   –with-mysql=/usr/local/mysql   –with-libxml-dir   –with-gd   –with-jpeg-dir   –with-png-dir   –with-freetype-dir   –with-iconv-dir   –with-zlib-dir   –with-bz2   –with-openssl   –with-mcrypt   –enable-soap   –enable-gd-native-ttf   –enable-mbstring   –enable-sockets   –enable-exif   –disable-ipv6

  ◆编译时报错:xml2-config not found. Please check your libxml2 installation.

  提示此类信息一般缺少相关的库,而相关库一般是 *-devel 形式的,比如 libxml2-devel

  解决:

  [root@yue php-5.3.28]# rpm -qa |grep libxml2     <== 查看有没有安装libxml2

  [root@yue php-5.3.28]# yum install -y libxml2    <== 安装两个包

  [root@yue php-5.3.28]# yum install -y libxml2-devel

  [root@yue php-5.3.28]# find / -name "xml2-config" <== find一下,发现系统里现在已经有libxml2

  /usr/bin/xml2-config

  重新编译,出现错误提示:configure: error: Please reinstall the BZip2 distribution

  按照上面的两个思路安装两个包

  [root@yue php-5.3.28]# yum install -y bzip2

  [root@yue php-5.3.28]# yum install -y bzip2-devel

  编译又报错:configure: error: jpeglib.h not found.

  [root@yue php-5.3.28]# yum install -y libjpeg-devel  <== 注意安装的为libjpeg-devel

  编译又出现了报错:configure: error: png.h not found.

  [root@yue php-5.3.28]# yum install -y libpng-devel   <== 注意安装包的名称

  还有报错:configure: error: freetype.h not found.

  继续安装[root@yue php-5.3.28]# yum install -y freetype-devel

  报错又来:configure: error: mcrypt.h not found. Please reinstall libmcrypt.

  我们先来查一下需要安装哪些包

  [root@yue php-5.3.28]# yum list|grep mcrypt

  file:///mnt/repodata/repomd.xml: [Errno 14] Could not open/read file:///mnt/repodata/repomd.xml

  Trying other mirror.     <== 查看过程中出现这样的提示

  出现此问题的原因是系统中没有安装epel扩展源,yum 源安装一下即可

  [root@yue php-5.3.28]# yum list|grep mcrypt

  file:///mnt/repodata/repomd.xml: [Errno 14] Could not open/read file:///mnt/repodata/repomd.xml

  Trying other mirror.

  libmcrypt.i686                             2.5.8-9.el6                   epel

  libmcrypt-devel.i686                       2.5.8-9.el6                   epel

  libtomcrypt.i686                           1.17-21.el6                   epel

  libtomcrypt-devel.i686                     1.17-21.el6                   epel

  libtomcrypt-doc.noarch                     1.17-21.el6                   epel

  mcrypt.i686                                2.6.8-10.el6                  epel

  php-mcrypt.i686                            5.3.3-3.el6                   epel   正常了

  安装[root@yue php-5.3.28]# yum install -y mcrypt-devel

  !!编译成功!!  Thank you for using PHP.

  ◆make   如果看不出来是否成功,可以使用echo $?查看 0为成功 1为失败

  报错:/usr/local/src/php-5.3.28/Zend/zend_language_parser.h:317: 错误:与‘zendparse’类型冲突

  /usr/local/src/php-5.3.28/Zend/zend_globals_macros.h:35: 附注:‘zendparse’的上一个声明在此

  make: *** [ext/standard/basic_functions.lo] 错误 1

  提示类型冲突,那我们就修改一下类型

  打开上面的两个文件,我们对应行数可以看到

  在zend_language_parser.h:317

  int zendparse (void);

  在zend_globals_macros.h:35

  int zendparse(void *compiler_globals);

  错误就是参数不一致导致的:

  我们vim一下,

  把zend_language_parser.h:317的

  int zendparse (void) ==> int zendparse(void *compiler_globals)  成功!!

  ◆make install

 

上一篇:安卓防火墙 PS DroidWall

下一篇:CentOS查看内核版本,位数,版本号