{"id":53591,"date":"2024-10-09T12:34:15","date_gmt":"2024-10-09T04:34:15","guid":{"rendered":"https:\/\/server.hk\/cnblog\/53591\/"},"modified":"2024-10-09T12:34:15","modified_gmt":"2024-10-09T04:34:15","slug":"phpiis7-%e9%85%8d%e7%bd%ae-oci8-%e9%80%a3%e6%8e%a5-oracle-10g-%e7%9a%84%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/53591\/","title":{"rendered":"PHP+IIS7 \u914d\u7f6e OCI8 \u9023\u63a5 Oracle 10G \u7684\u65b9\u6cd5"},"content":{"rendered":"<h1 id=\"phpiis7-%e9%85%8d%e7%bd%ae-oci8-%e9%80%a3%e6%8e%a5-oracle-10g-%e7%9a%84%e6%96%b9%e6%b3%95-OmSbRLjPro\">PHP+IIS7 \u914d\u7f6e OCI8 \u9023\u63a5 Oracle 10G \u7684\u65b9\u6cd5<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u7db2\u7d61\u74b0\u5883\u4e2d\uff0cPHP \u548c Oracle \u6578\u64da\u5eab\u7684\u7d50\u5408\u8d8a\u4f86\u8d8a\u53d7\u5230\u958b\u767c\u8005\u7684\u9752\u775e\u3002\u7279\u5225\u662f\u5728\u4f7f\u7528 IIS7 \u4f5c\u70ba\u4f3a\u670d\u5668\u6642\uff0c\u914d\u7f6e OCI8 \u64f4\u5c55\u4ee5\u9023\u63a5 Oracle 10G \u6578\u64da\u5eab\u7684\u904e\u7a0b\u53ef\u80fd\u6703\u8b93\u4e00\u4e9b\u958b\u767c\u8005\u611f\u5230\u56f0\u60d1\u3002\u672c\u6587\u5c07\u8a73\u7d30\u4ecb\u7d39\u5982\u4f55\u5728 Windows \u74b0\u5883\u4e0b\u914d\u7f6e PHP \u548c OCI8\uff0c\u4ee5\u4fbf\u9806\u5229\u9023\u63a5\u5230 Oracle 10G \u6578\u64da\u5eab\u3002<\/p>\n<h2 id=\"%e5%89%8d%e6%9c%9f%e6%ba%96%e5%82%99-OmSbRLjPro\">\u524d\u671f\u6e96\u5099<\/h2>\n<p>\u5728\u958b\u59cb\u4e4b\u524d\uff0c\u60a8\u9700\u8981\u78ba\u4fdd\u4ee5\u4e0b\u5e7e\u9ede\uff1a<\/p>\n<ul>\n<li>\u5df2\u5b89\u88dd PHP\uff0c\u5efa\u8b70\u4f7f\u7528 PHP 5.3 \u6216\u66f4\u9ad8\u7248\u672c\u3002<\/li>\n<li>\u5df2\u5b89\u88dd Oracle 10G \u6578\u64da\u5eab\u3002<\/li>\n<li>\u5df2\u5b89\u88dd IIS7 \u4f5c\u70ba Web \u4f3a\u670d\u5668\u3002<\/li>\n<li>\u4e0b\u8f09\u4e26\u5b89\u88dd Oracle Instant Client\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%ae%89%e8%a3%9d-oracle-instant-client-OmSbRLjPro\">\u5b89\u88dd Oracle Instant Client<\/h2>\n<p>Oracle Instant Client \u662f\u4e00\u500b\u8f15\u91cf\u7d1a\u7684\u5ba2\u6236\u7aef\uff0c\u5141\u8a31 PHP \u9023\u63a5\u5230 Oracle \u6578\u64da\u5eab\u3002\u60a8\u53ef\u4ee5\u5f9e Oracle \u5b98\u65b9\u7db2\u7ad9\u4e0b\u8f09\u6700\u65b0\u7248\u672c\u7684 Instant Client\u3002\u4e0b\u8f09\u5f8c\uff0c\u8acb\u6309\u7167\u4ee5\u4e0b\u6b65\u9a5f\u9032\u884c\u5b89\u88dd\uff1a<\/p>\n<ol>\n<li>\u89e3\u58d3\u7e2e\u4e0b\u8f09\u7684\u6587\u4ef6\u5230\u4e00\u500b\u76ee\u9304\uff0c\u4f8b\u5982 C:oracleinstantclient\u3002<\/li>\n<li>\u5c07\u8a72\u76ee\u9304\u6dfb\u52a0\u5230\u7cfb\u7d71\u7684\u74b0\u5883\u8b8a\u91cf PATH \u4e2d\uff0c\u4ee5\u4fbf PHP \u80fd\u5920\u627e\u5230 Oracle \u5ba2\u6236\u7aef\u3002<\/li>\n<\/ol>\n<h2 id=\"%e9%85%8d%e7%bd%ae-php-%e7%9a%84-oci8-%e6%93%b4%e5%b1%95-OmSbRLjPro\">\u914d\u7f6e PHP \u7684 OCI8 \u64f4\u5c55<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u914d\u7f6e PHP \u7684 OCI8 \u64f4\u5c55\u3002\u9019\u53ef\u4ee5\u901a\u904e\u4ee5\u4e0b\u6b65\u9a5f\u5b8c\u6210\uff1a<\/p>\n<ol>\n<li>\u4e0b\u8f09\u9069\u5408\u60a8 PHP \u7248\u672c\u7684 OCI8 DLL \u6587\u4ef6\u3002\u60a8\u53ef\u4ee5\u5f9e PECL \u7db2\u7ad9\u7372\u53d6\u3002<\/li>\n<li>\u5c07\u4e0b\u8f09\u7684 DLL \u6587\u4ef6\u653e\u5165 PHP \u7684 ext \u76ee\u9304\u4e2d\uff0c\u4f8b\u5982 C:phpext\u3002<\/li>\n<li>\u6253\u958b php.ini \u6587\u4ef6\uff0c\u4e26\u6dfb\u52a0\u4ee5\u4e0b\u884c\u4ee5\u555f\u7528 OCI8 \u64f4\u5c55\uff1a<\/li>\n<pre><code>extension=php_oci8.dll<\/code><\/pre>\n<li>\u78ba\u4fdd\u5728 php.ini \u4e2d\u8a2d\u7f6e\u4e86\u6b63\u78ba\u7684 Oracle Instant Client \u8def\u5f91\uff1a<\/li>\n<pre><code>extension_dir = \"C:phpext\"<\/code><\/pre>\n<li>\u91cd\u555f IIS \u4f3a\u670d\u5668\u4ee5\u4f7f\u66f4\u6539\u751f\u6548\u3002<\/li>\n<\/ol>\n<h2 id=\"%e6%b8%ac%e8%a9%a6-oci8-%e9%80%a3%e6%8e%a5-OmSbRLjPro\">\u6e2c\u8a66 OCI8 \u9023\u63a5<\/h2>\n<p>\u5b8c\u6210\u4e0a\u8ff0\u6b65\u9a5f\u5f8c\uff0c\u60a8\u53ef\u4ee5\u901a\u904e\u5275\u5efa\u4e00\u500b\u7c21\u55ae\u7684 PHP \u8173\u672c\u4f86\u6e2c\u8a66 OCI8 \u662f\u5426\u914d\u7f6e\u6210\u529f\u3002\u8acb\u5275\u5efa\u4e00\u500b\u540d\u70ba test_oci8.php \u7684\u6587\u4ef6\uff0c\u4e26\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u78bc\uff1a<\/p>\n<pre><code>&lt;?php\n$conn = oci_connect('username', 'password', 'localhost\/XE');\nif (!$conn) {\n    $e = oci_error();\n    echo \"Connection failed: \" . $e['message'];\n} else {\n    echo \"Connection successful!\";\n    oci_close($conn);\n}\n?&gt;<\/code><\/pre>\n<p>\u8acb\u5c07 &#8216;username&#8217; \u548c &#8216;password&#8217; \u66ff\u63db\u70ba\u60a8\u7684 Oracle \u6578\u64da\u5eab\u7528\u6236\u540d\u548c\u5bc6\u78bc\u3002\u7136\u5f8c\u5728\u700f\u89bd\u5668\u4e2d\u8a2a\u554f\u8a72\u6587\u4ef6\uff0c\u60a8\u61c9\u8a72\u80fd\u770b\u5230\u9023\u63a5\u6210\u529f\u7684\u6d88\u606f\u3002<\/p>\n<h2 id=\"%e5%b8%b8%e8%a6%8b%e5%95%8f%e9%a1%8c-OmSbRLjPro\">\u5e38\u898b\u554f\u984c<\/h2>\n<h3 id=\"1-%e7%82%ba%e4%bb%80%e9%ba%bc%e6%9c%83%e5%87%ba%e7%8f%be%e9%80%a3%e6%8e%a5%e5%a4%b1%e6%95%97%e7%9a%84%e9%8c%af%e8%aa%a4%ef%bc%9f-OmSbRLjPro\">1. \u70ba\u4ec0\u9ebc\u6703\u51fa\u73fe\u9023\u63a5\u5931\u6557\u7684\u932f\u8aa4\uff1f<\/h3>\n<p>\u9019\u53ef\u80fd\u662f\u7531\u65bc\u4ee5\u4e0b\u539f\u56e0\u9020\u6210\u7684\uff1a<\/p>\n<ul>\n<li>Oracle Instant Client \u672a\u6b63\u78ba\u5b89\u88dd\u6216\u672a\u6dfb\u52a0\u5230 PATH \u4e2d\u3002<\/li>\n<li>php.ini \u4e2d\u7684 OCI8 \u64f4\u5c55\u672a\u6b63\u78ba\u555f\u7528\u3002<\/li>\n<li>\u6578\u64da\u5eab\u7528\u6236\u540d\u6216\u5bc6\u78bc\u932f\u8aa4\u3002<\/li>\n<\/ul>\n<h3 id=\"2-%e5%a6%82%e4%bd%95%e6%aa%a2%e6%9f%a5-oci8-%e6%93%b4%e5%b1%95%e6%98%af%e5%90%a6%e5%b7%b2%e5%8a%a0%e8%bc%89%ef%bc%9f-OmSbRLjPro\">2. \u5982\u4f55\u6aa2\u67e5 OCI8 \u64f4\u5c55\u662f\u5426\u5df2\u52a0\u8f09\uff1f<\/h3>\n<p>\u60a8\u53ef\u4ee5\u5275\u5efa\u4e00\u500b PHP \u8173\u672c\uff0c\u4f7f\u7528 phpinfo() \u51fd\u6578\u4f86\u6aa2\u67e5\u5df2\u52a0\u8f09\u7684\u64f4\u5c55\uff1a<\/p>\n<pre><code>&lt;?php\nphpinfo();\n?&gt;<\/code><\/pre>\n<p>\u5728\u8f38\u51fa\u7684\u9801\u9762\u4e2d\u67e5\u627e &#8220;oci8&#8221; \u90e8\u5206\uff0c\u78ba\u8a8d\u5176\u5df2\u6b63\u78ba\u52a0\u8f09\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-OmSbRLjPro\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904e\u4ee5\u4e0a\u6b65\u9a5f\uff0c\u60a8\u61c9\u8a72\u80fd\u5920\u6210\u529f\u914d\u7f6e PHP+IIS7 \u4ee5\u9023\u63a5 Oracle 10G \u6578\u64da\u5eab\u3002\u9019\u4e00\u904e\u7a0b\u96d6\u7136\u6d89\u53ca\u591a\u500b\u6b65\u9a5f\uff0c\u4f46\u53ea\u8981\u6309\u7167\u6307\u793a\u64cd\u4f5c\uff0c\u5c31\u80fd\u9806\u5229\u5b8c\u6210\u3002\u5982\u679c\u60a8\u9700\u8981\u66f4\u9ad8\u6548\u7684\u89e3\u6c7a\u65b9\u6848\uff0c\u8003\u616e\u4f7f\u7528 <a href=\"https:\/\/server.hk\">\u9999\u6e2f VPS<\/a> \u670d\u52d9\u4f86\u63d0\u5347\u60a8\u7684\u61c9\u7528\u6027\u80fd\u548c\u7a69\u5b9a\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to configure OCI8 in PHP on IIS7 to connect to Oracle 10G, ensuring seamless database integration for your applications.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-53591","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/53591","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=53591"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/53591\/revisions"}],"predecessor-version":[{"id":53592,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/53591\/revisions\/53592"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=53591"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=53591"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=53591"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}