Languages: English • A Network 日本語 Русский • 中文(简体) • (Add your language)
在WordPress 3.0版本中,已经开始提供了创建一个多站点博客网络的功能。此文是关于如何创建这么一个网络的说明,最终就像创建了一个你的个人版WordPress.com博客网站一样.
如果想配置多站点博客网络,你至少应该对UNIX、Linux的管理操作有基本了解。最好能对WordPress开发、PHP、HTML 和 CSS 有一定认识.
配置安装并运行起来一个多站点博客网络比单博客站点要明显复杂。阅读本文会有利于你确定是否真正需要假设一个多站点博客网络,且告诉你如果必须这么做时会涉及到些什么。如果这些本文的指导你不是真正明白的话,请务必首先在测试站点做这些动作,请谨慎在一个正在正常运作的站点上操作.
由于该功能需要对服务器进行另外的设置并且需要了解更多的技术细节,请联系你的网络服务商以便确认他们的服务是否支持这些特性。不推荐在共享的服务器上进行这样的操作。
当执行第四步时,你需要在子域名和子目录之间做一个选择,这意味着网站中其它的子域名或子目录可能要进行一些更改。
site1.example.com
和site2.example.com
example.com/site1
和example.com/site2
稍后也可以, 使用插件WordPress MU Domain Mapping, to map individual sites to independent domain names.
.htaccess
文档, 该功能将提供创建链接结构.localhost
(即本地环境).(参见 wp-admin/network.php
获得更多内容)
你的 WordPress 将会在创建站点网络时升级,请于操作前备份你的数据。
(如果选择子目录方式安装,请跳过此步骤。)
Sub-domain sites work with the use of wildcard subdomains. This is a two-step process:
httpd.conf
file or the include file containing the VHOST entry for your web account.ServerAlias *.example.com
A *.example.com
If you can't access httpd.conf and your server uses CPanel. Make a sub-domain named "*" (wildcard) at your CPanel (*.example.com). Don't give names to subdomains at CPanel. If you can't do that, contact your host.
如果你的服务器使用 Plesk Panel 控制面板. There are several steps that differ when setting up the server for wildcard subdomains on a server using Plesk Panel compared to a server using cPanel (or no control panel). This article Configuring Wildcard Subdomains for multi site under Plesk Control Panel details all the steps involved. Although the instructions are comprehensive, the actual work only takes a couple of minutes.
如果你的服务器使用 DirectAdmin 控制面板。 (2011.01)
External links:
To enable the Network menu item, you must first define multisite in the wp-config.php
file.
打开 wp-config.php
并且 在/* That's all, stop editing! Happy blogging. */
的上方加入此行:
define('WP_ALLOW_MULTISITE', true);
This will enable the Network menu item to appear in the Tools menu. Visit Administration > Tools > Network to see the screen where you will configure certain aspects of our network.
site1.example.com
and site2.example.com
example.com/site1
and example.com/site2
example.com
.Double-check they are correct and click the Install button.
You may receive a warning about wildcard subdomains. Check Setting Wildcard Subdomains.
Warning! Wildcard DNS may not be configured correctly!
The installer attempted to contact a random hostname (13cc09.example.com
) on your domain.
To use a subdomain configuration, you must have a wildcard entry in your DNS. This usually means adding a *
hostname record pointing at your web server in your DNS configuration tool.
You can still use your site but any subdomain you create may not be accessible. If you know your DNS is correct, ignore this message.
The rest of the steps are ones you must complete in order to finish.
wp-config.php
和.htaccess
文件。/wp-content/
目录下创建一个blogs.dir
文件wp-content
目录一样授予CHOWNed和CHMODed权限。wp-config.php
file.wp-config.php
file while you are logged in to your sites admin panel./* That's all, stop editing! Happy blogging. */
.define('WP_ALLOW_MULTISITE', true);
line only if you wish to remove the Network menu in the admin area. You may choose to leave this to be able to access the .htaccess rules again...htaccess
file, replacing other WordPress rules.You will now see a new menu section called Super Admin. The menus contained in there are for adding and managing additional sites in your network. Your base WordPress install is now the main site in your network.
Go Super Admin > Options panel to configure network options, and then create sites and users.
Here are some additional things you might need to know about advanced administration of the blog network.
By design, all users who are added to your network will have subscriber access to all sites on your network.
Also, site admins cannot install new themes or plugins. Only the Network Admin (aka Super Admin) has that ability.
While permalinks will continue to work, the main blog (i.e. the first one created) will have an extra entry of blog
, making your URLs appear like domain.com/blog/YYYY/MM/POSTNAME
.
This is by design, in order to prevent collisions with SubFolder installs. Currently there is no easy way to change it, as doing so prevents WordPress from auto-detecting collisions between your main site and any subsites. This will be addressed, and customizable, in a future version of WordPress.
Also note that the blog
prefix is not used for static pages which will be accessible directly under the base address, e.g. domain.com/PAGENAME
. If you try to create a static page in the first blog with the name of another existing blog, the page's permalink will get a suffix (e.g. domain.com/PAGENAME-2
). If you create a new blog with the slug of an existing static page, the static page will not be reachable anymore. To prevent this, you can add the names of your static pages to the blacklist so that no blog with this name can be created.
If you have had WordPress installed for longer than a month and are attempting to activate the network, you will be told to use Sub-domain sites. This is in order to ensure you don't have conflicts between pages (i.e. example.com/pagename ) and sites (i.e. example.com/sitename ). If you are confident you will not have this issue, then you can change this after you finish the initial setup.
In your wp-config.php
file, you'll want to change the define call for SUBDOMAIN_INSTALL:
define( 'SUBDOMAIN_INSTALL', true );
define( 'SUBDOMAIN_INSTALL', false );
You'll also have to change your .htaccess
to the new setup. Be aware, you may have issues if you attempt this after being on one setup or the other for any length of time, so proceed with caution.
Unlike Single Site WordPress, which can work with "ugly" Permalinks and thus does not need Mod Rewrite, MultiSite requires its use to format URLs for your subsites. This necessitates the use of an .htaccess file, the format of which will be slightly different if you're using SubFolders or SubDomains. The examples below are the standard .htaccess entries for WordPress SubFolders and SubDomains, when WordPress is installed in the root folder of your website. If you have WordPress in it's own folder, you will need to change the value for RewriteBase appropriately.
需要提醒的是,这里有一些示例可以应用到大多数情境中,但不是全部。
子目录示例
# 开始 WordPress RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] # 上传文件 RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L] # 为 /wp-admin 加上一个斜杠 RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L] RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L] RewriteRule . index.php [L] # 结束 WordPress
子域名示例
# 开始 WordPress RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] # 文件上传 RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule . index.php [L] # 结束 WordPress