第一步:在配置文件中开启多站点
编辑wp-config.php文件
vim wp-config.php
#添加
define('WP_ALLOW_MULTISITE', true);
第二步:安装网络
配置好刷新网站后台,就会出现一个配置网络的选项如下图


第三步:在配置文件中配置网络
编辑wp-config.php文件,将网络配置页面中的配置项添加到配置文件中
vim wp-config.php
#添加
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', false );
define( 'DOMAIN_CURRENT_SITE', 'cosmetics.iloveu.website' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );

第四步:修改nginx 配置文件支持多站点
vim cosmetics.iloveu.website.conf
map $uri $blogname{
# ~^(?P/[^/]+/)files/(.*) $blogpath ;
}
map $blogname $blogid{
default -999;
}
server{
listen 80;
server_name cosmetics.iloveu.website;
rewrite ^(.*)$ https://${server_name}$1 permanent;
}
server {
listen 443 ssl;
server_name cosmetics.iloveu.website;
root /var/www/cosmetics.iloveu.website;
index index.php index.html index.hml;
access_log logs/blog.log;
ssl off;
ssl_certificate /var/www/cert/cosmetics.iloveu.website/fullchain.pem;
ssl_certificate_key /var/www/cert/cosmetics.iloveu.website/privkey.pem;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers on;
server_tokens off;
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;
}
location ^~ /blogs.dir {
internal;
alias /var/www/cosmetics.iloveu.website/wp-content/blogs.dir ;
access_log off; log_not_found off; expires max;
}
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$request_uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
rewrite ^(/[^/]+)?(/.*\.php) $2 last;
}
.......
第五步:管理多站点
在Sites菜单中管理站点

添加一个英文站点

添加一个中文站点

查看我的站点

上次更新时间 13 3 月, 2023 at 09:59 上午