linux+apache2+php5安装中 "libtool: install: error: cannot install `libphp5.la' to a

1.问题描述

最近工作需要搭建linux+apache2+php5,分别从官网上下了

httpd-2.3.8-deps.tar.bz2

httpd-2.3.8.tar.gz

php-5.3.3.tar

准备开动,没想到刚开始就遇到很多错误,根据错误提示先后安装了libxml2-2.7.3,zlib-1.2.5和libtool-2.4,这些不是重点,不多说了。

开始装apache2,

./configure --prefix=/usr/local/apache2  --enable-rewrite --enable-mods-shared=most  --enable-so --sbindir=/usr/sbin --enable-cgi



make&make install

总算是apache装上了。



该php5了,

./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-libxml-dir=/usr/local/libxml2  --with-mysql=/var/lib/mysql --with-zlib-dir=/usr/local/zlib --enable-zip --with-jpeg-dir=/usr/local/jpeg6 --with-png-dir=/usr/local/libpng --with-iconv --with-gd --with-config-file-path=/usr/local/lib --disable-debug  --enable-short-tags --disable-posix --enable-exif --enable-ftp --enable-sockets  --enable-shared



make

好像也没报错,但是关键的make install,出现如下错误:

/usr/local/apache2/build/instdso.sh SH_LIBTOOL='/usr/local/apache2/build/libtool' libphp5.la /usr/local/apache2/modules

/usr/local/apache2/build/libtool --mode=install cp libphp5.la /usr/local/apache2/modules/

libtool: install: error: cannot install `libphp5.la' to a directory not ending in /home/bruced/php/libs

apxs:Error: Command failed with rc=65536



网上搜了下很多人出现这样的问题,但都没有有效的解决办法,折腾了好几天,期间apache和php分别make clean &configure&make&makeinstall无数次。



2.解决方案

最后,盯着错误 libtool: install: error: cannot install `libphp5.la' to a directory not ending in /home/bruced/php/libs  突发奇想,不是libphp5.la只能build在/home/bruced/php/libs中么,那我在这build好,再拷到/usr/local/apache2/modules下面去行不行?



于是在php安装目录下:

/usr/local/apache2/build/libtool --mode=install cp libphp5.la /home/bruced/php/libs

这样在/home/bruced/php/libs 便生成了libphp5.la和libphp5.so,把他们拷到/usr/local/apache2/modules中去!



对php,make clean,重新config,这次去掉 --with-apxs2=/usr/local/apache2/bin/apxs选项:

./configure --prefix=/usr/local/php5  --with-libxml-dir=/usr/local/libxml2  --with-mysql=/var/lib/mysql --with-zlib-dir=/usr/local/zlib --enable-zip --with-jpeg-dir=/usr/local/jpeg6 --with-png-dir=/usr/local/libpng --with-iconv --with-gd --with-config-file-path=/usr/local/lib --disable-debug  --enable-short-tags --disable-posix --enable-exif --enable-ftp --enable-sockets  --enable-shared



make&make install,php安装成功。

修改httpd.conf

添加

LoadModule php5_module modules/libphp5.so

AddType application/x-httpd-php .php



重启httpd进程:

httpd -k restart



在/usr/local/apache2/htdocs 写个测试页面:test.php

内容,打开浏览器:http://localhost/test/php

终于看到了久违的页面。




3.tips

1)apache config时,一定要加--enable-so选项,这样php就能以动态模块编译到apache中去

2)重新安装前记着make clean

3)如果重新安装出现以前没有的错误,在执行2)后把原来安装好的 /usr/local/php5 等这些全删掉

4)还是不行的话把source code删掉,重新解压一份tar包折腾。

 

你可能感兴趣的:(apache,mysql,linux,PHP,浏览器)