{"id":29160,"date":"2024-11-25T12:40:38","date_gmt":"2024-11-25T04:40:38","guid":{"rendered":"https:\/\/fwq.ai\/blog\/29160\/"},"modified":"2024-11-25T12:40:38","modified_gmt":"2024-11-25T04:40:38","slug":"%e4%bd%bf%e7%94%a8-docker-%e6%90%ad%e5%bb%ba-wordpress","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/29160\/","title":{"rendered":"\u4f7f\u7528 docker \u642d\u5efa wordpress"},"content":{"rendered":"<p>\u4e0b\u9762\u7531\/&#8221; target=&#8221;_blank&#8221;&gt;<strong>wordpress\u6559\u7a0b<\/strong>\u680f\u76ee\u4e3a\u5927\u5bb6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 docker \u642d\u5efa wordpress\uff0c\u5e0c\u671b\u5bf9\u9700\u8981\u7684\u670b\u53cb\u6709\u6240\u5e2e\u52a9\uff01<\/p>\n<p style=\"text-align: center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/020\/5d8585aded832554.jpg\" class=\"aligncenter\" title=\"\u4f7f\u7528 docker \u642d\u5efa wordpress\u63d2\u56fe\" alt=\"\u4f7f\u7528 docker \u642d\u5efa wordpress\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5bfc\u8bed<\/strong><\/p>\n<p>\u8fd9\u4e0d\u662f\u4e00\u7bc7\u6b63\u89c4\u642d\u5efa wordpress \u7684\u6587\u7ae0\uff0c\u662f\u57fa\u4e8e\u7684\u57fa\u7840\u4e4b\u4e0a\uff0c\u8fdb\u884c\u7684\u5b9e\u73b0\u3002\u6700\u7ec8\u7684\u5b9e\u73b0\u662f\u4f7f\u7528 nginx \u505a\u4ee3\u7406\uff0c\u72ec\u7acb\u7684 wordpress \u5bb9\u5668\uff0c\u8fde\u63a5 laradock \u7684 MySQL \u505a\u5b58\u50a8\u3002<\/p>\n<p><strong>\u4fee\u6539 nginx \u4ee3\u7406<\/strong><\/p>\n<p>\u76f8\u8f83\u4e8e laradock \u7684\u914d\u7f6e\uff0c\u53ea\u662f\u4fee\u6539\u76d1\u542c\u7684\u57df\u540d\u4ee5\u53ca\u8f6c\u53d1\u7684\u7aef\u53e3\u3002\u5728 \/etc\/nginx\/conf.d\/ \u76ee\u5f55\u4e0b\u65b0\u5efa wordpress.conf \u6587\u4ef6\uff0c\u5982\u4e0b<\/p>\n<pre>server&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;listen&nbsp;&nbsp;80;\n&nbsp;&nbsp;&nbsp;&nbsp;server_name&nbsp;&nbsp;blog.you_site.com;\n&nbsp;&nbsp;&nbsp;&nbsp;location&nbsp;\/&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_set_header&nbsp;&nbsp;Host&nbsp;&nbsp;$http_host;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_set_header&nbsp;&nbsp;X-Real-IP&nbsp;&nbsp;$remote_addr;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_set_header&nbsp;&nbsp;X-Forwarded-For&nbsp;$proxy_add_x_forwarded_for;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_pass&nbsp;&nbsp;http:\/\/[\u5bbf\u4e3b\u673aIP]:8001;\n&nbsp;&nbsp;&nbsp;&nbsp;}\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4fee\u6539\u4e4b\u540e\u8bb0\u5f97\u91cd\u542f<\/p>\n<p><strong>\u642d\u5efa wordpress \u5bb9\u5668<\/strong><\/p>\n<p>1.\u62c9\u53d6\u955c\u50cf docker pull wordpress<\/p>\n<p>2.\u56e0\u4e3a wordpress \u8981\u8fde\u63a5 MySQL \u5bb9\u5668\uff0c\u6b63\u597d laradock \u5c31\u6709\uff0c\u5c31\u7528\u8fd9\u4e2a\u597d\u4e86\u3002\u8fde\u63a5\u7684\u65b9\u5f0f\u4e0d\u7528 &#8211;link\uff0c\u7528 &#8211;network\uff0c\u53ef\u4ee5\u53c2\u8003\u8fd9\u91cc<\/p>\n<p>3.laradock \u4e2d MySQL \u7684 network \u5728 docker-compose.yml \u6587\u4ef6\u4e2d\u6709\u5199\uff0c\u5982\u4e0b<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/image\/116\/603\/646\/1569031237195110.png\" class=\"aligncenter\" title=\"\u4f7f\u7528 docker \u642d\u5efa wordpress\u63d2\u56fe1\" alt=\"\u4f7f\u7528 docker \u642d\u5efa wordpress\u63d2\u56fe1\" \/><\/p>\n<p>\u540c\u65f6\u4f7f\u7528 docker network ls \u67e5\u770b\uff0c\u53ef\u4ee5\u770b\u5230 laradock_backend \u8fd9\u4e2a\u7f51\u7edc\u3002\u663e\u800c\u6613\u89c1\u4f7f\u7528 laradock_backend \u5c31\u53ef\u4ee5<\/p>\n<p>1.\u642d\u5efa\u5bb9\u5668 docker run -d &#8211;name wordpress -p 8001:80 &#8211;network laradock_backend wordpress<\/p>\n<p>2.\u6700\u540e\u4e00\u6b65\uff0c\u5f00\u542f\u670d\u52a1\u5668\uff08\u5bbf\u4e3b\u673a\uff098001\u7aef\u53e3<\/p>\n<p><strong>\u7ed3\u8bed<\/strong><\/p>\n<p>\u6253\u5f00\u7f51\u5740\uff0c\u51fa\u73b0\u4e86\u914d\u7f6e\u754c\u9762\u3002\u5c06 Database Host \u8bbe\u7f6e\u4e3a mysql \u5c31\u53ef\u4ee5\u3002\u5176\u4ed6\u7684\u6570\u636e\u8868\u3001\u7528\u6237\u7b49\u4e0d\u5728\u8ba8\u8bba\u8303\u56f4\u4e4b\u5185\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4f7f\u7528 docker \u642d\u5efa \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\u4e3a\u5927\u5bb6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 docker \u642d\u5efa wordpress\uff0c\u5e0c\u671b\u5bf9\u9700\u8981\u7684\u670b\u53cb\u6709\u6240\u5e2e\u52a9\uff01 \u5bfc\u8bed \u8fd9\u4e0d\u662f\u4e00\u7bc7\u6b63\u89c4\u642d\u5efa wordpress \u7684\u6587\u7ae0\uff0c\u662f\u57fa\u4e8e\u7684\u57fa\u7840\u4e4b\u4e0a\uff0c\u8fdb\u884c\u7684\u5b9e\u73b0\u3002\u6700\u7ec8\u7684\u5b9e\u73b0\u662f\u4f7f\u7528 nginx \u505a\u4ee3\u7406\uff0c\u72ec\u7acb\u7684 wordpress \u5bb9\u5668\uff0c\u8fde\u63a5 laradock \u7684 MySQL \u505a\u5b58\u50a8\u3002 \u4fee\u6539 nginx \u4ee3\u7406 \u76f8\u8f83\u4e8e laradock \u7684\u914d\u7f6e\uff0c\u53ea\u662f\u4fee\u6539\u76d1\u542c\u7684\u57df\u540d\u4ee5\u53ca\u8f6c\u53d1\u7684\u7aef\u53e3\u3002\u5728 \/etc\/nginx\/conf.d\/ \u76ee\u5f55\u4e0b\u65b0\u5efa wordpress.conf \u6587\u4ef6\uff0c\u5982\u4e0b server&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;listen&nbsp;&nbsp;80; &nbsp;&nbsp;&nbsp;&nbsp;server_name&nbsp;&nbsp;blog.you_site.com; &nbsp;&nbsp;&nbsp;&nbsp;location&nbsp;\/&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_set_header&nbsp;&nbsp;Host&nbsp;&nbsp;$http_host; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_set_header&nbsp;&nbsp;X-Real-IP&nbsp;&nbsp;$remote_addr; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_set_header&nbsp;&nbsp;X-Forwarded-For&nbsp;$proxy_add_x_forwarded_for; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_pass&nbsp;&nbsp;http:\/\/[\u5bbf\u4e3b\u673aIP]:8001; &nbsp;&nbsp;&nbsp;&nbsp;} } \u767b\u5f55\u540e\u590d\u5236 \u4fee\u6539\u4e4b\u540e\u8bb0\u5f97\u91cd\u542f \u642d\u5efa wordpress \u5bb9\u5668 1.\u62c9\u53d6\u955c\u50cf docker pull wordpress 2.\u56e0\u4e3a wordpress \u8981\u8fde\u63a5 MySQL \u5bb9\u5668\uff0c\u6b63\u597d laradock \u5c31\u6709\uff0c\u5c31\u7528\u8fd9\u4e2a\u597d\u4e86\u3002\u8fde\u63a5\u7684\u65b9\u5f0f\u4e0d\u7528 &#8211;link\uff0c\u7528 &#8211;network\uff0c\u53ef\u4ee5\u53c2\u8003\u8fd9\u91cc [&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-29160","post","type-post","status-publish","format-standard","hentry","category-cms"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/29160","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=29160"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/29160\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=29160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=29160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=29160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}