snowcat
By:
snowcat

Wordpress problem after following some tutorials.

March 25, 2017 336 views
WordPress Let's Encrypt Nginx Ubuntu 16.04

I followed this tutorial. How To Install WordPress with LEMP on Ubuntu 16.04(https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-lemp-on-ubuntu-16-04) - I also followed Prerequisites.

Wordpress site works well with letsencrypt.

But I want to add wordpress multisite with sub domain&domain mapping.
exsisted wordpress example.com
wordpress multisite sub-domain test.example.com
domain mapping second.com

I tried How To Set Up WordPress Multisite with Nginx on Ubuntu 14.04 (https://www.digitalocean.com/community/tutorials/how-to-set-up-wordpress-multisite-with-nginx-on-ubuntu-14-04).

But I can't access neither sub-domain nor domain-mapped domain.
I can't access test.example.com / and second.com redirected to example.com.

How can I set up Wordpress Multisite with exsisted wordpress site.

3 Answers
snowcat March 26, 2017
Accepted Answer

I just solved with this.

@snowcat

You'll need to setup a WildCard DNS A entry for sub-domains to map to your primary domain. If you look at the guide, you'll see this:

server_name examplewp.com *.examplewp.com;

This tells NGINX to map all sub-domains to your main domain unless they actually resolve to another server block. This doesn't, however, account for DNS.

You'll need to add an A entry to your DNS zone file for the WildCard (i.e. *). That'd look like this:

A          *          DROPLET_IP

Where DROPLET_IP is your Droplets IPv4 IP. With those two things taken care of, you should be able to use anything.examplewp.com and it resolve to the main domain. If it happens to be mapped using WPMU, then WPMU should take over and map the correct WordPress site.

One other thing to note is that LetsEncrypt doesn't support WildCard domains, so you can't pass:

letsencrypt certonly -d examplewp.com -d *.examplewp.com

You have to pass resolvable domains and sub-domains, i.e.

letsencrypt certonly -d examplewp.com -d www.examplewp.com

This may be an issue since you're wanting to use sub-domain mapping as the only way (right now) to get a WildCard SSL Certificate is to buy one. So without a WildCard SSL Certificate, each site would be HTTP only (not HTTPS/SSL/HTTP2).

  • Can I use

    letsencrypt certonly -d examplewp.com -d www.examplewp.com -d second.examplewp.com -d second.com -d www.second.com
    

    Like this?

    I also tried this.

@snowcat

If you use sub-domain mapping and want SSL for each mapped installation, you'd need to purchase a WildCard SSL Certificate for your main domain and install it. LetsEncrypt won't work for WildCards.

Passing multiple domains to the LetsEncrypt script in this case, would not be the best option as this is something you're going to have to do over and over again for each and every sub-domain you add as a site. That means if you add two sub-domains today, you have to run it. If you add two more tomorrow, same scenario.

Have another answer? Share your knowledge.