Report this

What is the reason for this report?

Some help required on wordpress multi-site with Nginx

Posted on November 5, 2016

Hello, im trying to achieve the following

main wordpress installation for mysite1.com 2nd site using WP multi-site(sub-directory) mysite.com/abc 3rd site using WP multi-site (domain maping) anothersite.com

all 3 above with 1 single wordpress installation. i checked couple of tutorials but a bit confused that wordpress sub-directory and custom domain can be installed in single wordpress or not.

some detailed instruction would be appreciated. thank you.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hello. I hope I’m not too late. But, I have bad news for you. :(

This is not possible with one WP installation. This is a quote from WP Codex - Create A Network:

You must choose one or the other. You can reconfigure your network to use the other choice after installation, despite the advice on the screen, but reconfiguring it might not be easy.

I’ve setup one Droplet with it and verified that it’s no possible to do it. Codex: Before You Create A Network Codex: Create A Network.

I’m not sure that you would be able to setup as you want. You would be able to setup first and second site, but I’m not sure that third is supported by Multisite. Multisite supports sub-directory or sub-domain: e.g. for sub-directory: example.com & example.com/blog e.g. for sub-domain: example.com & blog.example.com But there isn’t option for: example.com & example.org Maybe it’s possible to tweak but as I said I’m not sure in it.

You can always go with multiple sites, it could be even easier in your case

Setting up a WordPress Multisite Network with Nginx, allowing for both subdirectory and domain mapping, can be a bit complex, but it’s definitely achievable. Here’s a step-by-step guide:

Step 1: Install WordPress and Enable Multisite

  1. Install WordPress: First, ensure you have a standard WordPress installation set up on mysite1.com.

  2. Enable Multisite:

    • Open wp-config.php in your WordPress root directory.
    • Just before the line that says /* That's all, stop editing! Happy publishing. */, add:
/* Multisite */
define('WP_ALLOW_MULTISITE', true);
  1. Setup Network:

    • Go to the WordPress Dashboard, then Tools → Network Setup.
    • Choose Sub-directories and complete the setup.
    • WordPress will provide some code to add to your wp-config.php and .htaccess files. For Nginx, you’ll use the wp-config.php changes but will need a different approach for Nginx configuration.

Step 2: Configure Nginx for Multisite

You’ll need to edit your Nginx configuration. This usually resides in /etc/nginx/sites-available/ or a similar directory.

  1. Basic Configuration:

    • Ensure the server block is correctly configured for mysite1.com.
    • Within this server block, you need to add specific rewrite rules to handle Multisite. Here’s an example snippet:
location / {
    try_files $uri $uri/ /index.php?$args;
}
  • This rewrite rule is crucial for the WordPress Multisite to parse URLs correctly.
  1. Subdirectory Rules:

    • The above rule should handle the subdirectory (mysite1.com/abc) automatically.
  2. Domain Mapping:

    • For anothersite.com, create another server block in Nginx that points to the same WordPress installation directory.
    • It will have a similar configuration but with a different server_name:
server {
    server_name anothersite.com;
    root /path/to/wordpress;
    # Include the rest of your WordPress config here...
}

Step 3: Update WordPress Configuration

  • Configure Multisite:
    • Edit wp-config.php and update the multisite settings provided by WordPress during the network setup.
    • Set DOMAIN_CURRENT_SITE to your main site’s domain.

Step 4: Configure WordPress Sites

  • Go to the Network Admin dashboard in WordPress.
  • For mysite1.com/abc, add a new site using the subdirectory option.
  • For domain mapping (anothersite.com), you’ll need a domain mapping plugin or WordPress 4.5+ which supports domain mapping natively. Add anothersite.com as a new site, then map the domain.

Step 5: DNS and Domain Settings

  • Ensure the DNS for anothersite.com is pointed to the same server as mysite1.com.
  • If using domain mapping plugins, follow their specific instructions for domain setup.

Additional Tips

  • SSL Certificates: If you’re using HTTPS (highly recommended), ensure you have SSL certificates for all domains.
  • Caching: Be careful with caching plugins; they can behave differently on Multisite installations.
  • Backups: Always backup your site and database before making significant changes like these.

This setup allows a single WordPress installation to serve multiple sites, both in subdirectories and with separate domains. Remember, the exact Nginx configuration might vary based on your server’s setup and WordPress version. Ensure to restart Nginx after making configuration changes.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.