Prepare for Multi site network
deactiavate plugins it will also asks later.
First enable WordPress multisite on website
Step 2: Allow Multisite
Edit the wp-config.php file:
nano /usr/share/nginx/wordpress/wp-config.php
0r
nano /var/www/html/southjobs.in/wp-config.php
Add the following code before the comment /* That’s all, stop editing! Happy blogging. */:
/* Multisite settings */
define( ‘WP_ALLOW_MULTISITE’, true );
Step 3: Network setup
The previous step enables the Network Setup item in your Tools menu. Use that menu item to go to the Create a Network of WordPress Sites screen.
Step 4: Enabling the Network
Nginx config for Sub-directories for domain named example.com:
server {
listen [::]:80 ipv6only=off;
server_name examplewp.com *.examplewp.com shoppingsite.com companysite.org;
root /usr/share/nginx/wordpress;
rewriting wp-admin site.com/musite/wp-admin
# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
# Pass uploaded files to wp-includes/ms-files.php.
rewrite /files/$ /index.php last;
if ($uri !~ wp-content/plugins) {
rewrite /files/(.+)$ /wp-includes/ms-files.php?file=$1 last;
}
# Rewrite multisite ‘…/wp-.*’ and ‘…/*.php’.
if (!-e $request_filename) {
rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
rewrite ^/[_0-9a-zA-Z-]+.*(/wp-admin/.*\.php)$ $1 last;
rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
}
or
server {
##DM - uncomment following line for domain mapping
#listen 80 default_server;
server_name example.com *.example.com ;
##DM - uncomment following line for domain mapping
#server_name_in_redirect off;
root /var/www/example.com/htdocs;
index index.php;
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
rewrite ^(/[^/]+)?(/.*.php) $2 last;
}
location / {
try_files $uri $uri/ /index.php?$args ;
}
location ~ .php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}
}
https://www.nginx.com/resources/wiki/start/topics/recipes/wordpress/
https://wordpress.org/documentation/article/create-a-network/
nginx -t && nginx -s reload
Step 3: Installing a Network
Administration >Tools > Network Setup.
Sub-domain Installation | Because your installation is not new, the sites in your WordPress network must use sub-domains. The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links. |
---|
bypassing sub domain define(‘ALLOW_SUBDIRECTORY_INSTALL’, true);
define( ‘MULTISITE’, true );
define( ‘SUBDOMAIN_INSTALL’, false );
define( ‘DOMAIN_CURRENT_SITE’, ‘southjobs.in’ );
define( ‘PATH_CURRENT_SITE’, ‘/’ );
define( ‘SITE_ID_CURRENT_SITE’, 1 );
define( ‘BLOG_ID_CURRENT_SITE’, 1 );
if changes not reflected restart php fpm service php8.1-fpm restart to clear opcode cache or opcache
https://wordpress.org/documentation/article/nginx/
/wp-admin/network/sites.php
Create new site
nginx wordpress multisite subdirectory settings
root /var/www/example.com/htdocs;
index index.php;
if (!-e $request_filename) { rewrite /wp-admin$ $scheme://$host$uri/ permanent; rewrite ^/(/[^/]+)?(/wp-.*) /$2 last; rewrite ^/(/[^/]+)?(/.*\.php)$ /$2 last; }
or
if (!-e $request_filename) { rewrite /wp-admin$ $scheme://$host$uri/ permanent; rewrite ^/wordpress(/[^/]+)?(/wp-.*) /wordpress$2 last; rewrite ^/wordpress(/[^/]+)?(/.*\.php)$ /wordpress$2 last; } final file
server { server_name example.com ; access_log /var/log/nginx/example.com.access.log; error_log /var/log/nginx/example.com.error.log debug; root /var/www/example.com/htdocs ; index index.php; if (!-e $request_filename) { rewrite /wp-admin$ $scheme://$host$uri/ permanent; rewrite ^/wordpress(/[^/]+)?(/wp-.*) /wordpress$2 last; rewrite ^/wordpress(/[^/]+)?(/.*\.php)$ /wordpress$2 last; } location / { try_files $uri $uri/ /wordpress/index.php?$args ; } location ~ \.php$ { try_files $uri /wordpress/index.php; include fastcgi_params; fastcgi_pass 127.0.0.1:9000; } } 3rd way
# WordPress Multisite Subdirectory
if (!-e $request_filename) {
rewrite /wp-admin$ https://$host$uri permanent;
rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
}
if (-f $request_filename) {
break;
}