php和mysql是安装在不同的机器上。(centos7.0)
编译php时
./configure \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd\
--with-pdo-mysql=mysqlnd
最后mysql的PDO好像没有加载上去。
解决办法:
1、进入源码包:php-5.5.32/ext/pdo_mysql
/usr/local/services/php/bin/phpize #可以显示出对应号
./configure --with-php-config=/usr/local/services/php/bin/php-config
make && make install
这时就会在该目录下的modules下生成pdo_mysql.so
2、copy文件
cp modules/pdo_mysql.so /usr/local/services/php-5.5.32/lib/php/extensions/no-debug-non-zts-20121212/
3、加入到php.ini文件
extension_dir = "/usr/local/services/php-5.5.32/lib/php/extensions/no-debug-non-zts-20121212/"
extension="pdo_mysql.so"
4、重启php-fpm即可生效。
==============================================
编译libiconv时出现如下错误
./stdio.h:1010:1: error: ‘gets’ undeclared here (not in a function) _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); ^make[2]: *** [progname.o] Error 1make[2]: Leaving directory `/root/libiconv-1.14_2/srclib'make[1]: *** [all] Error 2make[1]: Leaving directory `/root/libiconv-1.14_2/srclib'make: *** [all] Error 2
解决方法:
cd libiconv-1.14/srclib
vim stdio.in.h
通过搜索,定位到_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");这一行,然后在这一行的前后加上条件编译即可,修改后的内容如下:
#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16) _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");#endif
然后再make && make install
============================================
php编译报错
/usr/bin/ld: ext/ldap/.libs/ldap.o: undefined reference to symbol 'ber_strdup'
/usr/bin/ld: note: 'ber_strdup' is defined in DSO /lib64/liblber-2.4.so.2 so try adding it to the linker command line
/lib64/liblber-2.4.so.2: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1
解决办法:
./configure后
编辑MakeFile
找到 开头是 'EXTRA_LIBS' 这一行 在结尾加上 '-llber' 然后执行 make && make install