`

基于CentOS 5.4的环境构建LAMP平台问题集锦

阅读更多

一、APACHE编译配置

#./configure --prefix=/usr/local/apache2 --enable-rewrite=shared --enable-track-vars --enable-cgi --enable-so --enable-mods-shared=all --with-config-file-path=/usr/local/apache2/conf --with-mpm=worker

 

二、MYSQL编译配置

#./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-extra-charsets=all --enable-thread-safe-client --enable-assembler --with-readline --with-big-tables --with-plugins=all --with-tcp-port=3310 --with-unix-socket-path=/usr/local/mysql/data/mysql.sock --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-named-curses-libs=/usr/lib/libncursesw.so.5

 

 

./configure --prefix=/usr/local/mysql --with-named-curses-libs=/usr/lib/libncursesw.so.5

 

MYSQL编译安装时碰到的问题:

 

问题一、

configure: error: No curses/termcap library found

解决办法一如下:

./configure --with-named-curses-libs=/usr/lib/libncursesw.so.5

解决方法二如下:

(centos5系统):yum -y install ncurses-devel

其他linux系统请去http://www.rpmfind.net/下载该包安装

 

问题二、

[root@localhost bin]# ./mysql_install_db --user=mysql

 

FATAL ERROR: Could not find /usr/local/mysql/libexec/mysqld

 

 

三、GD库安装

jpeg6安装:./configure --prefix=/usr/local/modules/jpeg6/ --enable-shared –enable-static

 

问题一、

checking host system type... Invalid configuration `x86_64-unknown-linux-gnu': machine `x86_64-unknown' not recognized

 

在做 configure 的时候,报上述的错误。

解决方案:

把 /usr/share/libtool/config.guess 覆盖到相关软件自带的config.guess

把 /usr/share/libtool/config.sub 覆盖到相关软件自带的config.sub

./configure --enable-shared --enable-static

make libdir=/usr/lib64

make libdir=/usr/lib64 install #e4@"A(N#q8q#e5a)G.I4^7e

使用64位函数库编译.

 

这样就可以通过了。

libpng安装:./configure --prefix=/usr/local/modules/libpng/ --enable-shared --enable-static

出现错误,解决办法:更新libpng基础包:yum install libpng*

 

安装PNG:

#tar –zvxf libpng-1.2.24.tar.gz

 

#cd libpng-1.2.24

 

#cp scripts/makefile.gcmmx makefile

 

#./configure –prefix=/usr/local/libpng2

 

#vi Makefile

 

找到CFLAGS= -g –O2后面加上 –fPIC (这里是关键)

 

#make && make

 

安装Zlib(zlib-1.2.3):

第一步:安装zlib基本库:yum install zlib*

第二部:更新zlib库:yum update zlib*

第三步:#cd zlib-xxx/ #./configure

第四步:config后修改Makefile文件

找到

CFLAGS= -DUSE_MMAP

修改为 CFLAGS=-O3 -DUSE_MMAP -fPIC

第五步:make && make install

其中第三步和第四步也可以由下面一步代替

或者使用以下选项进行编译

CFLAGS="-O3 -DUSE_MMAP -fPIC" ./configure

 

 

GD编译配置

./configure --prefix=/usr/local/modules/gd --with-jpeg=/usr/local/modules/jpeg6 --with-png=/usr/local/modules/libpng --with-zlib --with-freetype=/usr/local/modules/freetype

 

四、PHP安装

./configure --prefix=/usr/local/php5 --with-gd=/usr/local/modules/gd --with-jpeg-dir=/usr/local/modules/jpeg6 --with-zlib --with-png-dir=/usr/local/modules/libpng --with-freetype-dir=/usr/local/modules/freetype --with-libxpm --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-iconv --enable-mbstring --with-pear --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php5/etc --with-libxml-dir=/usr/lib --with-curl

 

./configure --prefix=/usr/local/php5 --with-gd --with-jpeg-dir --with-zlib --with-png-dir --with-freetype-dir --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-iconv --enable-mbstring --with-pear --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php5/etc --with-libxml

 

 

/usr/bin/ld: /usr/local/lib/libz.a(compress.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC

/usr/local/lib/libz.a: could not read symbols: Bad value

collect2: ld returned 1 exit status

make: *** [libphp5.la] 错误 1

 

解决方法:

方法一、安装zlib包已经zlib-devel包,就OK了

方法二、

 

编译gdlib库碰到undefined reference to `png_check_sig’问题解决

 

采用源码方式编译php,需要gd库,同样采用源码编译,在编译过程中碰到 undefined reference to `png_check_sig’ 错误。

google了一下,发现由于使用的新的 libpng 1.4版本,去掉了png_check_sig函数,替换为了png_sig_check函数

,于是编辑gd库的 gd_png.c文件,将

 

1.

if (!png_check_sig (sig, 8)) { /* bad signature */

2.

return NULL;

3.

}

 

修改为

 

1.

if (png_sig_cmp (sig, 0, 8)) { /* bad signature 注意这里的参数不同*/

2.

return NULL;

3.

}

 

再次编译通过

 

错误一、

ext/gd/libgd/.libs/gd_png.o: In function `php_gd_gdImageCreateFromPngCtx':

/root/downloads/php-5.2.13/ext/gd/libgd/gd_png.c:142: undefined reference to `png_check_sig'

collect2: ld returned 1 exit status

make: *** [sapi/cli/php] 错误 1

 

把 `png_check_sig' 改为了 ‘png_sig_cmp’

 

[url]http://aspn.activestate.com/ASPN/Mail/Message/php-dev/3803631[/url]

可以算是php的一个bug,libpng-1.4.0源码中的libpng-1.4.0.txt有说明,已经取消了png_check_sig这个函数,改用png_sig_cmp代替.自从libpng-0.90就已经反对使用png_check_sig函数了.这个帖子中采用修改php源码的方法,编辑ext/gd/libgd/gd_png.c,将

if (!png_check_sig (sig, 8)) { /* bad signature */

换成

if (png_sig_cmp (sig, 0, 8)) { /* bad signature */

但我不知道其他哪些地方有没有这个函数,所以我还是用libpng-1.2.35吧,看libpng-1.2.35.txt,就没有提png_check_sig的事.

编译安装libpng-1.2.35后,php-5.2.12的make通过了

 

现在编译通过了。

 

 

APACHE启动报错:

/usr/local/apache2/bin/apachectl restart

Warning: DocumentRoot [/usr/local/apache2/docs/dummy-host.example.com] does not exist

Warning: DocumentRoot [/usr/local/apache2/docs/dummy-host2.example.com] does not exist

 

原因:

/usr/local/apache2/conf/extra/httpd-vhosts.conf 中一些 DocumentRoot不存在于之对应的实体文件。

 

linux下php扩展cURL的安装

方法一

 

  安装cURL

 

   # wget http://curl.haxx.se/download/curl-7.17.1.tar.gz

 

   # tar -zxf curl-7.17.1.tar.gz

 

   # ./configure --prefix=/usr/local/curl

 

   # make; make install

 

  安装php

 

   只要打开开关 --with-curl=/usr/local/curl

 

   就可以了。

 

   这个扩展库还是非常棒,是fsockopen等等相关的有效的替代品。

 

  方法二

 

  进入安装原php的源码目录,

 

  cd ext

 

  cd curl

 

  phpize

 

  ./configure --with-curl=DIR

 

  make

 

  就会在PHPDIR/ext/curl/moudles/下生成curl.so的文件。

 

  复制curl.so文件到extensions的配置目录,修改php.ini就好了

 

问题

配置php支持curl的时候, 出现如下报错

checking for cURL in default path... not found

configure: error: Please reinstall the libcurl distribution -

easy.h should be in /include/curl/

 

原因其实就是curl的dev包没有安装, 解决方案:

终端下

 

# yum -y install curl-devel

 

然后就可以继续了

 

PHP扩展包的安装(这里以 mcrypt为例,环境为Centos5.4系统):

第一步:先确认安装了安装包的基础包,通常使用系统更新安装即可:

yum list libmcrypt*

yum install libmcrypt*

第二步:进入PHP源码解压后的目录中,如我这里是php-5.2.13,#cd /root/downloads/php-5.2.13/ext/mcrypt

如果没有mcrypt则需要到网站上去下载,通常是自带了的。

第三步:执行phpize, #/usr/local/php5/bin/phpize

第四步:编译configure: ./configure --with-php-config=/usr/local/php5/bin/php-config

这里需要指定php-config的目录,然后仔细make,这里将生成一个mcrypt.so文件在 ./modules/mcrypt.so

第五步:拷贝./modules/mcrypt.so 到 php 的extension_dir 目录中.

cp ./modules/mcrypt.so /usr/local/php5/include/php/include/

第六步:确定php.ini文件中的 extension_dir= /usr/local/php5/include/php/include/

然后加上 extension = mcrypt.so;

第七步:重启apache,查看phpinfo看mcrypt是否已经加上。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics