{"id":49496,"date":"2024-10-08T05:08:15","date_gmt":"2024-10-07T21:08:15","guid":{"rendered":"https:\/\/server.hk\/cnblog\/49496\/"},"modified":"2024-10-08T05:08:15","modified_gmt":"2024-10-07T21:08:15","slug":"php-iis-7-%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\/49496\/","title":{"rendered":"PHP + IIS 7 \u914d\u7f6e OCI8 \u9023\u63a5 Oracle 10G \u7684\u65b9\u6cd5"},"content":{"rendered":"<h1 id=\"php-iis-7-%e9%85%8d%e7%bd%ae-oci8-%e9%80%a3%e6%8e%a5-oracle-10g-%e7%9a%84%e6%96%b9%e6%b3%95-rBtOylfkBY\">PHP + IIS 7 \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 Windows Server \u7684 IIS 7 \u74b0\u5883\u4e2d\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 IIS 7 \u4e0a\u914d\u7f6e PHP \u4ee5\u4f7f\u7528 OCI8 \u9023\u63a5 Oracle 10G \u6578\u64da\u5eab\u3002<\/p>\n<h2 id=\"%e5%89%8d%e6%9c%9f%e6%ba%96%e5%82%99-rBtOylfkBY\">\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\u4e26\u4e14\u7248\u672c\u652f\u6301 OCI8 \u64f4\u5c55\u3002<\/li>\n<li>\u5df2\u5b89\u88dd Oracle 10G \u6578\u64da\u5eab\uff0c\u4e26\u4e14\u80fd\u5920\u6b63\u5e38\u904b\u884c\u3002<\/li>\n<li>\u5df2\u5b89\u88dd Oracle Instant Client\uff0c\u9019\u662f OCI8 \u64f4\u5c55\u6b63\u5e38\u904b\u884c\u7684\u5fc5\u8981\u689d\u4ef6\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%ae%89%e8%a3%9d-oracle-instant-client-rBtOylfkBY\">\u5b89\u88dd Oracle Instant Client<\/h2>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u4e0b\u8f09 Oracle Instant Client\u3002\u8acb\u9075\u5faa\u4ee5\u4e0b\u6b65\u9a5f\uff1a<\/p>\n<ol>\n<li>\u8a2a\u554f <a href=\"https:\/\/www.oracle.com\/database\/technologies\/instant-client\/winx64-64-downloads.html\" rel=\"nofollow noopener\" target=\"_blank\">Oracle Instant Client \u4e0b\u8f09\u9801\u9762<\/a>\u3002<\/li>\n<li>\u9078\u64c7\u9069\u5408\u60a8\u7cfb\u7d71\u7684\u7248\u672c\uff08\u4f8b\u5982\uff0cWindows x64\uff09\u3002<\/li>\n<li>\u4e0b\u8f09\u4e26\u89e3\u58d3\u7e2e\u5230\u4e00\u500b\u76ee\u9304\uff0c\u4f8b\u5982 C:oracleinstantclient_19_8\u3002<\/li>\n<li>\u5c07\u8a72\u76ee\u9304\u6dfb\u52a0\u5230\u7cfb\u7d71\u7684\u74b0\u5883\u8b8a\u91cf PATH \u4e2d\u3002<\/li>\n<\/ol>\n<h2 id=\"%e9%85%8d%e7%bd%ae-php-%e7%9a%84-oci8-%e6%93%b4%e5%b1%95-rBtOylfkBY\">\u914d\u7f6e PHP \u7684 OCI8 \u64f4\u5c55<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u914d\u7f6e PHP \u4ee5\u4f7f\u7528 OCI8 \u64f4\u5c55\uff1a<\/p>\n<ol>\n<li>\u627e\u5230 PHP \u7684\u914d\u7f6e\u6587\u4ef6 php.ini\u3002\u901a\u5e38\u4f4d\u65bc PHP \u5b89\u88dd\u76ee\u9304\u4e0b\u3002<\/li>\n<li>\u6253\u958b php.ini \u6587\u4ef6\uff0c\u4e26\u627e\u5230\u4ee5\u4e0b\u884c\uff1a<\/li>\n<pre><code>;extension=oci8_12c.dll<\/code><\/pre>\n<li>\u5c07\u8a72\u884c\u524d\u7684\u5206\u865f\u53bb\u6389\uff0c\u4e26\u78ba\u4fdd\u5b83\u6307\u5411\u6b63\u78ba\u7684 DLL \u6587\u4ef6\u3002\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662f\u4e0d\u540c\u7248\u672c\u7684 Oracle Instant Client\uff0c\u8acb\u6839\u64da\u9700\u8981\u8abf\u6574\u3002<\/li>\n<li>\u4fdd\u5b58\u4e26\u95dc\u9589 php.ini \u6587\u4ef6\u3002<\/li>\n<\/ol>\n<h2 id=\"%e9%85%8d%e7%bd%ae-iis-7-rBtOylfkBY\">\u914d\u7f6e IIS 7<\/h2>\n<p>\u5728 IIS 7 \u4e2d\uff0c\u60a8\u9700\u8981\u78ba\u4fdd PHP \u6b63\u78ba\u904b\u884c\uff1a<\/p>\n<ol>\n<li>\u6253\u958b IIS \u7ba1\u7406\u5668\uff0c\u9078\u64c7\u60a8\u7684\u7db2\u7ad9\u3002<\/li>\n<li>\u5728\u53f3\u5074\u7684\u529f\u80fd\u9762\u677f\u4e2d\uff0c\u627e\u5230\u201c\u8655\u7406\u7a0b\u5e8f\u6620\u5c04\u201d\u3002<\/li>\n<li>\u78ba\u4fdd PHP \u7684\u8655\u7406\u7a0b\u5e8f\u5df2\u6b63\u78ba\u6dfb\u52a0\u3002\u5982\u679c\u6c92\u6709\uff0c\u60a8\u9700\u8981\u624b\u52d5\u6dfb\u52a0 PHP \u7684\u8655\u7406\u7a0b\u5e8f\u3002<\/li>\n<\/ol>\n<h2 id=\"%e6%b8%ac%e8%a9%a6-oci8-%e9%80%a3%e6%8e%a5-rBtOylfkBY\">\u6e2c\u8a66 OCI8 \u9023\u63a5<\/h2>\n<p>\u5b8c\u6210\u4e0a\u8ff0\u6b65\u9a5f\u5f8c\uff0c\u60a8\u53ef\u4ee5\u5275\u5efa\u4e00\u500b PHP \u6e2c\u8a66\u6587\u4ef6\u4f86\u6aa2\u67e5 OCI8 \u662f\u5426\u6b63\u5e38\u5de5\u4f5c\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>\u5c07\u4e0a\u8ff0\u4ee3\u78bc\u4fdd\u5b58\u70ba test.php\uff0c\u7136\u5f8c\u5728\u700f\u89bd\u5668\u4e2d\u8a2a\u554f\u8a72\u6587\u4ef6\u3002\u5982\u679c\u4e00\u5207\u6b63\u5e38\uff0c\u60a8\u61c9\u8a72\u6703\u770b\u5230\u201cConnection successful!\u201d\u7684\u6d88\u606f\u3002<\/p>\n<h2 id=\"%e5%b8%b8%e8%a6%8b%e5%95%8f%e9%a1%8c-rBtOylfkBY\">\u5e38\u898b\u554f\u984c<\/h2>\n<h3 id=\"1-%e7%82%ba%e4%bb%80%e9%ba%bc%e6%88%91%e7%84%a1%e6%b3%95%e9%80%a3%e6%8e%a5%e5%88%b0-oracle-%e6%95%b8%e6%93%9a%e5%ba%ab%ef%bc%9f-rBtOylfkBY\">1. \u70ba\u4ec0\u9ebc\u6211\u7121\u6cd5\u9023\u63a5\u5230 Oracle \u6578\u64da\u5eab\uff1f<\/h3>\n<p>\u8acb\u6aa2\u67e5\u60a8\u7684\u7528\u6236\u540d\u3001\u5bc6\u78bc\u548c\u6578\u64da\u5eab\u9023\u63a5\u5b57\u7b26\u4e32\u662f\u5426\u6b63\u78ba\u3002\u6b64\u5916\uff0c\u78ba\u4fdd Oracle \u6578\u64da\u5eab\u6b63\u5728\u904b\u884c\uff0c\u4e26\u4e14\u9632\u706b\u7246\u672a\u963b\u6b62\u9023\u63a5\u3002<\/p>\n<h3 id=\"2-oci8-%e6%93%b4%e5%b1%95%e6%9c%aa%e5%8a%a0%e8%bc%89%ef%bc%8c%e8%a9%b2%e6%80%8e%e9%ba%bc%e8%be%a6%ef%bc%9f-rBtOylfkBY\">2. OCI8 \u64f4\u5c55\u672a\u52a0\u8f09\uff0c\u8a72\u600e\u9ebc\u8fa6\uff1f<\/h3>\n<p>\u8acb\u6aa2\u67e5 php.ini \u6587\u4ef6\u4e2d\u7684\u64f4\u5c55\u914d\u7f6e\u662f\u5426\u6b63\u78ba\uff0c\u4e26\u78ba\u4fdd Oracle Instant Client \u7684\u8def\u5f91\u5df2\u6dfb\u52a0\u5230\u7cfb\u7d71\u74b0\u5883\u8b8a\u91cf\u4e2d\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-rBtOylfkBY\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904e\u4ee5\u4e0a\u6b65\u9a5f\uff0c\u60a8\u61c9\u8a72\u80fd\u5920\u5728 IIS 7 \u4e0a\u6210\u529f\u914d\u7f6e PHP \u4ee5\u4f7f\u7528 OCI8 \u9023\u63a5 Oracle 10G \u6578\u64da\u5eab\u3002\u9019\u6a23\u7684\u914d\u7f6e\u4e0d\u50c5\u80fd\u63d0\u9ad8\u61c9\u7528\u7a0b\u5e8f\u7684\u6027\u80fd\uff0c\u9084\u80fd\u5145\u5206\u5229\u7528 Oracle \u6578\u64da\u5eab\u7684\u5f37\u5927\u529f\u80fd\u3002\u5982\u679c\u60a8\u9700\u8981\u9032\u4e00\u6b65\u7684\u652f\u6301\u6216\u5c0b\u627e\u5408\u9069\u7684 <a href=\"https:\/\/server.hk\">\u9999\u6e2f VPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0c\u8acb\u96a8\u6642\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9\u4ee5\u7372\u53d6\u66f4\u591a\u4fe1\u606f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2\u5982\u4f55\u5728 IIS 7 \u4e0a\u914d\u7f6e PHP \u4ee5\u4f7f\u7528 OCI8 \u9023\u63a5 Oracle 10G\uff0c\u7c21\u55ae\u6b65\u9a5f\u52a9\u4f60\u8f15\u9b06\u5be6\u73fe\u6578\u64da\u5eab\u9023\u63a5\u3002<\/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-49496","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/49496","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=49496"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/49496\/revisions"}],"predecessor-version":[{"id":49497,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/49496\/revisions\/49497"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=49496"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=49496"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=49496"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}