{"id":44972,"date":"2024-10-06T19:32:16","date_gmt":"2024-10-06T11:32:16","guid":{"rendered":"https:\/\/server.hk\/cnblog\/44972\/"},"modified":"2024-10-06T19:32:16","modified_gmt":"2024-10-06T11:32:16","slug":"lnmp%ef%bc%88nginx-mysql-php%ef%bc%89%e7%92%b0%e5%a2%83-%e6%9e%b6%e6%a7%8b%e4%b8%80%e9%8d%b5%e5%ae%89%e8%a3%9d%e8%85%b3%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/44972\/","title":{"rendered":"LNMP\uff08nginx + mysql + php\uff09\u74b0\u5883\/\u67b6\u69cb\u4e00\u9375\u5b89\u88dd\u8173\u672c"},"content":{"rendered":"<h1 id=\"lnmp%ef%bc%88nginx-mysql-php%ef%bc%89%e7%92%b0%e5%a2%83-%e6%9e%b6%e6%a7%8b%e4%b8%80%e9%8d%b5%e5%ae%89%e8%a3%9d%e8%85%b3%e6%9c%ac-wdfPJuSRhz\">LNMP\uff08nginx + mysql + php\uff09\u74b0\u5883\/\u67b6\u69cb\u4e00\u9375\u5b89\u88dd\u8173\u672c<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u7db2\u7d61\u74b0\u5883\u4e2d\uff0cLNMP\uff08Linux, Nginx, MySQL, PHP\uff09\u67b6\u69cb\u56e0\u5176\u9ad8\u6548\u80fd\u548c\u9748\u6d3b\u6027\u800c\u53d7\u5230\u5ee3\u6cdb\u4f7f\u7528\u3002\u9019\u7a2e\u67b6\u69cb\u7279\u5225\u9069\u5408\u7528\u65bc\u642d\u5efa\u5404\u985e\u7db2\u7ad9\u548c\u61c9\u7528\u7a0b\u5f0f\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u4f7f\u7528\u4e00\u9375\u5b89\u88dd\u8173\u672c\u4f86\u5feb\u901f\u90e8\u7f72LNMP\u74b0\u5883\uff0c\u4e26\u63d0\u4f9b\u4e00\u4e9b\u5be6\u7528\u7684\u793a\u4f8b\u548c\u4ee3\u78bc\u7247\u6bb5\u3002<\/p>\n<h2 id=\"lnmp%e6%9e%b6%e6%a7%8b%e6%a6%82%e8%bf%b0-wdfPJuSRhz\">LNMP\u67b6\u69cb\u6982\u8ff0<\/h2>\n<p>LNMP\u67b6\u69cb\u7531\u56db\u500b\u4e3b\u8981\u7d44\u4ef6\u7d44\u6210\uff1a<\/p>\n<ul>\n<li><strong>Linux<\/strong>\uff1a\u4f5c\u70ba\u64cd\u4f5c\u7cfb\u7d71\uff0c\u63d0\u4f9b\u7a69\u5b9a\u7684\u904b\u884c\u74b0\u5883\u3002<\/li>\n<li><strong>Nginx<\/strong>\uff1a\u4e00\u500b\u9ad8\u6548\u7684\u7db2\u9801\u4f3a\u670d\u5668\uff0c\u8ca0\u8cac\u8655\u7406HTTP\u8acb\u6c42\u3002<\/li>\n<li><strong>MySQL<\/strong>\uff1a\u4e00\u500b\u6d41\u884c\u7684\u95dc\u806f\u578b\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\uff0c\u7528\u65bc\u5b58\u5132\u548c\u7ba1\u7406\u6578\u64da\u3002<\/li>\n<li><strong>PHP<\/strong>\uff1a\u4e00\u7a2e\u5ee3\u6cdb\u4f7f\u7528\u7684\u4f3a\u670d\u5668\u7aef\u8173\u672c\u8a9e\u8a00\uff0c\u9069\u5408\u7528\u65bc\u52d5\u614b\u7db2\u9801\u7684\u958b\u767c\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%82%ba%e4%bb%80%e9%ba%bc%e9%81%b8%e6%93%87%e4%b8%80%e9%8d%b5%e5%ae%89%e8%a3%9d%e8%85%b3%e6%9c%ac%ef%bc%9f-wdfPJuSRhz\">\u70ba\u4ec0\u9ebc\u9078\u64c7\u4e00\u9375\u5b89\u88dd\u8173\u672c\uff1f<\/h2>\n<p>\u624b\u52d5\u5b89\u88ddLNMP\u74b0\u5883\u53ef\u80fd\u6703\u6d89\u53ca\u591a\u500b\u6b65\u9a5f\uff0c\u5c0d\u65bc\u521d\u5b78\u8005\u4f86\u8aaa\u53ef\u80fd\u6703\u611f\u5230\u56f0\u96e3\u3002\u4e00\u9375\u5b89\u88dd\u8173\u672c\u7684\u51fa\u73fe\uff0c\u7c21\u5316\u4e86\u9019\u4e00\u904e\u7a0b\uff0c\u8b93\u7528\u6236\u80fd\u5920\u5feb\u901f\u642d\u5efa\u6240\u9700\u7684\u74b0\u5883\u3002\u9019\u4e9b\u8173\u672c\u901a\u5e38\u6703\u81ea\u52d5\u8655\u7406\u4f9d\u8cf4\u95dc\u4fc2\u3001\u914d\u7f6e\u6587\u4ef6\u548c\u670d\u52d9\u555f\u52d5\u7b49\u554f\u984c\uff0c\u7bc0\u7701\u4e86\u5927\u91cf\u6642\u9593\u548c\u7cbe\u529b\u3002<\/p>\n<h2 id=\"%e4%b8%80%e9%8d%b5%e5%ae%89%e8%a3%9d%e8%85%b3%e6%9c%ac%e7%a4%ba%e4%be%8b-wdfPJuSRhz\">\u4e00\u9375\u5b89\u88dd\u8173\u672c\u793a\u4f8b<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u500b\u7c21\u55ae\u7684LNMP\u4e00\u9375\u5b89\u88dd\u8173\u672c\u793a\u4f8b\uff0c\u9069\u7528\u65bc\u57fa\u65bcDebian\u6216Ubuntu\u7684\u7cfb\u7d71\uff1a<\/p>\n<pre><code>\n#!\/bin\/bash\n\n# \u66f4\u65b0\u7cfb\u7d71\napt-get update &amp;&amp; apt-get upgrade -y\n\n# \u5b89\u88ddNginx\napt-get install nginx -y\n\n# \u5b89\u88ddMySQL\napt-get install mysql-server -y\nmysql_secure_installation\n\n# \u5b89\u88ddPHP\u53ca\u5176\u64f4\u5c55\napt-get install php-fpm php-mysql -y\n\n# \u914d\u7f6eNginx\ncat &gt; \/etc\/nginx\/sites-available\/default &lt;&lt; EOF\nserver {\n    listen 80;\n    server_name your_domain.com;\n\n    root \/var\/www\/html;\n    index index.php index.html index.htm;\n\n    location \/ {\n        try_files $uri $uri\/ =404;\n    }\n\n    location ~ .php$ {\n        include snippets\/fastcgi-php.conf;\n        fastcgi_pass unix:\/var\/run\/php\/php7.4-fpm.sock;\n        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n        include fastcgi_params;\n    }\n}\nEOF\n\n# \u555f\u52d5\u670d\u52d9\nsystemctl restart nginx\nsystemctl restart php7.4-fpm\nsystemctl enable nginx\nsystemctl enable php7.4-fpm\n\necho \"LNMP\u74b0\u5883\u5b89\u88dd\u5b8c\u6210\uff01\"\n<\/code><\/pre>\n<p>\u5728\u9019\u500b\u8173\u672c\u4e2d\uff0c\u6211\u5011\u9996\u5148\u66f4\u65b0\u7cfb\u7d71\uff0c\u7136\u5f8c\u5b89\u88ddNginx\u3001MySQL\u548cPHP\u3002\u63a5\u8457\uff0c\u6211\u5011\u914d\u7f6eNginx\u4ee5\u652f\u6301PHP\uff0c\u4e26\u555f\u52d5\u76f8\u95dc\u670d\u52d9\u3002\u7528\u6236\u53ea\u9700\u5c07\u6b64\u8173\u672c\u4fdd\u5b58\u70ba.sh\u6587\u4ef6\uff0c\u4e26\u4f7f\u7528\u547d\u4ee4\u884c\u57f7\u884c\uff0c\u5373\u53ef\u5b8c\u6210LNMP\u74b0\u5883\u7684\u642d\u5efa\u3002<\/p>\n<h2 id=\"%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a0%85-wdfPJuSRhz\">\u6ce8\u610f\u4e8b\u9805<\/h2>\n<p>\u5728\u4f7f\u7528\u4e00\u9375\u5b89\u88dd\u8173\u672c\u6642\uff0c\u5efa\u8b70\u7528\u6236\u6ce8\u610f\u4ee5\u4e0b\u5e7e\u9ede\uff1a<\/p>\n<ul>\n<li>\u78ba\u4fdd\u7cfb\u7d71\u5df2\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\uff0c\u4ee5\u907f\u514d\u517c\u5bb9\u6027\u554f\u984c\u3002<\/li>\n<li>\u6839\u64da\u5be6\u969b\u9700\u6c42\u8abf\u6574Nginx\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684server_name\u548croot\u8def\u5f91\u3002<\/li>\n<li>\u5728\u751f\u7522\u74b0\u5883\u4e2d\uff0c\u5efa\u8b70\u5c0dMySQL\u9032\u884c\u5b89\u5168\u914d\u7f6e\uff0c\u4ee5\u4fdd\u8b77\u6578\u64da\u5b89\u5168\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-wdfPJuSRhz\">\u7e3d\u7d50<\/h2>\n<p>LNMP\u67b6\u69cb\u56e0\u5176\u9ad8\u6548\u80fd\u548c\u9748\u6d3b\u6027\u800c\u6210\u70ba\u8a31\u591a\u7db2\u7ad9\u548c\u61c9\u7528\u7a0b\u5f0f\u7684\u9996\u9078\u3002\u901a\u904e\u4f7f\u7528\u4e00\u9375\u5b89\u88dd\u8173\u672c\uff0c\u7528\u6236\u53ef\u4ee5\u5feb\u901f\u642d\u5efaLNMP\u74b0\u5883\uff0c\u7bc0\u7701\u6642\u9593\u548c\u7cbe\u529b\u3002\u7121\u8ad6\u662f\u958b\u767c\u8005\u9084\u662f\u4f01\u696d\uff0c\u9078\u64c7\u5408\u9069\u7684\u4f3a\u670d\u5668\u4f86\u904b\u884cLNMP\u74b0\u5883\u90fd\u662f\u81f3\u95dc\u91cd\u8981\u7684\u3002\u82e5\u60a8\u9700\u8981\u9032\u4e00\u6b65\u4e86\u89e3\u5982\u4f55\u9078\u64c7\u5408\u9069\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9\u4ee5\u7372\u53d6\u66f4\u591a\u8cc7\u8a0a\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u9375\u5b89\u88ddLNMP\u74b0\u5883\uff08nginx + mysql + php\uff09\u8173\u672c\uff0c\u7c21\u5316\u90e8\u7f72\u6d41\u7a0b\uff0c\u5feb\u901f\u642d\u5efa\u9ad8\u6548\u7db2\u7ad9\u4f3a\u670d\u5668\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-44972","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/44972","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=44972"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/44972\/revisions"}],"predecessor-version":[{"id":44973,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/44972\/revisions\/44973"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=44972"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=44972"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=44972"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}