{"id":31985,"date":"2024-11-25T09:19:58","date_gmt":"2024-11-25T01:19:58","guid":{"rendered":"https:\/\/fwq.ai\/blog\/31985\/"},"modified":"2024-11-25T09:19:58","modified_gmt":"2024-11-25T01:19:58","slug":"%e6%80%8e%e4%b9%88%e4%bd%bf%e7%94%a8docker-swarm%e6%90%ad%e5%bb%bawordpress","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/31985\/","title":{"rendered":"\u600e\u4e48\u4f7f\u7528Docker Swarm\u642d\u5efaWordPress"},"content":{"rendered":"<p>\u4e0b\u9762\u7531\/&#8221; target=&#8221;_blank&#8221;&gt;<strong>wordpress<\/strong>\u6559\u7a0b\u680f\u76ee\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u4f7f\u7528  swarm \u642d\u5efa wordpress\u7684\u65b9\u6cd5\uff0c\u5e0c\u671b\u5bf9\u9700\u8981\u7684\u670b\u53cb\u6709\u6240\u5e2e\u52a9\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/020\/607e711c24880367.jpg\" class=\"aligncenter\" title=\"\u600e\u4e48\u4f7f\u7528Docker Swarm\u642d\u5efaWordPress\u63d2\u56fe\" alt=\"\u600e\u4e48\u4f7f\u7528Docker Swarm\u642d\u5efaWordPress\u63d2\u56fe\" \/><\/p>\n<p> \u4f7f\u7528 Docker Swarm \u642d\u5efa WordPress <\/p>\n<h2>\u8d77\u56e0<\/h2>\n<p>\u6211\u66fe\u7ecf\u628a wordpress \u642d\u5efa\u5728 Vultr \u4e0a\uff0c\u4f46\u662f\u56e0\u4e3a\u4f17\u6240\u5468\u77e5\u7684\u539f\u56e0\uff0c\u8fd9\u4e2a\u5730\u65b9\u8bbf\u95ee\u8d8a\u6765\u8d8a\u6162\u3002\u518d\u540e\u6765\u6211\u9009\u62e9\u4e86\u65b0\u6d6a\u4e91\uff0c\u65b0\u6d6a\u4e91\u7684\u786e\u591f\u4fbf\u5b9c\uff0c\u4e5f\u5f88\u4e0d\u9519\uff0c\u4f46\u662f\u8981\u5907\u6848\uff0c\u8fd8\u6709\u8bc4\u8bba\u529f\u80fd\u4f30\u8ba1\u8981\u9609\u5272\uff0c\u60f3\u60f3\u8fd8\u662f\u7b97\u4e86\uff0c\u627e\u4e2a\u9999\u6e2f\u7684\u4e3b\u673a\u642d\u5efa wordpress \u5373\u53ef\u3002<\/p>\n<h2>\u8d2d\u4e70\u4e3b\u673a<\/h2>\n<p>\u6211\u8fd9\u91cc\u9009\u62e9\u7684\u662f\u963f\u91cc\u4e91\u7684\u8f7b\u91cf\u5e94\u7528\u670d\u52a1\u5668\uff0c\u8fd9\u4e2a\u4e3b\u673a\u7684\u597d\u5904\u5c31\u662f\u4fbf\u5b9c\uff0c\u591f\u7528\u3002<br \/>\u6bd4\u5982\u6211\u9009\u62e9\u7684\u9999\u6e2f\u7684\u4e3b\u673a\uff0c\u4e00\u4e2a\u6708\u53ea\u9700\u8981 24 \u5757\u94b1\uff0c\u4e00\u6838\u5fc3\u4e00G\u5185\u5b58\uff0c\u7f51\u901f\u4e3a 30Mbps\uff0c\u78c1\u76d8\u7a7a\u95f4 25GB\uff0c\u6708\u6d41\u91cf 1TB\u3002<\/p>\n<p>\u914d\u7f6e\u5982\u4e0b\u56fe<br \/><span><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/020\/6330ad6946b13d656624ab5886f63d82-1.jpg\" title=\"\u600e\u4e48\u4f7f\u7528Docker Swarm\u642d\u5efaWordPress\u63d2\u56fe1\" alt=\"\u600e\u4e48\u4f7f\u7528Docker Swarm\u642d\u5efaWordPress\u63d2\u56fe1\" \/><\/span><\/p>\n<h2>\u521d\u59cb\u5316 docker \u73af\u5883<\/h2>\n<blockquote><p>\n  \u867d\u7136\u4e0a\u9762\u6709\u4e00\u4ef6\u5b89\u88c5wordpress\u7684\u529f\u80fd\uff0c\u4f46\u662f\u6211\u4e0d\u63a8\u8350\uff0c\u56e0\u4e3a\u914d\u7f6e\u90fd\u592a\u8001\u4e86\n<\/p><\/blockquote>\n<p>\u6700\u7ec8\u6211\u9009\u62e9\u7684\u662f ubuntu18.04 \u7cfb\u7edf\uff0c\u76f4\u63a5\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u5373\u53ef\u5b8c\u6210\u5b89\u88c5 docker \u5e76\u4e14\u521d\u59cb\u5316 docker swarm<\/p>\n<pre>curl -o- -L https:\/\/gist.githubusercontent.com\/hangox\/e679464f35dc2a78920e6249a21d7958\/raw\/c5541e38979dca1e3e1e9704ad171ed2f0556fa1\/ubunut-install-docker.sh | bash<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h2>\u7f16\u5199 docker-compose<\/h2>\n<h3>\u914d\u7f6e\u4e00\u89c8<\/h3>\n<pre>version: '3.7'\n\nservices:\n  caddy:\n    image: abiosoft\/caddy\n    ports:\n      - 80:80\n      - 443:443\n    environment:\n      - ACME_AGREE=true\n      - TZ=Asia\/Shanghai\n    volumes:\n      - caddy:\/root\/.caddy\n      - wp-src:\/usr\/src\/wordpress\n    configs:\n      - source: wp_caddy\n        target: \/etc\/Caddyfile\n  app:\n    image: wordpress:5.4.1-php7.2-fpm\n    environment:\n      TZ: Asia\/Shanghai\n      WORDPRESS_DB_HOST: wp_db:3306\n      WORDPRESS_DB_USER: root\n      WORDPRESS_DB_PASSWORD: yourpassword\n      WORDPRESS_DB_NAME: wordpress\n    depends_on:\n      - db\n    volumes:\n      - wordpress:\/var\/www\/html\n      - wp-src:\/usr\/src\/wordpress\n  db:\n    image: mysql:8\n    environment:\n      TZ: Asia\/Shanghai\n      MYSQL_ROOT_PASSWORD: yourpassword\n      MYSQL_DATABASE: wordpress\n    command: --default-authentication-plugin=mysql_native_password\n    volumes:\n      - db:\/var\/lib\/mysql\n\nvolumes:\n  wordpress:\n  db:\n  caddy:\n  wp-src:\nconfigs:\n  wp_caddy:\n    external: true<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h3>\u914d\u7f6e\u89e3\u6790<\/h3>\n<h4>caddy<\/h4>\n<p>\u7528\u6765\u505a\u53cd\u5411\u4ee3\u7406\uff0c\u540c\u65f6\u517c\u987e https \u8bc1\u4e66\u7533\u8bf7\uff0c\u914d\u7f6e\u5982\u4e0b<\/p>\n<pre>https:\/\/47log.com  https:\/\/www.47log.com  {\n    root \/usr\/src\/wordpress\n    gzip\n    fastcgi \/ wp_app:9000 php\n    rewrite {\n        if {path} not_match ^\/wp-admin\n        to {path} {path}\/ \/index.php?_url={uri}\n    }\n    log stdout\n    errors stderr\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u91cc\u6211\u7528\u5230\u4e86 docker swarm \u7684 config \u529f\u80fd\uff0c\u76f4\u63a5\u628a\u914d\u7f6e\u5199\u5165\u5230 wp_caddy \u8fd9\u4e2a\u914d\u7f6e\u4e2d\u3002<\/p>\n<h4>db<\/h4>\n<p>\u8fd9\u91cc\u7528\u7684\u662f mysql8 , wordpress \u662f\u652f\u6301\u7684\uff0c\u6027\u80fd\u4e5f\u8981\u66f4\u597d\u70b9<br \/>\u9700\u8981\u6ce8\u610f\u7684\uff0ccommmand \u5fc5\u987b\u52a0\u4e0a command: &#8211;default-authentication-plugin=mysql_native_password \u4e0d\u7136\u662f\u6ca1\u529e\u6cd5\u8fdb\u884c\u5bc6\u7801\u8ba4\u8bc1\u7684\uff0c\u6211\u5c31\u662f\u5fd8\u8bb0\u52a0\u8fd9\u4e2a\u86cb\u75bc\u4e86\u4e00\u9635\u5b50\u3002<\/p>\n<h4>app<\/h4>\n<p><strong>\u6ce8\u610f\u8fde\u63a5\u65b9\u5f0f<\/strong><br \/>\u5982\u679c\u4f60\u662f\u7528 docker stack \u90e8\u7f72\u7684\uff0c\u90e8\u7f72\u7684\u662f\u4ec0\u4e48\u540d\u5b57\uff0c\u6570\u636e\u5e93\u8fde\u63a5\u90a3\u91cc\u5c31\u8981\u52a0\u4e0a\u540d\u5b57\u7684\u524d\u7f00\u3002\u6bd4\u5982\u6211\u8fd9\u91cc\u662f docker stack deploy -c docker-compose.yml wp\uff0c\u6211\u8fd9\u91cc\u6570\u636e\u5e93\u5728 docker \u7f51\u7edc\u4e2d\u7684 host \u5c31\u662f wp_db\u3002\u5982\u679c\u4f60\u7684 stack \u540d\u5b57\u4e3a wordpress , \u5c31\u8981\u5bf9\u5e94\u7684\u6539\u4e3a wordpress_db\u3002<\/p>\n<p><strong>\u6ce8\u610f\u914d\u7f6e volume<\/strong><br \/>&#8211; wordpress:\/var\/www\/html \u8fd9\u4e2a\u4e1c\u897f\u4e00\u5b9a\u8981\u914d\u7f6e\uff0c\u4e0a\u6b21\u6211\u5c31\u662f\u6ca1\u6709\u914d\u7f6e\u8fd9\u4e2a\u4e1c\u897f\uff0c\u5220\u6389 container\uff0c\u4e3b\u9898\u76f4\u63a5\u6ca1\u6709\u4e86\u3002<\/p>\n<h2>\u4f7f\u7528 docker stack \u90e8\u7f72<\/h2>\n<p>\u4e00\u884c\u547d\u4ee4 docker stack deploy -c docker-compose.yml wp \u7b49\u4e00\u6bb5\u65f6\u95f4\u5c31\u80fd\u8fdb\u5165 wordpress \u4e86<\/p>\n<blockquote><p>\n  \u4e3a\u4ec0\u4e48\u4f7f\u7528 docker swarm\u3002 \u56e0\u4e3a\u6709 portainer , docker-swarm \u63a5\u5165\u5230 portainer \u4e4b\u540e\u53ef\u4ee5\u6709\u5168\u529f\u80fd\u7684\u914d\u7f6e\u80fd\u529b\u3002\n<\/p><\/blockquote>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u4f7f\u7528Docker Swarm\u642d\u5efaWordpress\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0b\u9762\u7531\/&#8221; target=&#8221;_blank&#8221;&gt;wordpress\u6559\u7a0b\u680f\u76ee\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u4f7f\u7528 swarm \u642d\u5efa wordpress\u7684\u65b9\u6cd5\uff0c\u5e0c\u671b\u5bf9\u9700\u8981\u7684\u670b\u53cb\u6709\u6240\u5e2e\u52a9\uff01 \u4f7f\u7528 Docker Swarm \u642d\u5efa WordPress \u8d77\u56e0 \u6211\u66fe\u7ecf\u628a wordpress \u642d\u5efa\u5728 Vultr \u4e0a\uff0c\u4f46\u662f\u56e0\u4e3a\u4f17\u6240\u5468\u77e5\u7684\u539f\u56e0\uff0c\u8fd9\u4e2a\u5730\u65b9\u8bbf\u95ee\u8d8a\u6765\u8d8a\u6162\u3002\u518d\u540e\u6765\u6211\u9009\u62e9\u4e86\u65b0\u6d6a\u4e91\uff0c\u65b0\u6d6a\u4e91\u7684\u786e\u591f\u4fbf\u5b9c\uff0c\u4e5f\u5f88\u4e0d\u9519\uff0c\u4f46\u662f\u8981\u5907\u6848\uff0c\u8fd8\u6709\u8bc4\u8bba\u529f\u80fd\u4f30\u8ba1\u8981\u9609\u5272\uff0c\u60f3\u60f3\u8fd8\u662f\u7b97\u4e86\uff0c\u627e\u4e2a\u9999\u6e2f\u7684\u4e3b\u673a\u642d\u5efa wordpress \u5373\u53ef\u3002 \u8d2d\u4e70\u4e3b\u673a \u6211\u8fd9\u91cc\u9009\u62e9\u7684\u662f\u963f\u91cc\u4e91\u7684\u8f7b\u91cf\u5e94\u7528\u670d\u52a1\u5668\uff0c\u8fd9\u4e2a\u4e3b\u673a\u7684\u597d\u5904\u5c31\u662f\u4fbf\u5b9c\uff0c\u591f\u7528\u3002\u6bd4\u5982\u6211\u9009\u62e9\u7684\u9999\u6e2f\u7684\u4e3b\u673a\uff0c\u4e00\u4e2a\u6708\u53ea\u9700\u8981 24 \u5757\u94b1\uff0c\u4e00\u6838\u5fc3\u4e00G\u5185\u5b58\uff0c\u7f51\u901f\u4e3a 30Mbps\uff0c\u78c1\u76d8\u7a7a\u95f4 25GB\uff0c\u6708\u6d41\u91cf 1TB\u3002 \u914d\u7f6e\u5982\u4e0b\u56fe \u521d\u59cb\u5316 docker \u73af\u5883 \u867d\u7136\u4e0a\u9762\u6709\u4e00\u4ef6\u5b89\u88c5wordpress\u7684\u529f\u80fd\uff0c\u4f46\u662f\u6211\u4e0d\u63a8\u8350\uff0c\u56e0\u4e3a\u914d\u7f6e\u90fd\u592a\u8001\u4e86 \u6700\u7ec8\u6211\u9009\u62e9\u7684\u662f ubuntu18.04 \u7cfb\u7edf\uff0c\u76f4\u63a5\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u5373\u53ef\u5b8c\u6210\u5b89\u88c5 docker \u5e76\u4e14\u521d\u59cb\u5316 docker swarm curl -o- -L https:\/\/gist.githubusercontent.com\/hangox\/e679464f35dc2a78920e6249a21d7958\/raw\/c5541e38979dca1e3e1e9704ad171ed2f0556fa1\/ubunut-install-docker.sh | bash \u767b\u5f55\u540e\u590d\u5236 \u7f16\u5199 docker-compose \u914d\u7f6e\u4e00\u89c8 version: &#8216;3.7&#8217; services: caddy: image: abiosoft\/caddy ports: &#8211; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-31985","post","type-post","status-publish","format-standard","hentry","category-cms"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/31985","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=31985"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/31985\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=31985"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=31985"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=31985"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}