{"id":6483,"date":"2024-08-19T14:10:37","date_gmt":"2024-08-19T06:10:37","guid":{"rendered":"https:\/\/t.n-years.com\/?p=6483"},"modified":"2024-08-19T14:10:37","modified_gmt":"2024-08-19T06:10:37","slug":"wordpress-%e7%9a%84%e9%95%9c%e5%83%8f%e9%80%9a%e5%b8%b8%e9%9c%80%e8%a6%81%e5%85%b6%e4%bb%96%e5%93%aa%e4%ba%9b%e9%95%9c%e5%83%8f%e4%b8%80%e8%b5%b7%e4%bd%bf%e7%94%a8","status":"publish","type":"post","link":"https:\/\/t.n-years.com\/?p=6483","title":{"rendered":"WordPress \u7684\u955c\u50cf\u901a\u5e38\u9700\u8981\u5176\u4ed6\u54ea\u4e9b\u955c\u50cf\u4e00\u8d77\u4f7f\u7528"},"content":{"rendered":"<blockquote>\n<p>\u975e\u539f\u521b\u3001ChatGPT \u95ee\u7b54\u751f\u6210<\/p>\n<\/blockquote>\n<p>\u5728\u4f7f\u7528 Docker \u90e8\u7f72 WordPress \u65f6\uff0c\u901a\u5e38\u9700\u8981\u591a\u4e2a\u5bb9\u5668\u534f\u540c\u5de5\u4f5c\uff0c\u4ee5\u63d0\u4f9b\u5b8c\u6574\u7684\u670d\u52a1\u3002\u5e38\u89c1\u7684 WordPress \u90e8\u7f72\u4f1a\u5305\u542b\u4ee5\u4e0b\u51e0\u4e2a\u955c\u50cf\uff1a<\/p>\n<h3>1. <strong>WordPress \u955c\u50cf<\/strong><\/h3>\n<ul>\n<li>\u8fd9\u662f\u4e3b\u8981\u7684\u5e94\u7528\u955c\u50cf\uff0c\u63d0\u4f9b WordPress \u7684\u8fd0\u884c\u73af\u5883\u3002\u5b98\u65b9\u7684 WordPress \u955c\u50cf\u901a\u5e38\u57fa\u4e8e PHP \u548c Apache\/Nginx\uff0c\u5305\u542b\u4e86\u8fd0\u884c WordPress \u6240\u9700\u7684\u73af\u5883\u3002<\/li>\n<li>\u53ef\u4ee5\u901a\u8fc7\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff08\u5982 <code>WORDPRESS_DB_HOST<\/code>, <code>WORDPRESS_DB_NAME<\/code> \u7b49\uff09\u8fde\u63a5\u5230\u5916\u90e8\u6570\u636e\u5e93\u3002<\/li>\n<\/ul>\n<h3>2. <strong>\u6570\u636e\u5e93\u955c\u50cf<\/strong><\/h3>\n<p>WordPress \u9700\u8981\u6570\u636e\u5e93\u6765\u5b58\u50a8\u6570\u636e\uff0c\u5e38\u7528\u7684\u6570\u636e\u5e93\u955c\u50cf\u6709\uff1a<\/p>\n<ul>\n<li><strong>MySQL<\/strong>: \u901a\u5e38\u4f7f\u7528\u5b98\u65b9\u7684 <code>mysql<\/code> \u955c\u50cf\uff0c\u9002\u5408\u5927\u591a\u6570\u573a\u666f\u3002<\/li>\n<li>\n<p><strong>MariaDB<\/strong>: \u8fd9\u662f MySQL \u7684\u4e00\u4e2a\u5206\u652f\uff0c\u517c\u5bb9 WordPress\uff0c\u901a\u5e38\u4f7f\u7528\u5b98\u65b9\u7684 <code>mariadb<\/code> \u955c\u50cf\u3002<\/p>\n<p>\u8fd9\u4e24\u4e2a\u955c\u50cf\u90fd\u9700\u8981\u8bbe\u7f6e\u4e00\u4e9b\u73af\u5883\u53d8\u91cf\uff0c\u5982 <code>MYSQL_ROOT_PASSWORD<\/code>, <code>MYSQL_DATABASE<\/code>, <code>MYSQL_USER<\/code>, <code>MYSQL_PASSWORD<\/code>\uff0c\u4ee5\u786e\u4fdd\u6570\u636e\u5e93\u53ef\u4ee5\u6b63\u5e38\u521d\u59cb\u5316\u5e76\u88ab WordPress \u8bbf\u95ee\u3002<\/p>\n<\/li>\n<\/ul>\n<h3>3. <strong>\u53cd\u5411\u4ee3\u7406\uff08Nginx\/Traefik\uff09<\/strong><\/h3>\n<p>\u5982\u679c\u9700\u8981\u4f7f\u7528 HTTPS \u6216\u7ba1\u7406\u591a\u4e2a\u7f51\u7ad9\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u4e00\u4e2a\u53cd\u5411\u4ee3\u7406\u5bb9\u5668\uff1a<\/p>\n<ul>\n<li><strong>Nginx<\/strong>: \u53ef\u4ee5\u7528\u4f5c\u53cd\u5411\u4ee3\u7406\uff0c\u5c06\u6d41\u91cf\u8f6c\u53d1\u5230 WordPress \u5bb9\u5668\uff0c\u540c\u65f6\u5904\u7406 SSL \u8bc1\u4e66\u914d\u7f6e\u3002<\/li>\n<li><strong>Traefik<\/strong>: \u4e00\u4e2a\u52a8\u6001\u53cd\u5411\u4ee3\u7406\uff0c\u9002\u5408\u9700\u8981\u7ba1\u7406\u591a\u4e2a\u57df\u540d\u548c\u81ea\u52a8\u5316 SSL \u8bc1\u4e66\u7684\u573a\u666f\u3002<\/li>\n<\/ul>\n<h3>4. <strong>\u6570\u636e\u6301\u4e45\u5316\u548c\u5907\u4efd\uff08\u53ef\u9009\uff09<\/strong><\/h3>\n<ul>\n<li>WordPress \u548c\u6570\u636e\u5e93\u6570\u636e\u9700\u8981\u6301\u4e45\u5316\uff0c\u901a\u5e38\u4f7f\u7528 Docker Volume \u6765\u5b58\u50a8\u8fd9\u4e9b\u6570\u636e\u3002\u6b64\u5916\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u4e13\u95e8\u7684\u5907\u4efd\u5de5\u5177\u955c\u50cf\u8fdb\u884c\u81ea\u52a8\u5316\u5907\u4efd\u3002<\/li>\n<li>\u6709\u65f6\u4f1a\u4f7f\u7528 <code>minio<\/code> \u8fd9\u6837\u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u955c\u50cf\uff0c\u4f5c\u4e3a\u6301\u4e45\u5316\u6570\u636e\u7684\u5907\u4efd\u89e3\u51b3\u65b9\u6848\u3002<\/li>\n<\/ul>\n<h3>5. <strong>\u7f13\u5b58\u548c\u6027\u80fd\u4f18\u5316\uff08\u53ef\u9009\uff09<\/strong><\/h3>\n<p>\u4e3a\u4e86\u63d0\u5347 WordPress \u7684\u6027\u80fd\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u955c\u50cf\uff1a<\/p>\n<ul>\n<li><strong>Redis<\/strong>: \u53ef\u4ee5\u4f5c\u4e3a WordPress \u7684\u5bf9\u8c61\u7f13\u5b58\uff0c\u52a0\u901f\u9875\u9762\u52a0\u8f7d\u901f\u5ea6\u3002\u4f7f\u7528 <code>redis<\/code> \u5b98\u65b9\u955c\u50cf\uff0c\u5e76\u901a\u8fc7\u63d2\u4ef6\u5c06 WordPress \u8fde\u63a5\u5230 Redis\u3002<\/li>\n<li><strong>Memcached<\/strong>: \u53e6\u4e00\u79cd\u7f13\u5b58\u65b9\u6848\uff0c\u4f7f\u7528 <code>memcached<\/code> \u955c\u50cf\u3002<\/li>\n<\/ul>\n<h3>6. <strong>SMTP \u90ae\u4ef6\u670d\u52a1\uff08\u53ef\u9009\uff09<\/strong><\/h3>\n<p>WordPress \u901a\u5e38\u9700\u8981\u53d1\u9001\u90ae\u4ef6\uff08\u5982\u7528\u6237\u6ce8\u518c\u3001\u901a\u77e5\u7b49\uff09\uff0c\u53ef\u4ee5\u901a\u8fc7 SMTP \u670d\u52a1\u6765\u5b9e\u73b0\uff1a<\/p>\n<ul>\n<li><strong>Mailhog<\/strong>: \u7528\u4e8e\u672c\u5730\u5f00\u53d1\u7684\u90ae\u4ef6\u6355\u83b7\u670d\u52a1\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>mailhog<\/code> \u955c\u50cf\u3002<\/li>\n<li><strong>Postfix<\/strong>: \u7528\u4e8e\u751f\u4ea7\u73af\u5883\u7684 SMTP \u670d\u52a1\u5668\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>postfix<\/code> \u955c\u50cf\uff0c\u914d\u7f6e\u5916\u90e8\u90ae\u4ef6\u670d\u52a1\u3002<\/li>\n<\/ul>\n<h3>7. <strong>\u7ba1\u7406\u5de5\u5177\uff08\u53ef\u9009\uff09<\/strong><\/h3>\n<p>\u4e3a\u4e86\u66f4\u65b9\u4fbf\u5730\u7ba1\u7406\u6570\u636e\u5e93\u548c\u7ad9\u70b9\uff0c\u4f60\u53ef\u4ee5\u6dfb\u52a0\u4e00\u4e9b\u7ba1\u7406\u5de5\u5177\u955c\u50cf\uff1a<\/p>\n<ul>\n<li><strong>phpMyAdmin<\/strong>: \u4e00\u4e2a\u6d41\u884c\u7684 MySQL\/MariaDB \u7ba1\u7406\u5de5\u5177\uff0c\u4f7f\u7528 <code>phpmyadmin<\/code> \u955c\u50cf\uff0c\u53ef\u4ee5\u901a\u8fc7\u6d4f\u89c8\u5668\u7ba1\u7406\u6570\u636e\u5e93\u3002<\/li>\n<li><strong>Adminer<\/strong>: \u53e6\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u7684\u6570\u636e\u5e93\u7ba1\u7406\u5de5\u5177\uff0c\u4f7f\u7528 <code>adminer<\/code> \u955c\u50cf\u3002<\/li>\n<\/ul>\n<h3>\u7ec4\u5408\u65b9\u6848<\/h3>\n<p>\u4e00\u4e2a\u5e38\u89c1\u7684 Docker Compose \u914d\u7f6e\u53ef\u80fd\u4f1a\u5305\u62ec WordPress\u3001\u6570\u636e\u5e93\u548c\u53cd\u5411\u4ee3\u7406\u4e09\u8005\u7684\u7ec4\u5408\uff1a<\/p>\n<pre><code class=\"language-yaml\">version: &#039;3.8&#039;\nservices:\n  wordpress:\n    image: wordpress:latest\n    ports:\n      - &quot;80:80&quot;\n    environment:\n      WORDPRESS_DB_HOST: db:3306\n      WORDPRESS_DB_USER: wordpress\n      WORDPRESS_DB_PASSWORD: wordpress_password\n      WORDPRESS_DB_NAME: wordpress_db\n    volumes:\n      - .\/wordpress:\/var\/www\/html\n    depends_on:\n      - db\n\n  db:\n    image: mysql:5.7\n    environment:\n      MYSQL_ROOT_PASSWORD: root_password\n      MYSQL_DATABASE: wordpress_db\n      MYSQL_USER: wordpress\n      MYSQL_PASSWORD: wordpress_password\n    volumes:\n      - .\/db:\/var\/lib\/mysql\n\n  nginx:\n    image: nginx:latest\n    ports:\n      - &quot;8080:80&quot;\n    volumes:\n      - .\/nginx:\/etc\/nginx\/conf.d\n    depends_on:\n      - wordpress<\/code><\/pre>\n<h3>\u603b\u7ed3<\/h3>\n<p>\u901a\u5e38\uff0c\u4e00\u4e2a\u5b8c\u6574\u7684 WordPress \u90e8\u7f72\u9700\u8981 WordPress \u955c\u50cf\u548c\u6570\u636e\u5e93\u955c\u50cf\uff08\u5982 MySQL \u6216 MariaDB\uff09\u3002\u5728\u6b64\u57fa\u7840\u4e0a\uff0c\u53ef\u80fd\u8fd8\u4f1a\u7528\u5230\u53cd\u5411\u4ee3\u7406\uff08\u5982 Nginx \u6216 Traefik\uff09\u3001\u7f13\u5b58\uff08\u5982 Redis\uff09\u548c\u5176\u4ed6\u8f85\u52a9\u670d\u52a1\uff08\u5982 SMTP \u90ae\u4ef6\u670d\u52a1\u3001\u6570\u636e\u5e93\u7ba1\u7406\u5de5\u5177\uff09\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u975e\u539f\u521b\u3001ChatGPT \u95ee\u7b54\u751f\u6210 \u5728\u4f7f\u7528 Docker \u90e8\u7f72 WordPress \u65f6\uff0c\u901a\u5e38\u9700\u8981\u591a\u4e2a\u5bb9\u5668\u534f\u540c\u5de5\u4f5c&#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"https:\/\/t.n-years.com\/?p=6483\">\u9605\u8bfb\u66f4\u591a<i class=\"fa fa-angle-double-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[123],"tags":[147],"class_list":["post-6483","post","type-post","status-publish","format-standard","hentry","category-123","tag-147"],"_links":{"self":[{"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts\/6483","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6483"}],"version-history":[{"count":1,"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts\/6483\/revisions"}],"predecessor-version":[{"id":6484,"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts\/6483\/revisions\/6484"}],"wp:attachment":[{"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6483"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6483"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}