{"id":1007,"date":"2026-06-04T23:13:14","date_gmt":"2026-06-04T15:13:14","guid":{"rendered":"https:\/\/www.loongdi.net\/blog\/?p=1007"},"modified":"2026-06-04T23:13:14","modified_gmt":"2026-06-04T15:13:14","slug":"%e5%9f%ba%e7%a1%80linux%e6%9c%8d%e5%8a%a1%e5%99%a8%e6%90%ad%e5%bb%ba%e6%95%99%e7%a8%8b%ef%bc%9a%e7%ae%80%e6%98%93%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"https:\/\/www.loongdi.net\/blog\/1007.html","title":{"rendered":"\u57fa\u7840Linux\u670d\u52a1\u5668\u642d\u5efa\u6559\u7a0b\uff1a\u7b80\u6613\u6307\u5357"},"content":{"rendered":"<p><p>\u670d\u52a1\u5668\u642d\u5efa\u6559\u7a0b<\/p>\n<\/p>\n<p><p>\u672c\u6587\u5c06\u6307\u5bfc\u60a8\u5982\u4f55\u642d\u5efa\u4e00\u4e2a\u57fa\u7840\u7684Linux\u670d\u52a1\u5668\u3002\u6211\u4eec\u5c06\u4f7f\u7528Ubuntu 20.04\u4f5c\u4e3a\u64cd\u4f5c\u7cfb\u7edf\uff0c\u5e76\u914d\u7f6eApache\u4f5c\u4e3aWeb\u670d\u52a1\u5668\uff0cMySQL\u4f5c\u4e3a\u6570\u636e\u5e93\u670d\u52a1\u5668\uff0c\u4ee5\u53caPHP\u4f5c\u4e3a\u670d\u52a1\u5668\u7aef\u811a\u672c\u8bed\u8a00\u3002<\/p>\n<\/p>\n<p><h2>\u64cd\u4f5c\u524d\u7684\u51c6\u5907\u6216\u80cc\u666f\u4ecb\u7ecd<\/h2>\n<\/p>\n<ul>\n<li>\u4e00\u53f0\u5df2\u7ecf\u5b89\u88c5\u4e86Ubuntu 20.04\u7684\u670d\u52a1\u5668\u6216VPS\u3002<\/li>\n<li>\u4e00\u4e2a\u53ef\u4ee5\u8fdc\u7a0b\u8bbf\u95ee\u670d\u52a1\u5668\u7684SSH\u5ba2\u6237\u7aef\uff0c\u4f8b\u5982PuTTY\u3002<\/li>\n<li>\u57fa\u7840\u7684Linux\u547d\u4ee4\u884c\u77e5\u8bc6\u3002<\/li>\n<\/ul>\n<p><h2>1. \u66f4\u65b0\u7cfb\u7edf\u8f6f\u4ef6\u5305<\/h2>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u66f4\u65b0\u7cfb\u7edf\u7684\u8f6f\u4ef6\u5305\u4ee5\u83b7\u53d6\u6700\u65b0\u7684\u8f6f\u4ef6\u7248\u672c\u3002<\/p>\n<\/p>\n<p><pre><code>sudo apt update<\/p>\r\n<p>sudo apt upgrade<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u89e3\u91ca\uff1a`apt update` \u547d\u4ee4\u7528\u4e8e\u66f4\u65b0\u7cfb\u7edf\u8f6f\u4ef6\u5305\u5217\u8868\uff0c\u800c `apt upgrade` \u547d\u4ee4\u7528\u4e8e\u5347\u7ea7\u5df2\u5b89\u88c5\u7684\u8f6f\u4ef6\u5305\u5230\u6700\u65b0\u7248\u672c\u3002<\/p>\n<\/p>\n<p><h2>2. \u5b89\u88c5Apache\u670d\u52a1\u5668<\/h2>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u5b89\u88c5Apache Web\u670d\u52a1\u5668\u3002<\/p>\n<\/p>\n<p><pre><code>sudo apt install apache2<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u89e3\u91ca\uff1a`apache2` \u662fUbuntu\u7cfb\u7edf\u4e2dApache\u670d\u52a1\u5668\u8f6f\u4ef6\u5305\u7684\u540d\u79f0\u3002<\/p>\n<\/p>\n<p><h2>3. \u542f\u52a8Apache\u5e76\u8bbe\u7f6e\u5f00\u673a\u81ea\u542f<\/h2>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u9700\u8981\u542f\u52a8Apache\u670d\u52a1\uff0c\u5e76\u786e\u4fdd\u5b83\u5728\u7cfb\u7edf\u542f\u52a8\u65f6\u81ea\u52a8\u8fd0\u884c\u3002<\/p>\n<\/p>\n<p><pre><code>sudo systemctl start apache2<\/p>\r\n<p>sudo systemctl enable apache2<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u89e3\u91ca\uff1a`systemctl start apache2` \u547d\u4ee4\u542f\u52a8Apache\u670d\u52a1\uff0c\u800c `systemctl enable apache2` \u547d\u4ee4\u5c06Apache\u670d\u52a1\u8bbe\u7f6e\u4e3a\u5f00\u673a\u81ea\u542f\u3002<\/p>\n<\/p>\n<p><h2>4. \u5b89\u88c5MySQL\u6570\u636e\u5e93\u670d\u52a1\u5668<\/h2>\n<\/p>\n<p><p>MySQL\u662f\u4e00\u4e2a\u6d41\u884c\u7684\u5173\u7cfb\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\uff0c\u6211\u4eec\u5c06\u5b89\u88c5\u5b83\u4ee5\u652f\u6301\u6570\u636e\u5e93\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.loongdi.net\/blog\/wp-content\/uploads\/2026\/03\/5QoAD.jpg\" alt=\"\u57fa\u7840Linux\u670d\u52a1\u5668\u642d\u5efa\u6559\u7a0b\uff1a\u7b80\u6613\u6307\u5357\" title=\"\u57fa\u7840Linux\u670d\u52a1\u5668\u642d\u5efa\u6559\u7a0b\uff1a\u7b80\u6613\u6307\u5357\"><\/p>\n<p><pre><code>sudo apt install mysql-server<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u89e3\u91ca\uff1a`mysql-server` \u662fUbuntu\u7cfb\u7edf\u4e2dMySQL\u6570\u636e\u5e93\u670d\u52a1\u5668\u8f6f\u4ef6\u5305\u7684\u540d\u79f0\u3002<\/p>\n<\/p>\n<p><h2>5. \u914d\u7f6eMySQL\u6570\u636e\u5e93<\/h2>\n<\/p>\n<p><p>\u5b89\u88c5MySQL\u540e\uff0c\u6211\u4eec\u9700\u8981\u8bbe\u7f6eroot\u7528\u6237\u7684\u5bc6\u7801\u3002<\/p>\n<\/p>\n<p><pre><code>sudo mysql_secure_installation<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u89e3\u91ca\uff1a`mysql_secure_installation` \u811a\u672c\u4f1a\u5f15\u5bfc\u4f60\u8bbe\u7f6eroot\u5bc6\u7801\u3001\u79fb\u9664\u533f\u540d\u7528\u6237\u3001\u7981\u6b62root\u7528\u6237\u8fdc\u7a0b\u767b\u5f55\uff0c\u5e76\u5220\u9664\u6d4b\u8bd5\u6570\u636e\u5e93\u3002<\/p>\n<\/p>\n<p><h2>6. \u5b89\u88c5PHP\u548c\u76f8\u5173\u7684\u6269\u5c55<\/h2>\n<\/p>\n<p><p>\u4e3a\u4e86\u652f\u6301PHP\u811a\u672c\uff0c\u6211\u4eec\u9700\u8981\u5b89\u88c5PHP\u53ca\u5176\u76f8\u5173\u6269\u5c55\u3002<\/p>\n<\/p>\n<p><pre><code>sudo apt install php php-mysql<\/p>\r\n<p>sudo systemctl restart apache2<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u89e3\u91ca\uff1a`php` \u662fPHP\u89e3\u91ca\u5668\uff0c\u800c `php-mysql` \u662fPHP\u7684MySQL\u6269\u5c55\u3002`systemctl restart apache2` \u547d\u4ee4\u91cd\u542fApache\u670d\u52a1\u4ee5\u52a0\u8f7d\u65b0\u7684PHP\u914d\u7f6e\u3002<\/p>\n<\/p>\n<p><h2>7. \u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684PHP\u7f51\u9875<\/h2>\n<\/p>\n<p><p>\u4e3a\u4e86\u9a8c\u8bc1PHP\u5b89\u88c5\uff0c\u6211\u4eec\u5c06\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684PHP\u7f51\u9875\u3002<\/p>\n<\/p>\n<p><pre><code>sudo nano \/var\/www\/html\/info.php<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9\u5e76\u4fdd\u5b58\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code>&lt;?php<\/p>\r\n<p>phpinfo();<\/p>\r\n<p>?&gt;<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u6d4f\u89c8\u5668\u4e2d\u8bbf\u95ee `http:\/\/\u4f60\u7684\u670d\u52a1\u5668IP\u5730\u5740\/info.php`\uff0c\u4f60\u5e94\u8be5\u80fd\u770b\u5230PHP\u7684\u914d\u7f6e\u4fe1\u606f\u3002<\/p>\n<\/p>\n<p><h2>8. \u53ef\u80fd\u9047\u5230\u7684\u95ee\u9898\u53ca\u6ce8\u610f\u4e8b\u9879<\/h2>\n<\/p>\n<ul>\n<li>\u5982\u679cApache\u65e0\u6cd5\u542f\u52a8\uff0c\u8bf7\u68c0\u67e5\u7aef\u53e380\u662f\u5426\u5df2\u88ab\u5360\u7528\u3002<\/li>\n<li>\u5728\u914d\u7f6eMySQL\u65f6\uff0c\u786e\u4fdd\u8bbe\u7f6e\u7684root\u5bc6\u7801\u7b26\u5408\u5b89\u5168\u6027\u8981\u6c42\u3002<\/li>\n<li>\u786e\u4fddPHP\u7684MySQL\u6269\u5c55\u88ab\u6b63\u786e\u5b89\u88c5\u548c\u52a0\u8f7d\u3002<\/li>\n<\/ul>\n<p><p>\u606d\u559c\u4f60\uff0c\u73b0\u5728\u4f60\u5df2\u7ecf\u6210\u529f\u642d\u5efa\u4e86\u4e00\u4e2a\u57fa\u672c\u7684Linux\u670d\u52a1\u5668\uff0c\u5e76\u914d\u7f6e\u4e86Apache\u3001MySQL\u548cPHP\u3002\u4f60\u53ef\u4ee5\u5728\u6b64\u57fa\u7840\u4e0a\u7ee7\u7eed\u5b89\u88c5\u5176\u4ed6\u8f6f\u4ef6\u548c\u914d\u7f6e\u670d\u52a1\u5668\u4ee5\u6ee1\u8db3\u4f60\u7684\u9700\u6c42\u3002<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u670d\u52a1\u5668\u642d\u5efa\u6559\u7a0b \u672c\u6587\u5c06\u6307\u5bfc\u60a8\u5982\u4f55\u642d\u5efa\u4e00\u4e2a\u57fa\u7840\u7684Linux\u670d\u52a1\u5668\u3002\u6211\u4eec\u5c06\u4f7f\u7528Ubuntu 20.04\u4f5c\u4e3a\u64cd\u4f5c\u7cfb\u7edf\uff0c\u5e76\u914d\u7f6eApache\u4f5c\u4e3aWeb\u670d\u52a1\u5668\uff0cMySQL\u4f5c\u4e3a\u6570\u636e\u5e93\u670d\u52a1\u5668\uff0c\u4ee5\u53caPHP\u4f5c\u4e3a\u670d\u52a1\u5668\u7aef\u811a\u672c\u8bed\u8a00\u3002 \u64cd\u4f5c\u524d\u7684\u51c6\u5907\u6216\u80cc\u666f\u4ecb\u7ecd \u4e00\u53f0\u5df2&#8230;<\/p>\n","protected":false},"author":1,"featured_media":135,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"topic":[],"class_list":["post-1007","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-yun"],"_links":{"self":[{"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/posts\/1007","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/comments?post=1007"}],"version-history":[{"count":1,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/posts\/1007\/revisions"}],"predecessor-version":[{"id":1008,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/posts\/1007\/revisions\/1008"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/media\/135"}],"wp:attachment":[{"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/media?parent=1007"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/categories?post=1007"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/tags?post=1007"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/topic?post=1007"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}