{"id":53003,"date":"2024-10-09T07:29:17","date_gmt":"2024-10-08T23:29:17","guid":{"rendered":"https:\/\/server.hk\/cnblog\/53003\/"},"modified":"2024-11-14T10:36:31","modified_gmt":"2024-11-14T02:36:31","slug":"%e4%bd%bf%e7%94%a8-nginx%e3%80%81mariadb%e3%80%81php-7-1%ef%bc%88lemp%ef%bc%89%e5%9c%a8-ubuntu-17-10-%e4%b8%8a%e5%ae%89%e8%a3%9d-wordpress","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/53003\/","title":{"rendered":"\u4f7f\u7528 Nginx\u3001MariaDB\u3001PHP 7.1\uff08LEMP\uff09\u5728 Ubuntu 17.10 \u4e0a\u5b89\u88dd WordPress"},"content":{"rendered":"<h1 id=\"%e4%bd%bf%e7%94%a8-nginx%e3%80%81mariadb%e3%80%81php-7-1%ef%bc%88lemp%ef%bc%89%e5%9c%a8-ubuntu-17-10-%e4%b8%8a%e5%ae%89%e8%a3%9d-wordpress-PzJpjiodTx\">\u4f7f\u7528 Nginx\u3001MariaDB\u3001PHP 7.1\uff08LEMP\uff09\u5728 Ubuntu 17.10 \u4e0a\u5b89\u88dd WordPress<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u7db2\u7d61\u74b0\u5883\u4e2d\uff0cWordPress \u662f\u6700\u53d7\u6b61\u8fce\u7684\u5167\u5bb9\u7ba1\u7406\u7cfb\u7d71\u4e4b\u4e00\u3002\u5b83\u7684\u9748\u6d3b\u6027\u548c\u64f4\u5c55\u6027\u4f7f\u5f97\u8a31\u591a\u7db2\u7ad9\u9078\u64c7\u4f7f\u7528 WordPress \u4f5c\u70ba\u5176\u5e73\u53f0\u3002\u672c\u6587\u5c07\u6307\u5c0e\u60a8\u5982\u4f55\u5728 Ubuntu 17.10 \u4e0a\u4f7f\u7528 Nginx\u3001MariaDB \u548c PHP 7.1\uff08LEMP \u5806\u758a\uff09\u5b89\u88dd WordPress\u3002<\/p>\n<h2 id=\"%e5%89%8d%e7%bd%ae%e6%a2%9d%e4%bb%b6-PzJpjiodTx\">\u524d\u7f6e\u689d\u4ef6<\/h2>\n<p>\u5728\u958b\u59cb\u4e4b\u524d\uff0c\u60a8\u9700\u8981\u78ba\u4fdd\u60a8\u7684\u4f3a\u670d\u5668\u4e0a\u5df2\u5b89\u88dd Ubuntu 17.10\u3002\u60a8\u9084\u9700\u8981\u64c1\u6709 sudo \u6b0a\u9650\u7684\u7528\u6236\u5e33\u6236\u3002\u4ee5\u4e0b\u662f\u5b89\u88dd\u904e\u7a0b\u4e2d\u7684\u4e00\u4e9b\u57fa\u672c\u8981\u6c42\uff1a<\/p>\n<ul>\n<li>Ubuntu 17.10 \u4f5c\u696d\u7cfb\u7d71<\/li>\n<li>\u8a2a\u554f\u7d42\u7aef\u6a5f\u6216 SSH \u5ba2\u6236\u7aef<\/li>\n<li>\u57fa\u672c\u7684 Linux \u547d\u4ee4\u884c\u77e5\u8b58<\/li>\n<\/ul>\n<h2 id=\"%e5%ae%89%e8%a3%9d-nginx-PzJpjiodTx\">\u5b89\u88dd Nginx<\/h2>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u5b89\u88dd Nginx\u3002\u6253\u958b\u7d42\u7aef\u6a5f\u4e26\u57f7\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>sudo apt update\nsudo 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\u555f\u52d5\u6642\u81ea\u52d5\u904b\u884c\uff1a<\/p>\n<pre><code>sudo systemctl start nginx\nsudo systemctl enable nginx<\/code><\/pre>\n<p>\u60a8\u53ef\u4ee5\u5728\u700f\u89bd\u5668\u4e2d\u8f38\u5165\u4f3a\u670d\u5668\u7684 IP \u5730\u5740\u4f86\u6aa2\u67e5 Nginx \u662f\u5426\u6b63\u5e38\u904b\u884c\u3002\u5982\u679c\u4e00\u5207\u6b63\u5e38\uff0c\u60a8\u61c9\u8a72\u6703\u770b\u5230 Nginx \u7684\u6b61\u8fce\u9801\u9762\u3002<\/p>\n<h2 id=\"%e5%ae%89%e8%a3%9d-mariadb-PzJpjiodTx\">\u5b89\u88dd MariaDB<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u5b89\u88dd MariaDB \u4f5c\u70ba\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\u3002\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\u904b\u884c\u5b89\u5168\u6027\u8173\u672c\u4f86\u52a0\u5f37 MariaDB \u7684\u5b89\u5168\u6027\uff1a<\/p>\n<pre><code>sudo mysql_secure_installation<\/code><\/pre>\n<p>\u6309\u7167\u63d0\u793a\u8a2d\u7f6e root \u5bc6\u78bc\uff0c\u4e26\u9078\u64c7\u5176\u4ed6\u5b89\u5168\u9078\u9805\u3002\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u5275\u5efa\u4e00\u500b\u6578\u64da\u5eab\u548c\u7528\u6236\u4f86\u904b\u884c WordPress\uff1a<\/p>\n<pre><code>sudo mysql -u root -p\nCREATE DATABASE wordpress;\nCREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'password';\nGRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';\nFLUSH PRIVILEGES;\nEXIT;<\/code><\/pre>\n<h2 id=\"%e5%ae%89%e8%a3%9d-php-7-1-PzJpjiodTx\">\u5b89\u88dd PHP 7.1<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u5b89\u88dd PHP 7.1 \u53ca\u5176\u76f8\u95dc\u64f4\u5c55\u3002\u57f7\u884c\u4ee5\u4e0b\u547d\u4ee4\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\u914d\u7f6e PHP \u4ee5\u8207 Nginx \u4e00\u8d77\u4f7f\u7528\u3002\u7de8\u8f2f PHP \u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo nano \/etc\/php\/7.1\/fpm\/php.ini<\/code><\/pre>\n<p>\u627e\u5230\u4e26\u4fee\u6539\u4ee5\u4e0b\u884c\u4ee5\u63d0\u9ad8\u6027\u80fd\uff1a<\/p>\n<pre><code>cgi.fix_pathinfo=0<\/code><\/pre>\n<p>\u7136\u5f8c\uff0c\u91cd\u555f PHP-FPM \u670d\u52d9\uff1a<\/p>\n<pre><code>sudo systemctl restart php7.1-fpm<\/code><\/pre>\n<h2 id=\"%e5%ae%89%e8%a3%9d-wordpress-PzJpjiodTx\">\u5b89\u88dd WordPress<\/h2>\n<p>\u73fe\u5728\uff0c\u60a8\u53ef\u4ee5\u4e0b\u8f09\u4e26\u5b89\u88dd WordPress\u3002\u9996\u5148\uff0c\u4e0b\u8f09\u6700\u65b0\u7248\u672c\u7684 WordPress\uff1a<\/p>\n<pre><code>wget https:\/\/wordpress.org\/latest.tar.gz<\/code><\/pre>\n<p>\u89e3\u58d3\u7e2e\u4e0b\u8f09\u7684\u6587\u4ef6\uff1a<\/p>\n<pre><code>tar -xvzf latest.tar.gz<\/code><\/pre>\n<p>\u5c07 WordPress \u6587\u4ef6\u79fb\u52d5\u5230 Nginx \u7684\u6839\u76ee\u9304\uff1a<\/p>\n<pre><code>sudo mv wordpress\/* \/var\/www\/html\/<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u8a2d\u7f6e\u9069\u7576\u7684\u6b0a\u9650\uff1a<\/p>\n<pre><code>sudo chown -R www-data:www-data \/var\/www\/html\/\nsudo chmod -R 755 \/var\/www\/html\/<\/code><\/pre>\n<h2 id=\"%e9%85%8d%e7%bd%ae-nginx-PzJpjiodTx\">\u914d\u7f6e Nginx<\/h2>\n<p>\u6700\u5f8c\uff0c\u60a8\u9700\u8981\u914d\u7f6e Nginx \u4ee5\u652f\u6301 WordPress\u3002\u5275\u5efa\u4e00\u500b\u65b0\u7684 Nginx \u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo nano \/etc\/nginx\/sites-available\/wordpress<\/code><\/pre>\n<p>\u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5167\u5bb9\uff1a<\/p>\n<pre><code>server {\n    listen 80;\n    server_name your_domain.com; # \u66ff\u63db\u70ba\u60a8\u7684\u57df\u540d\u6216\u4f3a\u670d\u5668 IP\n    root \/var\/www\/html;\n    index index.php index.html index.htm;\n\n    location \/ {\n        try_files $uri $uri\/ \/index.php?$args;\n    }\n\n    location ~ .php$ {\n        include snippets\/fastcgi-php.conf;\n        fastcgi_pass unix:\/var\/run\/php\/php7.1-fpm.sock;\n        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n        include fastcgi_params;\n    }\n}<\/code><\/pre>\n<p>\u555f\u7528\u914d\u7f6e\u4e26\u91cd\u555f Nginx\uff1a<\/p>\n<pre><code>sudo ln -s \/etc\/nginx\/sites-available\/wordpress \/etc\/nginx\/sites-enabled\/\nsudo systemctl restart nginx<\/code><\/pre>\n<h2 id=\"%e5%ae%8c%e6%88%90%e5%ae%89%e8%a3%9d-PzJpjiodTx\">\u5b8c\u6210\u5b89\u88dd<\/h2>\n<p>\u73fe\u5728\uff0c\u60a8\u53ef\u4ee5\u5728\u700f\u89bd\u5668\u4e2d\u8a2a\u554f\u60a8\u7684\u57df\u540d\u6216\u4f3a\u670d\u5668 IP\uff0c\u4e26\u6309\u7167 WordPress \u7684\u5b89\u88dd\u5411\u5c0e\u5b8c\u6210\u8a2d\u7f6e\u3002\u8f38\u5165\u60a8\u4e4b\u524d\u5275\u5efa\u7684\u6578\u64da\u5eab\u540d\u7a31\u3001\u7528\u6236\u540d\u548c\u5bc6\u78bc\uff0c\u7136\u5f8c\u5b8c\u6210\u5b89\u88dd\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-PzJpjiodTx\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904e\u4ee5\u4e0a\u6b65\u9a5f\uff0c\u60a8\u5df2\u6210\u529f\u5728 Ubuntu 17.10 \u4e0a\u4f7f\u7528 Nginx\u3001MariaDB \u548c PHP 7.1 \u5b89\u88dd\u4e86 WordPress\u3002\u9019\u7a2e LEMP \u5806\u758a\u7684\u7d44\u5408\u63d0\u4f9b\u4e86\u9ad8\u6548\u80fd\u548c\u9748\u6d3b\u6027\uff0c\u9069\u5408\u5404\u7a2e\u7db2\u7ad9\u9700\u6c42\u3002\u5982\u679c\u60a8\u9700\u8981\u66f4\u7a69\u5b9a\u548c\u9ad8\u6548\u7684\u4f3a\u670d\u5668\u89e3\u6c7a\u65b9\u6848\uff0c\u53ef\u4ee5\u8003\u616e\u4f7f\u7528\u6211\u5011\u7684 <a href=\"https:\/\/server.hk\">\u9999\u6e2f VPS<\/a> \u670d\u52d9\uff0c\u70ba\u60a8\u7684\u7db2\u7ad9\u63d0\u4f9b\u6700\u4f73\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 Ubuntu 17.10 \u4e0a\u4f7f\u7528 Nginx\u3001MariaDB \u548c PHP 7.1\uff08LEMP\uff09\u5b89\u88dd WordPress\uff0c\u5feb\u901f\u642d\u5efa\u9ad8\u6548\u7db2\u7ad9\u74b0\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-53003","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/53003","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=53003"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/53003\/revisions"}],"predecessor-version":[{"id":53004,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/53003\/revisions\/53004"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=53003"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=53003"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=53003"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}