对于这个问题有个比较久远的帖子 有提及,这个方法我没有测试,另一种说就是因为64位的linux的lib路径有问题加上--with-libdir=lib的编译选项,这个试过加上也是同样的编译报错。
最终找到一个可行的办法就是,编译之前,先处理一下mysql的库,默认查找libmysqlclient_r.so,可是mysql默认为libmysqlclient.so,内容完全一样,做个链接即可
# cd /usr/local/mysql/lib/mysql/
# ln -s libmysqlclient.so.15.0.0 libmysqlclient_r.so
最后成功解决,可以make了,视个人系统环境不同,可能编译出错也不同,其时就是少什么库,就安装什么,对于编译错误找到一个总结比较好的帖子
Generating files
configure: creating ./config.status
creating main/internal_functions.c
creating main/internal_functions_cli.c
+--------------------------------------------------------------------+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+--------------------------------------------------------------------+
Thank you for using PHP.
config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands
make 完成之后,信息提示如下:
Generating phar.php
Generating phar.phar
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
clicommand.inc
directorytreeiterator.inc
invertedregexiterator.inc
directorygraphiterator.inc
pharcommand.inc
phar.inc
Build complete.
Don't forget to run 'make test'.
最终make install 安装完成
[root@localhost php-5.6.19]# make install
Installing PHP SAPI module: apache2handler
/usr/local/apache2/build/instdso.sh SH_LIBTOOL='/usr/local/apr/build-1/libtool' libphp5.la /usr/local/apache2/modules
/usr/local/apr/build-1/libtool --mode=install install libphp5.la /usr/local/apache2/modules/
libtool: install: install .libs/libphp5.so /usr/local/apache2/modules/libphp5.so
libtool: install: install .libs/libphp5.lai /usr/local/apache2/modules/libphp5.la
libtool: install: warning: remember to run `libtool --finish /usr/local/src/php-5.6.19/libs'
chmod 755 /usr/local/apache2/modules/libphp5.so
[activating module `php5' in /etc/httpd/httpd.conf]
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20131226/
Installing PHP CLI binary: /usr/local/php/bin/
Installing PHP CLI man page: /usr/local/php/php/man/man1/
Installing PHP CGI binary: /usr/local/php/bin/
Installing PHP CGI man page: /usr/local/php/php/man/man1/
Installing build environment: /usr/local/php/lib/php/build/
Installing header files: /usr/local/php/include/php/
Installing helper programs: /usr/local/php/bin/
program: phpize
program: php-config
Installing man pages: /usr/local/php/php/man/man1/
page: phpize.1
page: php-config.1
Installing PEAR environment: /usr/local/php/lib/php/
[PEAR] Archive_Tar - installed: 1.4.0
[PEAR] Console_Getopt - installed: 1.4.1
[PEAR] Structures_Graph- installed: 1.1.1
[PEAR] XML_Util - installed: 1.3.0
[PEAR] PEAR - installed: 1.10.1
Wrote PEAR system config file at: /usr/local/php/etc/pear.conf
You may want to add: /usr/local/php/lib/php to your php.ini include_path
/usr/local/src/php-5.6.19/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
ln -s -f phar.phar /usr/local/php/bin/phar
Installing PDO headers: /usr/local/php/include/php/ext/pdo/
查看apache配置文件,发现已经加载了php模块
LoadModule alias_module modules/mod_alias.so
#LoadModule rewrite_module modules/mod_rewrite.so
LoadModule php5_module modules/libphp5.so
在apache安装目录下modules里面有php安装后新增的libphp5.so
[root@localhost php-5.6.19]# ll /usr/local/apache2/modules/libphp5.so
-rwxr-xr-x. 1 root root 34524225 3月 7 00:12 /usr/local/apache2/modules/libphp5.so
以上即可说明php已经正常安装
1、在apache配置文件添加以下语句,实现php文件调用php模块解析
AddType application/x-httpd-php .php
2、复制php源码根目录下的配置文件到/etc
cp php.ini-production /etc/php.ini
至此php已经可以正常工作了
0x04 测试因为apache编译安装的网页文件目录为/usr/local/apache2/htdocs
在其中新增php文件测试能否正常解析,新增经典测试语句
[root@localhost php-5.6.19]# cat /usr/local/apache2/htdocs/phpinfo.php
<?php
phpinfo();
?>