执行make编译php时遇到libiconv_open的链接错误。原因可能是链接器到不到对应的libiconv库。
解决方法:
重新配置Makefile:
./configure --with-apxs2 -enable-cli -with-oci8=instantclient,/opt/oracle/instantclient/ --with-iconv=shared,/usr/local/
PHP编译安装完成之后,运行下面的命令:
$ php --ini
会出现如下的Warning:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20090626/oci8.so' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20090626/oci8.so, 9): image not found in Unknown on line 0
这时需要pecl命令安装PHP的OCI扩展:
pecl install oci8 (online mode)
pecl install oci8-1.3.5.tgz (offline mode)
上面的oci8-1.3.5.tgz可以从下面的地址取得:
http://pecl.php.net/get/oci8-1.3.5.tgz
调用oci_connect函数时,总是出现下面的错误:
Warning: oci_connect() [function.oci-connect]: OCIEnvNlsCreate() failed. There is something wrong with your system - please check that PATH includes the directory with Oracle Instant Client liberaries.
检查了很久,原来是apache的环境变量搞错了(注意了,这是在MAC环境下):
/System/Library/LaunchDaemons/org.apache.httpd.plist
<key>EnvironmentVariables</key>
<dict>
<key>DYLD_LIBRARY_PATH</key>
<string>/usr/lib:/opt/oracle/instantclient</string>
</dict>
下面的代码可以输出这个环境变量:
<?php
echo '<pre>';
print_r($_ENV);
echo '</pre>';
?>