您的位置:首页 > 运维架构 > Apache

Windows XP+Apache2.2+PHP5.3+OCI8 痛苦安装总结

2010-10-13 14:53 567 查看
Install Oracle Instance Client

STEP1:Download Oracle instance client from oracle web site. --->instantclient_11_2

STEP2:Unzip oracle instance client basc into D:/oracle/instantclient_11_2

STEP3:Add D:/oracle/instantclient_11_2 into the beginning of PATH environment variable.

Install Php oci8 DLL

STEP1:Download DLL from google search. (1.4 version)

STEP2:Copy PHP_OCI8.DLL into /php/ext directory

STEP3:Add extension=php_oci8.dll into php.ini

Restart Apache: fail

STEP1:Check error message in apache directory :logs/errors.log

error message:

Starting the Apache2.2 service

The Apache2.2 service is running.

] Apache/2.2.15 (Win32) PHP/5.3.2 configured -- resuming normal operations

[Wed Oct 13 10:06:37 2010] [notice] Server built: Mar 4 2010 11:27:46

[Wed Oct 13 10:06:37 2010] [notice] Parent: Created child process 3572

[Wed Oct 13 10:06:37 2010] [debug] mpm_winnt.c(487): Parent: Sent the scoreboard to the child

[Wed Oct 13 10:06:41 2010] [crit] (OS 6)The handle is invalid. : master_main: create child process failed. Exiting.

[Wed Oct 13 10:06:41 2010] [notice] Parent: Forcing termination of child process 36

[Wed Oct 13 10:06:41 2010] [info] removed PID file D:/Program Files/Apache Software Foundation/Apache2.2/logs/httpd.pid (pid=2400)

STEP2:Google with "master_main: create child process failed.Exiting.", nothing find.
STEP3:Check PHP error log file php-errors.log
error message:

[13-Oct-2010 09:25:39] PHP Warning: PHP Startup: oci8: Unable to initialize module
Module compiled with module API=20060613
PHP compiled with module API=20090626
These options need to match
in Unknown on line 0
STEP4:Google with "PHP Warning: PHP Startup: oci8: Unable to initialize module"
And find out the oci8 dll version is not suitable, the version is lower than php 5.3 compiled version.
STEP5:Uninstall PHP 5.3.2 from pc, and download PHP 5.3.3 , and install it with all packages.
Restart Apache: successful
Test OCI8 connection:
STEP1: create test.php file under apache htdocs folder.
STEP2: write source code into test.php file:

<?php
echo "step1 ";
$linkstr="(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = X.X.X.X)(PORT = 1521)))
(CONNECT_DATA =(SERVICE_NAME = XXXX)))";
$conn = oci_connect('user', 'password', $linkstr);
echo "step2 ";
if (!$conn) {
echo "in step1";
trigger_error("Could not connect to database", E_USER_ERROR);
}else{
echo "tina";
}
echo "step3 ";
$SQL="select * from apt_l_spdopt";
echo "step4 ";
$stid = oci_parse($conn, $SQL);
echo "step5 ";
if (!$stid){
trigger_error("Could not parse sql:".$SQL, E_USER_ERROR);
}
echo "step6 ";
oci_execute($stid);
while (($row = oci_fetch_array ($stid, OCI_ASSOC))) { // Ignore NULLs
var_dump($row);
}
echo "step7 ";
oci_free_statement($stid);
oci_close($conn);
?>
STEP5: View test.php with localhost:86/test.php, failed with message(php_errors.log)---->
[13-Oct-2010 03:38:43] PHP Warning: Module 'oci8' already loaded in Unknown on line 0

STEP6:Google with error message, and find that there are two oci8 dll exist in php.ini (php_oci8.dll &php_oci8_11g.dll),
STEP7:Uncomment php_oci8.dll, and refresh test.php. failed with message(php_errors.log)----->

[13-Oct-2010 05:13:48] PHP Warning: oci_connect(): OCIEnvNlsCreate() failed. There is something wrong with your system - please check that PATH includes the directory with Oracle Instant Client libraries in D:/Projects/PHP/APTUpload/jobs/include/libOracle.php on line 44
[13-Oct-2010 05:13:48] PHP Warning: oci_parse() expects parameter 1 to be resource, boolean given in D:/Projects/PHP/APTUpload/jobs/include/libOracle.php on line 198
STEP8:Google with "oci_connect(): OCIEnvNlsCreate() failed", and find out that system cannot find dll library,
STEP9:Copy oci.dll,orannzsbb11.dll,oraociei11.dll,ociw32.dll into C:/WINDOWS/system32 folder, and make sure that mfc71.dll,msvcr71.dll exist in C:/WINDOWS/system32 folder.
Restart Apache : successful
Retest test.php : failed
STEP1:Check php_errors.log, error message--->
[13-Oct-2010 06:11:39] PHP Warning: oci_connect(): ORA-12705: Cannot access NLS data files or invalid environment specified in D:/Program Files/Apache Software Foundation/Apache2.2/htdocs/test.php on line 6
STEP2:注册表里 /HKEY_LOCAL_MACHINE/SOFTWARE/ORACLE 查找键 NLS_LANG,这个键由Oracle标准客户端安装创建, 值是 NA 。这个导致了 ORA-12705错误。解决方法就是修改NA为SIMPLIFIED CHINESE_CHINA.ZHS16GBK。
STEP3:refresh test.php, successfule

The whole process spend two days! it is a very good experience.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: