{"id":51541,"date":"2024-10-08T19:30:16","date_gmt":"2024-10-08T11:30:16","guid":{"rendered":"https:\/\/server.hk\/cnblog\/51541\/"},"modified":"2024-11-14T10:42:49","modified_gmt":"2024-11-14T02:42:49","slug":"ubuntu-17-10-%e4%b8%8a%e5%ae%89%e8%a3%9d-lemp-%e7%92%b0%e5%a2%83%ef%bc%88nginx%ef%bc%8cmariadb%ef%bc%8cphp-7-1%ef%bc%89","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/51541\/","title":{"rendered":"Ubuntu 17.10 \u4e0a\u5b89\u88dd LEMP \u74b0\u5883\uff08Nginx\uff0cMariaDB\uff0cPHP 7.1\uff09"},"content":{"rendered":"<h1 id=\"ubuntu-17-10-%e4%b8%8a%e5%ae%89%e8%a3%9d-lemp-%e7%92%b0%e5%a2%83%ef%bc%88nginx%ef%bc%8cmariadb%ef%bc%8cphp-7-1%ef%bc%89-tVkaanKDQR\">Ubuntu 17.10 \u4e0a\u5b89\u88dd LEMP \u74b0\u5883\uff08Nginx\uff0cMariaDB\uff0cPHP 7.1\uff09<\/h1>\n<p>LEMP \u662f\u4e00\u500b\u6d41\u884c\u7684\u7db2\u9801\u4f3a\u670d\u5668\u67b6\u69cb\uff0c\u5305\u542b Linux\u3001Nginx\u3001MariaDB \u548c PHP\u3002\u9019\u7bc7\u6587\u7ae0\u5c07\u6307\u5c0e\u60a8\u5982\u4f55\u5728 Ubuntu 17.10 \u4e0a\u5b89\u88dd\u548c\u914d\u7f6e LEMP \u74b0\u5883\uff0c\u4ee5\u4fbf\u60a8\u80fd\u5920\u5feb\u901f\u642d\u5efa\u4e00\u500b\u9ad8\u6548\u7684\u7db2\u9801\u4f3a\u670d\u5668\u3002<\/p>\n<h2 id=\"%e5%89%8d%e6%9c%9f%e6%ba%96%e5%82%99-tVkaanKDQR\">\u524d\u671f\u6e96\u5099<\/h2>\n<p>\u5728\u958b\u59cb\u4e4b\u524d\uff0c\u8acb\u78ba\u4fdd\u60a8\u5df2\u7d93\u64c1\u6709\u4e00\u500b\u904b\u884c Ubuntu 17.10 \u7684\u4f3a\u670d\u5668\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528 SSH \u767b\u5165\u4f3a\u670d\u5668\uff0c\u4e26\u78ba\u4fdd\u7cfb\u7d71\u662f\u6700\u65b0\u7684\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u66f4\u65b0\u7cfb\u7d71\uff1a<\/p>\n<pre><code>sudo apt update\nsudo apt upgrade<\/code><\/pre>\n<h2 id=\"%e5%ae%89%e8%a3%9d-nginx-tVkaanKDQR\">\u5b89\u88dd Nginx<\/h2>\n<p>Nginx \u662f\u4e00\u500b\u9ad8\u6548\u80fd\u7684\u7db2\u9801\u4f3a\u670d\u5668\uff0c\u9069\u5408\u8655\u7406\u5927\u91cf\u7684\u4e26\u767c\u9023\u63a5\u3002\u8981\u5b89\u88dd Nginx\uff0c\u8acb\u57f7\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>sudo apt install nginx<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u555f\u52d5 Nginx \u4e26\u8a2d\u7f6e\u5176\u5728\u958b\u6a5f\u6642\u81ea\u52d5\u555f\u52d5\uff1a<\/p>\n<pre><code>sudo systemctl start nginx\nsudo systemctl enable nginx<\/code><\/pre>\n<p>\u63a5\u8457\uff0c\u60a8\u53ef\u4ee5\u5728\u700f\u89bd\u5668\u4e2d\u8f38\u5165\u4f3a\u670d\u5668\u7684 IP \u5730\u5740\uff0c\u61c9\u8a72\u80fd\u770b\u5230 Nginx \u7684\u9810\u8a2d\u6b61\u8fce\u9801\u9762\u3002<\/p>\n<h2 id=\"%e5%ae%89%e8%a3%9d-mariadb-tVkaanKDQR\">\u5b89\u88dd MariaDB<\/h2>\n<p>MariaDB \u662f\u4e00\u500b\u958b\u6e90\u7684\u8cc7\u6599\u5eab\u7ba1\u7406\u7cfb\u7d71\uff0c\u8207 MySQL \u517c\u5bb9\u3002\u8981\u5b89\u88dd MariaDB\uff0c\u8acb\u57f7\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>sudo apt install mariadb-server<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u9700\u8981\u57f7\u884c\u5b89\u5168\u6027\u914d\u7f6e\u8173\u672c\uff0c\u4ee5\u63d0\u9ad8 MariaDB \u7684\u5b89\u5168\u6027\uff1a<\/p>\n<pre><code>sudo mysql_secure_installation<\/code><\/pre>\n<p>\u6839\u64da\u63d0\u793a\uff0c\u60a8\u53ef\u4ee5\u8a2d\u7f6e root \u5bc6\u78bc\u3001\u522a\u9664\u533f\u540d\u7528\u6236\u3001\u7981\u6b62 root \u9060\u7a0b\u767b\u9304\u7b49\u3002\u9019\u4e9b\u6b65\u9a5f\u5c07\u6709\u52a9\u65bc\u4fdd\u8b77\u60a8\u7684\u8cc7\u6599\u5eab\u3002<\/p>\n<h2 id=\"%e5%ae%89%e8%a3%9d-php-7-1-tVkaanKDQR\">\u5b89\u88dd PHP 7.1<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u6211\u5011\u9700\u8981\u5b89\u88dd PHP \u53ca\u5176\u76f8\u95dc\u7684\u64f4\u5c55\u3002\u57f7\u884c\u4ee5\u4e0b\u547d\u4ee4\u4f86\u5b89\u88dd PHP 7.1 \u548c\u5e38\u7528\u7684\u64f4\u5c55\uff1a<\/p>\n<pre><code>sudo apt install php7.1 php7.1-fpm php7.1-mysql<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u9700\u8981\u555f\u52d5 PHP-FPM \u670d\u52d9\uff1a<\/p>\n<pre><code>sudo systemctl start php7.1-fpm\nsudo systemctl enable php7.1-fpm<\/code><\/pre>\n<h2 id=\"%e9%85%8d%e7%bd%ae-nginx-%e4%bd%bf%e7%94%a8-php-tVkaanKDQR\">\u914d\u7f6e Nginx \u4f7f\u7528 PHP<\/h2>\n<p>\u73fe\u5728\uff0c\u6211\u5011\u9700\u8981\u914d\u7f6e Nginx \u4ee5\u652f\u6301 PHP\u3002\u7de8\u8f2f Nginx \u7684\u9810\u8a2d\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo nano \/etc\/nginx\/sites-available\/default<\/code><\/pre>\n<p>\u5728 server \u5340\u584a\u4e2d\uff0c\u627e\u5230\u4ee5\u4e0b\u884c\uff1a<\/p>\n<pre><code>index index.html index.htm;<\/code><\/pre>\n<p>\u5c07\u5176\u66f4\u6539\u70ba\uff1a<\/p>\n<pre><code>index index.php index.html index.htm;<\/code><\/pre>\n<p>\u63a5\u8457\uff0c\u627e\u5230\u4ee5\u4e0b\u884c\uff1a<\/p>\n<pre><code># location ~ .php$ {<\/code><\/pre>\n<p>\u53d6\u6d88\u8a3b\u89e3\u4e26\u4fee\u6539\u70ba\uff1a<\/p>\n<pre><code>location ~ .php$ {\n    include snippets\/fastcgi-php.conf;\n    fastcgi_pass unix:\/var\/run\/php\/php7.1-fpm.sock;\n}<\/code><\/pre>\n<p>\u5b8c\u6210\u5f8c\uff0c\u4fdd\u5b58\u4e26\u9000\u51fa\u7de8\u8f2f\u5668\u3002\u7136\u5f8c\uff0c\u6aa2\u67e5 Nginx \u914d\u7f6e\u662f\u5426\u6b63\u78ba\uff1a<\/p>\n<pre><code>sudo nginx -t<\/code><\/pre>\n<p>\u5982\u679c\u6c92\u6709\u932f\u8aa4\uff0c\u91cd\u65b0\u555f\u52d5 Nginx \u4ee5\u61c9\u7528\u66f4\u6539\uff1a<\/p>\n<pre><code>sudo systemctl restart nginx<\/code><\/pre>\n<h2 id=\"%e6%b8%ac%e8%a9%a6-php-tVkaanKDQR\">\u6e2c\u8a66 PHP<\/h2>\n<p>\u70ba\u4e86\u78ba\u4fdd PHP \u6b63\u5e38\u904b\u884c\uff0c\u60a8\u53ef\u4ee5\u5275\u5efa\u4e00\u500b\u6e2c\u8a66 PHP \u6587\u4ef6\u3002\u5728 Nginx \u7684\u6839\u76ee\u9304\u4e2d\u5275\u5efa\u4e00\u500b\u540d\u70ba info.php \u7684\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo nano \/var\/www\/html\/info.php<\/code><\/pre>\n<p>\u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5167\u5bb9\uff1a<\/p>\n<pre><code>&lt;?php\nphpinfo();\n?&gt;<\/code><\/pre>\n<p>\u4fdd\u5b58\u4e26\u9000\u51fa\u7de8\u8f2f\u5668\u3002\u7136\u5f8c\u5728\u700f\u89bd\u5668\u4e2d\u8a2a\u554f <code>http:\/\/your_server_ip\/info.php<\/code>\uff0c\u60a8\u61c9\u8a72\u80fd\u770b\u5230 PHP \u7684\u4fe1\u606f\u9801\u9762\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-tVkaanKDQR\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904e\u4ee5\u4e0a\u6b65\u9a5f\uff0c\u60a8\u5df2\u6210\u529f\u5728 Ubuntu 17.10 \u4e0a\u5b89\u88dd\u4e86 LEMP \u74b0\u5883\uff08Nginx\uff0cMariaDB\uff0cPHP 7.1\uff09\u3002\u9019\u500b\u74b0\u5883\u70ba\u60a8\u63d0\u4f9b\u4e86\u4e00\u500b\u9ad8\u6548\u7684\u7db2\u9801\u4f3a\u670d\u5668\u67b6\u69cb\uff0c\u9069\u5408\u5404\u7a2e\u7db2\u9801\u61c9\u7528\u7684\u958b\u767c\u548c\u90e8\u7f72\u3002\u5982\u679c\u60a8\u9700\u8981\u66f4\u9ad8\u6548\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0c\u8acb\u8003\u616e\u4f7f\u7528\u6211\u5011\u7684\u670d\u52d9\uff0c\u8b93\u60a8\u7684\u7db2\u7ad9\u904b\u884c\u5f97\u66f4\u6d41\u66a2\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to install a LEMP stack (Nginx, MariaDB, PHP 7.1) on Ubuntu 17.10 for a powerful web server setup. Step-by-step guide included.<\/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-51541","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/51541","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=51541"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/51541\/revisions"}],"predecessor-version":[{"id":51542,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/51541\/revisions\/51542"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=51541"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=51541"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=51541"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}