WordPress Open multiple site support and nginx rewrite rule configuration _nginx

Source: Internet
Author: User
Tags extend readfile wordpress cache

Multiple sites can be used directly in the Wordpress3.0 and above versions, which can:

1, only install a WordPress program can create multiple WordPress site, can be a child domain name can also be a subdirectory.

2, can have independent blog backstage, independent blog address.

3, the administrator can set open which topics for the site to use.

4, the administrator can configure plug-ins for each site to use.

5, multiple sites sharing "user database table", that is, table Wp_usermeta and Wp_users, the other for the independent database table.

WordPress Multi-Site Configuration method:

1, first, back up the Web site's database, in case of unexpected recovery (generally can be ignored).

2, open the root directory of WordPress wp-config.php file, in
Require_once (Abspath. ' wp-settings.php ');
Precede with the following code:

Define (' Wp_allow_multisite ', true);

3, enter WordPress backstage, "Tool"-> Click "Configure Network"

PS: If you want to use the two-level domain name form, you can go to the "set"-> "General" inside, the site address (URL) of the www. Remove.

4, click the installation, follow the prompts to do the relevant configuration

5, configuration Well, again into the background, in the head will appear "My Site"-> "Management Network" Options menu, next you can manage or create a site, you can also open a theme or plug-ins for other sites to use.

6, if you want to bind other domain names to the site, you can install the WordPress MU domain Mapping plug-ins.

Nginx Multi-site rewrite (overriding) rules
WordPress Multi-site mode can be applied in a variety of ways. One of the most common is in "subdirectory" mode or "level two domain name" mode.
Nginx provides two special instructions: "X-accel-redirect" and "map", which can be used to achieve pseudo static function of the Web services of WordPress multi-site network using these two instructions.

WordPress Multiple Sites use subdirectory rewrite rules:
Jb51.net in the configuration is modified to its own site domain name.

Map $uri $blogname {~^ (?
p<blogpath>/[^/]+/) files/(. *) $blogpath;
 
 The map $blogname $blogid {default-999; #Ref: http://wordpress.org/extend/plugins/nginx-helper/#include/var/www/wordpress/wp-content/plugins/
nginx-helper/map.conf;
 
 } server {server_name jb51.net;
 Root/var/www/jb51.net/htdocs;
 
 Index index.php; #多站点配置 Location ~ ^ (/[^/]+/) files/(. +) {try_files/wp-content/blogs.dir/$blogid/files/$2/wp-includes/ms-files.php?
 file=$2; Access_log off; Log_not_found off;
 Expires Max;
 #avoid php ReadFile () location ^~/blogs.dir {internal;
 Alias/var/www/jb51.net/htdocs/wp-content/blogs.dir; Access_log off; Log_not_found off;
 Expires Max; 
 } if (!-e $request _filename) {rewrite/wp-admin$ $scheme://$host $uri/permanent; Rewrite ^ (/[^/]+)? 
 (/wp-.*) $ last; Rewrite ^ (/[^/]+)? 
 (/.*\.php) $ last;
 } location/{try_files $uri $uri//index.php $args;
 } location ~ \.php$ {try_files $uri = 404;
 Include Fastcgi_params; Fastcgi_pass Php
 } #此处可以继续添加伪静态规则}

WordPress Multi-Station Two-level domain name rewrite rules:
Jb51.net in the configuration is modified to its own site domain name.

Map $http _host $blogid {
 default  -999;
 
 #Ref: http://wordpress.org/extend/plugins/nginx-helper/
 #include/var/www/wordpress/wp-content/plugins/ nginx-helper/map.conf;
 
}
 
server {
 server_name jb51.net *.jb51.net;
 
 Root/var/www/jb51.net/htdocs;
 Index index.php;
 
 Location/{
 try_files $uri $uri//index.php $args;
 }
 
 Location ~ \.php$ {
 try_files $uri =404;
 Include Fastcgi_params;
 Fastcgi_pass php;
 }
 
 #WPMU Files
  Location ~ ^/files/(. *) $ {
    try_files/wp-content/blogs.dir/$blogid/$uri/wp-includes/ ms-files.php?file=$1;
    Access_log off; Log_not_found off;  Expires Max;
  }
 
 #WPMU x-sendfile to avoid PHP ReadFile ()
 location ^~/blogs.dir {internal
 ;
 Alias/var/www/jb51.net/htdocs/wp-content/blogs.dir;
 Access_log off; Log_not_found off; Expires Max;
 }
 
 #此处可以继续添加伪静态规则
}

Note

The

Map section can be applied to small sites. Multi-site applications for large sites can use Nginx-helper WordPress plug-ins.
If you want to further optimize the performance of WordPress, you can use Nginx's Fastcgi_cache, and when you use Fastcgi_cache configuration you need to add ngx_cache_ when compiling Nginx Purge module and the use of WordPress cache Plug-ins, and so on

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.