{"id":260,"date":"2015-10-29T15:52:28","date_gmt":"2015-10-29T07:52:28","guid":{"rendered":"http:\/\/www.ji-zhi.net\/?p=260"},"modified":"2015-10-29T15:52:28","modified_gmt":"2015-10-29T07:52:28","slug":"config-wordpress-multisite","status":"publish","type":"post","link":"https:\/\/www.ji-zhi.net\/?p=260","title":{"rendered":"WordPress\u7ad9\u70b9\u7f51\u7edc\u521d\u6b65\u63a2\u7d22"},"content":{"rendered":"<p>WordPress 3.0+\u7248\u672c\u652f\u6301MultiSite\uff0c\u7ad9\u70b9\u7f51\u7edc\u529f\u80fd\uff0c\u4e5f\u5c31\u662f\u5b89\u88c5\u4e00\u4efdWordpress\uff0c\u5c31\u53ef\u4ee5\u5f04\u51fa\u591a\u4e2aWP\u7ad9\u70b9\u6765\uff0c\u5c31\u50cf\u65b0\u6d6a\u535a\u5ba2\u90a3\u6837\u3002<\/p>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u53ef\u4ee5\u652f\u6301sub-domain\uff08\u4e8c\u7ea7\u57df\u540d\uff09\u548csub-directory\uff08\u5b50\u76ee\u5f55\uff09\u4e24\u79cd\u65b9\u5f0f\u3002\u5b98\u65b9\u6587\u6863\u63d0\u4f9b\u4e86Apache\u7684\u914d\u7f6e\u65b9\u5f0f\uff0cnginx\u7684\u914d\u7f6e\u6587\u6863\u8981\u5728nginx\u5b98\u7f51\u627e\u3002\u8bd5\u4e86\u4e00\u4e0bsub-domain\u6a21\u5f0f\uff0c\u975e\u5e38\u7b80\u5355\u3002<!--more--><\/p>\n<p>\u65b9\u6cd5\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n<h3>1\u3001\u51c6\u5907\u5de5\u4f5c<\/h3>\n<p>\u5148\u786e\u5b9a\u4f60\u7684\u7ad9\u70b9\u652f\u6301Pretty Permalink\uff0c\u5982\u679c\u4f60\u6309\u6211\u4e4b\u524d\u8bf4\u7684\u65b9\u6cd5\u5199.conf\u6587\u4ef6\uff0c\u90a3\u4e48\u5c31\u662f\u652f\u6301\u7684\u3002<\/p>\n<p>\u5230\u4f60\u7684\u57df\u540d\u89e3\u6790\u9762\u677f\u91cc\u9762\uff0c\u52a0\u4e00\u4e2a\u4e8c\u7ea7\u57df\u540d\uff0c\u6bd4\u5982site2.domain.com\u3002<\/p>\n<p>\u53e6\u5916\u4f60\u53ef\u80fd\u9700\u8981\u628a\u6240\u6709\u7684\u63d2\u4ef6\u90fd\u505c\u7528\u3002<\/p>\n<h3>2\u3001\u5b89\u88c5\u7ad9\u70b9\u7f51\u7edc<\/h3>\n<p>\u4fee\u6539wp-config.php\uff0c\u5728\/* \u597d\u4e86\uff01\u8bf7\u4e0d\u8981\u518d\u7ee7\u7eed\u7f16\u8f91\u3002\u8bf7\u4fdd\u5b58\u672c\u6587\u4ef6\u3002\u4f7f\u7528\u6109\u5feb\uff01 *\/\u7684\u4e0a\u9762\u52a0\u8fd9\u4e48\u4e00\u6761\uff1a<\/p>\n<pre class=\"\">define( 'WP_ALLOW_MULTISITE', true );<\/pre>\n<p>\u7136\u540e\u8fdb\u5230\u4f60\u7684Wordpress\u540e\u53f0\u53bb\u3002\u4f60\u4f1a\u53d1\u73b0\u5728\u201c\u5de5\u5177\u201d\u83dc\u5355\u91cc\u9762\u591a\u4e86\u4e00\u4e2a\u201c\u914d\u7f6e\u7f51\u7edc\u201d\uff0c\u731b\u51fb\u70b9\u5f00\u5b83\uff0c\u586b\u597d\u4e00\u4e9b\u9879\u76ee\u540e\u70b9\u201c\u73b0\u5728\u5b89\u88c5\u201d\u3002<\/p>\n<p>\u6709\u7684\u4eba\u53ef\u80fd\u4f1a\u88ab\u9650\u5236\u53ea\u80fd\u7528sub-directory\u6216\u8005sub-domain\uff0c\u6211\u8fd9\u91cc\u5c31\u662f\u53ea\u80fd\u7528sub-domain\uff0c\u5177\u4f53\u539f\u56e0\u5927\u6982\u662f\u548c\u73b0\u6709\u5b89\u88c5\u65b9\u5f0f\u6709\u5173\u3002\u6bd4\u5982\u8981\u662f\u4f60\u7684WP\u5b89\u88c5\u5728\u4e3b\u7ad9\u70b9\u7684\u4e00\u4e2a\u5b50\u76ee\u5f55\uff0c\u90a3\u5c31\u53ea\u80fd\u7528sub-directory\u6a21\u5f0f\u3002<\/p>\n<h3>3\u3001\u518d\u6b21\u914d\u7f6ewp-config.php<\/h3>\n<p>\u73b0\u5728\u9875\u9762\u4e0a\u5e94\u8be5\u6709\u4e24\u6bb5\u63d0\u793a\u3002\u4e0a\u4e00\u6bb5\u5c31\u662f\u544a\u8bc9\u4f60\u600e\u4e48\u6539wp-config\u7684\uff0c\u5927\u81f4\u662f\u5728\/* \u597d\u4e86\uff01\u8bf7\u4e0d\u8981\u518d\u7ee7\u7eed\u7f16\u8f91\u3002\u8bf7\u4fdd\u5b58\u672c\u6587\u4ef6\u3002\u4f7f\u7528\u6109\u5feb\uff01 *\/\u7684\u4e0a\u65b9\uff0c\u52a0\u4e0a\u8fd9\u4e48\u51e0\u6761\uff1a<\/p>\n<pre class=\"\">define('MULTISITE', true);\ndefine('SUBDOMAIN_INSTALL', true);\ndefine('DOMAIN_CURRENT_SITE', 'www.doocoo.xyz');\ndefine('PATH_CURRENT_SITE', '\/');\ndefine('SITE_ID_CURRENT_SITE', 1);\ndefine('BLOG_ID_CURRENT_SITE', 1);\n<\/pre>\n<h3>4\u3001\u914d\u7f6enginx<\/h3>\n<p>\u201c\u914d\u7f6e\u7f51\u7edc\u201d\u9875\u9762\u7b2c\u4e8c\u6bb5\u63d0\u793a\u7684\u662f\u4fee\u6539Apache\u7684\u65b9\u6cd5\uff0c\u6211\u4eec\u5230nginx\u5b98\u7f51\uff0c\u53c2\u8003<a href=\"https:\/\/www.nginx.com\/resources\/wiki\/start\/topics\/recipes\/wordpress\/#rewrite-rules-for-multisite\" target=\"_blank\" rel=\"noopener noreferrer\">\u8fd9\u4e2a\u9875\u9762\u4e0b\u9762Multisite\u7684\u90e8\u5206<\/a>\uff0c\u4fee\u6539\u7ad9\u70b9\u7684.conf\u6587\u4ef6\uff08\/etc\/nginx\/conf.d\/site.conf\uff09<\/p>\n<ul>\n<ul>\n<ul>\n<li>\u6700\u4e0a\u9762\u6dfb\u52a0\n<pre class=\"\">map $http_host $blogid {\n    default       -999;\n}<\/pre>\n<\/li>\n<li>server_name\u6539\u4e3a\n<pre>server_name domain.com *.domain.com;<\/pre>\n<p>\u4f60\u8981\u662f\u4e0d\u5acc\u9ebb\u70e6\uff0c\u7f57\u5217\u6240\u6709\u7684xxx.domain.com\u4e5f\u884c\u3002<\/li>\n<li>\u6dfb\u52a0\n<pre class=\"\">location ~ ^\/files\/(.*)$ {\n    try_files \/wp-content\/blogs.dir\/$blogid\/$uri \/wp-includes\/ms-files.php?file=$1 ;\n   access_log off; log_not_found off;expires max;\n}<\/pre>\n<pre class=\"\">location ^~ \/blogs.dir {\n    internal;\n    alias \/var\/www\/example.com\/htdocs\/wp-content\/blogs.dir;\n    access_log off;     log_not_found off;      expires max;\n}<\/pre>\n<\/li>\n<\/ul>\n<\/ul>\n<\/ul>\n<p>\u597d\u4e86\uff0c\u4fdd\u5b58\uff0c\u9000\u51fa\uff0c\u91cd\u542fnginx\u3002<\/p>\n<h3>5\u3001\u6dfb\u52a0\u5206\u7ad9\u70b9<\/h3>\n<p>\u73b0\u5728\u518d\u8fdb\u5230WP\u540e\u53f0\uff0c\u6837\u5b50\u53d8\u4e86\u5427\uff0c\u73b0\u5728\u662f\u7ad9\u70b9\u7f51\u7edc\u7684\u4e3b\u63a7\u540e\u53f0\u4e86\u3002<\/p>\n<p>\u6dfb\u52a0\u5206\u7ad9\uff0c\u5206\u7ad9\u57df\u540d\u5c31\u662f\u4f60\u7b2c\u4e00\u6b65\u65b0\u5efa\u7684\u90a3\u4e2a\u4e8c\u7ea7\u57df\u540d\u3002\u5176\u5b83\u7684\u4f60\u81ea\u5df1\u770b\u770b\u5c31\u4f1a\u4e86<\/p>\n<p>OK\uff0c\u641e\u5b9a\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>WordPress 3.0+\u7248\u672c\u652f\u6301MultiSite\uff0c\u7ad9\u70b9\u7f51\u7edc\u529f\u80fd\uff0c\u4e5f\u5c31\u662f\u5b89\u88c5\u4e00\u4efdWordpress\uff0c\u5c31\u53ef\u4ee5\u5f04\u51fa\u591a\u4e2aWP\u7ad9\u70b9\u6765\uff0c\u5c31\u50cf\u65b0\u6d6a\u535a\u5ba2\u90a3\u6837\u3002 \u9ed8\u8ba4\u60c5\u51b5\u4e0b\u53ef\u4ee5\u652f\u6301sub-domain\uff08\u4e8c\u7ea7\u57df\u540d\uff09\u548csub-directory\uff08\u5b50\u76ee\u5f55\uff09\u4e24\u79cd\u65b9\u5f0f\u3002\u5b98\u65b9\u6587\u6863\u63d0\u4f9b\u4e86Apache\u7684\u914d\u7f6e\u65b9\u5f0f\uff0cnginx\u7684\u914d\u7f6e\u6587\u6863\u8981\u5728nginx\u5b98\u7f51\u627e\u3002\u8bd5\u4e86\u4e00\u4e0bsub-domain\u6a21\u5f0f\uff0c\u975e\u5e38\u7b80\u5355\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,12],"tags":[32,52],"class_list":["post-260","post","type-post","status-publish","format-standard","hentry","category-nginx","category-wordpress","tag-nginx","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/www.ji-zhi.net\/index.php?rest_route=\/wp\/v2\/posts\/260","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ji-zhi.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ji-zhi.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ji-zhi.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ji-zhi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=260"}],"version-history":[{"count":0,"href":"https:\/\/www.ji-zhi.net\/index.php?rest_route=\/wp\/v2\/posts\/260\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.ji-zhi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=260"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ji-zhi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=260"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ji-zhi.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}