{"id":49210,"date":"2024-10-08T03:09:14","date_gmt":"2024-10-07T19:09:14","guid":{"rendered":"https:\/\/server.hk\/cnblog\/49210\/"},"modified":"2024-10-08T03:09:14","modified_gmt":"2024-10-07T19:09:14","slug":"windows-%e4%b8%8b-php-5-apache-mysql-5-%e6%89%8b%e5%b7%a5%e6%90%ad%e5%bb%ba%e7%ad%86%e8%a8%98","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/49210\/","title":{"rendered":"Windows \u4e0b PHP 5 + Apache + MySQL 5 \u624b\u5de5\u642d\u5efa\u7b46\u8a18"},"content":{"rendered":"<h1 id=\"windows-%e4%b8%8b-php-5-apache-mysql-5-%e6%89%8b%e5%b7%a5%e6%90%ad%e5%bb%ba%e7%ad%86%e8%a8%98-mKGjEWlEPW\">Windows \u4e0b PHP 5 + Apache + MySQL 5 \u624b\u5de5\u642d\u5efa\u7b46\u8a18<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u7db2\u7d61\u74b0\u5883\u4e2d\uff0cPHP\u3001Apache \u548c MySQL \u662f\u6700\u53d7\u6b61\u8fce\u7684\u958b\u767c\u7d44\u5408\u4e4b\u4e00\u3002\u9019\u7bc7\u6587\u7ae0\u5c07\u6307\u5c0e\u60a8\u5982\u4f55\u5728 Windows \u74b0\u5883\u4e0b\u624b\u52d5\u642d\u5efa PHP 5\u3001Apache \u548c MySQL 5 \u7684\u958b\u767c\u74b0\u5883\uff0c\u8b93\u60a8\u80fd\u5920\u8f15\u9b06\u5730\u958b\u59cb\u958b\u767c\u548c\u6e2c\u8a66\u60a8\u7684\u61c9\u7528\u7a0b\u5e8f\u3002<\/p>\n<h2 id=\"%e7%92%b0%e5%a2%83%e6%ba%96%e5%82%99-mKGjEWlEPW\">\u74b0\u5883\u6e96\u5099<\/h2>\n<p>\u5728\u958b\u59cb\u4e4b\u524d\uff0c\u60a8\u9700\u8981\u78ba\u4fdd\u60a8\u7684 Windows \u7cfb\u7d71\u5df2\u7d93\u5b89\u88dd\u4e86\u4ee5\u4e0b\u8edf\u4ef6\uff1a<\/p>\n<ul>\n<li>Windows \u64cd\u4f5c\u7cfb\u7d71\uff08\u5efa\u8b70\u4f7f\u7528 Windows 10 \u6216\u66f4\u9ad8\u7248\u672c\uff09<\/li>\n<li>PHP 5<\/li>\n<li>Apache HTTP Server<\/li>\n<li>MySQL 5<\/li>\n<\/ul>\n<h2 id=\"%e6%ad%a5%e9%a9%9f%e4%b8%80%ef%bc%9a%e5%ae%89%e8%a3%9d-apache-mKGjEWlEPW\">\u6b65\u9a5f\u4e00\uff1a\u5b89\u88dd Apache<\/h2>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u4e0b\u8f09 Apache HTTP Server\u3002\u53ef\u4ee5\u5f9e Apache \u5b98\u65b9\u7db2\u7ad9\u4e0b\u8f09\u6700\u65b0\u7248\u672c\u7684 Apache 2.x\u3002<\/p>\n<pre><code>1. \u4e0b\u8f09 Apache \u5b89\u88dd\u5305\u3002\n2. \u89e3\u58d3\u7e2e\u5230 C:Apache24\u3002\n3. \u6253\u958b\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u9032\u5165 Apache \u7684 bin \u76ee\u9304\uff1a\n   cd C:Apache24bin\n4. \u5b89\u88dd Apache\uff1a\n   httpd -k install\n5. \u555f\u52d5 Apache\uff1a\n   httpd -k start\n<\/code><\/pre>\n<p>\u5982\u679c\u4e00\u5207\u6b63\u5e38\uff0c\u60a8\u53ef\u4ee5\u5728\u700f\u89bd\u5668\u4e2d\u8f38\u5165 <code>http:\/\/localhost<\/code>\uff0c\u61c9\u8a72\u80fd\u770b\u5230 Apache \u7684\u6b61\u8fce\u9801\u9762\u3002<\/p>\n<h2 id=\"%e6%ad%a5%e9%a9%9f%e4%ba%8c%ef%bc%9a%e5%ae%89%e8%a3%9d-php-mKGjEWlEPW\">\u6b65\u9a5f\u4e8c\uff1a\u5b89\u88dd PHP<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u5b89\u88dd PHP\u3002\u53ef\u4ee5\u5f9e PHP \u5b98\u65b9\u7db2\u7ad9\u4e0b\u8f09 PHP 5 \u7684 Windows \u7248\u672c\u3002<\/p>\n<pre><code>1. \u4e0b\u8f09 PHP 5 \u7684 zip \u5305\u3002\n2. \u89e3\u58d3\u7e2e\u5230 C:php\u3002\n3. \u5c07 C:php \u6dfb\u52a0\u5230\u7cfb\u7d71\u74b0\u5883\u8b8a\u91cf PATH \u4e2d\u3002\n4. \u5728 C:Apache24confhttpd.conf \u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1a\n   LoadModule php5_module \"C:\/php\/php5apache2_4.dll\"\n   AddType application\/x-httpd-php .php\n   PHPIniDir \"C:\/php\"\n<\/code><\/pre>\n<p>\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u5275\u5efa\u4e00\u500b\u6e2c\u8a66 PHP \u6587\u4ef6\uff0c\u6a94\u540d\u70ba <code>info.php<\/code>\uff0c\u5167\u5bb9\u5982\u4e0b\uff1a<\/p>\n<pre><code>&lt;?php\nphpinfo();\n?&gt;<\/code><\/pre>\n<p>\u5c07\u6b64\u6587\u4ef6\u653e\u5728 <code>C:Apache24htdocs<\/code> \u76ee\u9304\u4e0b\uff0c\u7136\u5f8c\u5728\u700f\u89bd\u5668\u4e2d\u8f38\u5165 <code>http:\/\/localhost\/info.php<\/code>\uff0c\u60a8\u61c9\u8a72\u80fd\u770b\u5230 PHP \u7684\u914d\u7f6e\u4fe1\u606f\u3002<\/p>\n<h2 id=\"%e6%ad%a5%e9%a9%9f%e4%b8%89%ef%bc%9a%e5%ae%89%e8%a3%9d-mysql-mKGjEWlEPW\">\u6b65\u9a5f\u4e09\uff1a\u5b89\u88dd MySQL<\/h2>\n<p>\u6700\u5f8c\uff0c\u60a8\u9700\u8981\u5b89\u88dd MySQL\u3002\u53ef\u4ee5\u5f9e MySQL \u5b98\u65b9\u7db2\u7ad9\u4e0b\u8f09 MySQL 5 \u7684\u5b89\u88dd\u5305\u3002<\/p>\n<pre><code>1. \u4e0b\u8f09 MySQL \u5b89\u88dd\u5305\u3002\n2. \u904b\u884c\u5b89\u88dd\u7a0b\u5e8f\uff0c\u6309\u7167\u63d0\u793a\u5b8c\u6210\u5b89\u88dd\u3002\n3. \u8a2d\u7f6e root \u5bc6\u78bc\u4e26\u8a18\u4f4f\u3002\n4. \u555f\u52d5 MySQL \u670d\u52d9\uff1a\n   net start mysql\n<\/code><\/pre>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528 MySQL Workbench \u6216\u547d\u4ee4\u884c\u5de5\u5177\u4f86\u7ba1\u7406\u60a8\u7684\u6578\u64da\u5eab\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u767b\u9304 MySQL\uff1a<\/p>\n<pre><code>mysql -u root -p<\/code><\/pre>\n<h2 id=\"%e6%b8%ac%e8%a9%a6%e6%95%b4%e5%90%88-mKGjEWlEPW\">\u6e2c\u8a66\u6574\u5408<\/h2>\n<p>\u73fe\u5728\uff0c\u60a8\u5df2\u7d93\u6210\u529f\u5b89\u88dd\u4e86 Apache\u3001PHP \u548c MySQL\u3002\u60a8\u53ef\u4ee5\u5275\u5efa\u4e00\u500b\u7c21\u55ae\u7684 PHP \u61c9\u7528\u7a0b\u5e8f\u4f86\u6e2c\u8a66\u5b83\u5011\u7684\u6574\u5408\u3002\u4ee5\u4e0b\u662f\u4e00\u500b\u7c21\u55ae\u7684\u793a\u4f8b\uff1a<\/p>\n<pre><code>&lt;?php\n$conn = new mysqli(\"localhost\", \"root\", \"your_password\", \"test_db\");\n\nif ($conn-&gt;connect_error) {\n    die(\"\u9023\u63a5\u5931\u6557: \" . $conn-&gt;connect_error);\n}\necho \"\u6210\u529f\u9023\u63a5\u5230 MySQL\";\n?&gt;<\/code><\/pre>\n<p>\u5c07\u6b64\u4ee3\u78bc\u653e\u5165\u4e00\u500b\u65b0\u7684 PHP \u6587\u4ef6\u4e2d\uff0c\u4e26\u5728\u700f\u89bd\u5668\u4e2d\u8a2a\u554f\u5b83\u3002\u5982\u679c\u4e00\u5207\u6b63\u5e38\uff0c\u60a8\u61c9\u8a72\u80fd\u770b\u5230\u6210\u529f\u9023\u63a5\u7684\u6d88\u606f\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-mKGjEWlEPW\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904e\u4ee5\u4e0a\u6b65\u9a5f\uff0c\u60a8\u5df2\u7d93\u5728 Windows \u74b0\u5883\u4e0b\u6210\u529f\u642d\u5efa\u4e86 PHP 5\u3001Apache \u548c MySQL 5 \u7684\u958b\u767c\u74b0\u5883\u3002\u9019\u70ba\u60a8\u958b\u767c\u548c\u6e2c\u8a66\u61c9\u7528\u7a0b\u5e8f\u63d0\u4f9b\u4e86\u826f\u597d\u7684\u57fa\u790e\u3002\u5982\u679c\u60a8\u9700\u8981\u66f4\u9ad8\u6548\u7684\u89e3\u6c7a\u65b9\u6848\uff0c\u53ef\u4ee5\u8003\u616e\u4f7f\u7528 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u670d\u52d9\uff0c\u9019\u5c07\u70ba\u60a8\u7684\u61c9\u7528\u63d0\u4f9b\u66f4\u7a69\u5b9a\u7684\u904b\u884c\u74b0\u5883\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u624b\u5de5\u642d\u5efa Windows \u4e0b\u7684 PHP 5\u3001Apache \u548c MySQL 5\uff0c\u63d0\u4f9b\u8be6\u7ec6\u6b65\u9aa4\u548c\u5b9e\u7528\u6280\u5de7\uff0c\u52a9\u4f60\u8f7b\u677e\u642d\u5efa\u5f00\u53d1\u73af\u5883\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-49210","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/49210","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=49210"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/49210\/revisions"}],"predecessor-version":[{"id":49211,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/49210\/revisions\/49211"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=49210"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=49210"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=49210"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}