How to setup WordPress Multi-Site on CyberPanel

How to setup WordPress Multi-Site on CyberPanel

A multi-site setup for WordPress enables the end-user to create multiple WordPress sites from the WordPress dashboard. Each site with-in a WordPress network acts as a separate WordPress installation and can be managed from a single dashboard.

This feature is provided by WordPress to ensure that its users can easily create a network of sites without digging too much into server-side problems.

Slow Website?

Try our Managed Hosting to Supercharge your WordPress.

In this article, we will describe how to setup WordPress multi-site network using CyberPanel and then issue Wildcard SSL for multi-site operations.

Table of Contents:

  1. Setup Catch all vHost
  2. Things to do before enabling Multi-Site on WordPress
  3. Configuring WordPress to allow Multi-Site
  4. Create/Install a Multi-site Network
  5. Configuration of Multi-site setup
  6. Create a new site on Network
  7. Setup wildcard SSL on multi-site

1. Setup catch All vHost:

The first thing to do before setting up multi-site is the setup of Catch all vHost. Catch all vHost is the must thing to do before enabling the multi-site configuration in WordPress. A multi-site setup is not possible without the setup of Catch all vHost.

The method for catch-all vHost is different for LiteSpeed Ent and OpenLitespeed.

Setup catch all vHost for LiteSpeed Ent:

Open your vHost file from the website manager and edit this line

ServerAlias www.abc.com
wildcard SSL

Change this to

ServerAlias *.abc.com

Setup Catch all vHost for OpenLiteSpeed:

The setup for OpenLightSpeed is very different from LightSpeed. Follow the steps to do this:

Open “/usr/local/lsws/conf/httpd_config.conf” via command line or using an SFTP software.

image 25

Once you open this file find the Listener Default portion for port 80 (HTTP). It look like:

listener Default{
map example.com example.com
address *:80
secure 0
}

Now if you want to set up catch-all vHost for example.com, change the map line to following:

listener Default {
map example.com example.com, *.example.com
address *:80
secure 0
}

After this portion similarly you have to edit the listener SSL by default it looks like:

listener SSL {
map example.com example.com
address *:443
secure 1
keyFile /etc/letsencrypt/live/example.com/privkey.pem
certFile /etc/letsencrypt/live/example.com/fullchain.pem
............
............
enableStapling 1
ocspRespMaxAge 86400
}

Edit this file add *.example.com on the last of this portion:

listener SSL {
map example.com example.com,*.example.com
address *:443
secure 1
keyFile /etc/letsencrypt/live/example.com/privkey.pem
certFile /etc/letsencrypt/live/example.com/fullchain.pem
.........
.........
enableSpdy 15
enableStapling 1
ocspRespMaxAge 86400
}

vHost Configuration for OpenLiteSpeed:

After editing httpd_config.conf file (/usr/local/lsws/conf/httpd_config.conf) you need to open vHost option from Website Manager and edit vHost.

Default vhAliases

vhAliases www.$VH_NAME
image 26

Edit vhAliases to:

vhAliases *.$VH_NAME
image 27

2. Things to do before enabling Multi-site on WordPress

There are a few things you need to do before enabling and using Multi-Site on WordPress. Here are some key points:

Backup your full single website:

Always make a backup of your whole site (files and databases) before creating a network. this is an important step so you don’t lose your data and files.

Pretty Permalinks

Check and verify the pretty permalinks work on your single WordPress site.

like: https://wordpress.org/?p=1

image 11

Deactivate Plugins

Deactivate all WordPress plugin before the creation of the network. And activate again after creation.

Go to Plugins->Active and then click on the deactivate button present below every plugin name as shown below in the picture.

image 12

3. Configure Allow multi-site setup

To allow the multi-site setup or network setup you have to check your wp-config.php file on your file manager of the website and add this code to that file.

define( 'WP_ALLOW_MULTISITE', true );

wp-config.php file is present in public_html folder of site.

image 13

4. Create/Install a multi-site Network

After enabling multi-site mode from wp-config.php file now you can see a new option under the tools tab in wp-admin.

Before enabling multi-site network from wp-config.php file.

image 14

After enabling the mode.

Multisite On WordPress

Now go to this new option Network setup in the tool menu. You can see this screen.

image 16

In this screen the first note is for the pretty permalink.

You can select the option. Your sites will be subdomains or subdirectories in the network.

Sub Domian:

subdomain is a domain that is part of a larger domain. A domain-based network in which on-demand sites use subdomains. Like if our domain is “www.abc.com” then “site1.abc.com” or “site2.abc.com” are your subdomains.

Sub Directories:

Note: This does not require setting up catch-all vhost.

A path-based network in which on-demand sites use paths. Like “www.abc.com/site1” or “www.abc.com/site1” are subdirectories.

Use can set network titles according to your choice also provide the network admin email. and after that click on the install, button to process.

5. Configuration of Multi-site setup

Once the network installation is complete. Setup shows a screen which has code for the configuration of wp-config.php and .htaccess files. Copy these lines of code and paste into wp-config.php and .htaccess files accordingly.

image 17

Copy the lines of code and add these to the wp-config.php and replace the second lines of code and replace all these with .htaccess file present in the public_html folder.

After editing these files must log in again to the wp-admin. So you can see the changes on the dashboard. You can see these two new options on your dashboard.

image 18

6. Create new sites on Network

To create new sites Go to the My sites->Network admin->Dashboard option from the top bar of wp-admin.

image 19

When you visit this option you can see a different type of dashboard on your screen.

image 21

To create a new site visit Sites->add new option.

image 20

After clicking the add new button. A screen appears that requires information about your subdomain or subdirectory. As I selected subdirectory its look like:

image 22

In the case of sub domain it look little different.

Once you click the add site button you can see the Dashboard and edit site button on the top of the page.

image 23

You can access the site Dashboard or edit newly create site from here.

7. Setup wildcard SSL on multisite.

For a multi-site setup, we can use the wildcard SSL. Once you create a wild card SSL you have no need to create SSL for every sub domain as WildCard SSL will cover all subdomains.

Create wildcard SSL

Create a wild card SSL for your network using this command on the server terminal.

/root/.acme.sh/acme.sh --issue -d <youdomain.com> -d '*.<youdomain.com>' --dns dns_cf --cert-file /etc/letsencrypt/live/<youdomain.com>/cert.pem --key-file /etc/letsencrypt/live/<youdomain.com>/privkey.pem --fullchain-file /etc/letsencrypt/live/<youdomain.com>/fullchain.pem

CloudFlare File configuration

After creating that wildcard ssl its time to edit information in dns_cf.sh file present in “/root/.acme.sh/dnsapi” directory.

Replace the CF_Key and CF_Email by your key and email. Also, remove # Singh to active them.

CF_Key="sdfsdfsdfljlbjkljlkjsdfoiwje"
CF_Email="[email protected]"

You can also Use CF_token for this process.

Fellow this guide to check CF_Key or generate CF_token.

https://support.cloudflare.com/hc/en-us/articles/200167836-Managing-API-Tokens-and-Keys

Read More: HOW TO CHANGE TIMEZONE ON LINUX SERVER

Follow US on Facebook / Twitter  for update.

Slow Website?

Try our Managed Hosting to Supercharge your WordPress.

Tags: , , , , , ,

21 thoughts on “How to setup WordPress Multi-Site on CyberPanel

  • Eduardo

    Hola,

    Thanks for your tutorial. By following other tutorials I was only getting 404 errors when trying to access the subdomains.

    However, the only problem remaining is that the mydomain.com.mx is secured (SSL lock on Chrome), but when I try to access any of subdomain1.mydomain.com.mx or subdomain2.mydomain.com.mx I get a Not Secure warning (Certicate not valid).

    I’m using WordPress Multisite. domain and subdomains have https:// in the url inside WP.

    I’m following this tutorial up to “Create wildcard SSL”, because I’m not using CloudFlare. Yet when I issue the acme.sh command, I get a challenge error that it couldn’t write the TXT record. And it tells me I’m not using cloudflare.

    I did the tutorial again with a second domain and subdomains and the same things happens. The main domain is secured but the subdomains are not.

    Both main domains have:
    @–>A–>cyberpanel IP
    www–>CNAME–>mydomain.com.mx
    * –>A—>cyberpanel IP. (wildcard)

    If I check the logs at cyberpanel, all certificates are said to be correcly issued, including the subdomains.

    If I check domain an subdomain urls with SSL testers, they all say the certificates are ok.

    I also followed the testing mentioned here: https://cyberpanel.net/docs/how-to-fix-ssl-issues-in-cyberpanel/
    but it makes no difference: domains is secured but subdomains are not.

    My Cyberpanel/Openlitespeed is hosted in Google Cloud VM.

    Hope you can point me in the right direction.

    By the way, I already did all the Chrome-related checks like clearing all history (cache), etc.

    Gracias!

    • Shoaib Khan Khattak

      Hi,
      If you are getting 404 on subdomains, Please check your Catch all vHost.
      Catch all configuration is different for OpenliteSpeed and Litespeed Ent. Both are mentioned in the article.

      Before running the Acme command edit this file first ‘/root/.acme.sh/dnsapi’. Remove # sign from the starting of CF_key, CF_email, and CF_token present in this file. And add the value of these. follow the tutorial to get Cf_key and token.
      https://support.cloudflare.com/hc/en-us/articles/200167836-Managing-API-Tokens-and-Keys

      After all, these steps run this acme command

      /root/.acme.sh/acme.sh –issue -d -d ‘*.‘ –dns dns_cf –cert-file /etc/letsencrypt/live//cert.pem –key-file /etc/letsencrypt/live//privkey.pem –fullchain-file /etc/letsencrypt/live//fullchain.pem

  • Eduardo

    Hola, Shoaib.

    Thanks for answering. The way I made it work yesterday night was by following again the tutorial but declaring the explicit subdomains, i.e. http://www.mydomain.com.mx, subdomain1.mydomain.com.mx, subdomain2.mydomain.com.mx, etc. and not using the wildcard. The only place were I left the wildcard was at the vhAliases *.$VH_NAME in VHost in the vHost Configuration for OpenLiteSpeed step.

    When issuing the certificate, I also declared the subdomains and did not use the wildcard. That way, the certificate was issued without any errors nor warnings. Also, I declared the A records for the subdomains at the DNS and removed the wildcard A record.

    And yes, I’m using OpenLiteSpeed and saw the notice on the tutorial. Thanks for making sure I followed it correctly.

    As for the CF step… I’m not using CloudFlare nor intend to. Saw the documentation before but does not apply to my install.

    It is working fine now, so I won’t touch it any more 🙂

    ¡Muchas gracias! (Thanks a lot!)

    Eduardo

  • Diego

    Hello and thanks for the tutorial :D. Can you explain a little more about how to properly execute the command to create a wildcard ssl ? I will create a letsencrypt wildcard?

    • Shoaib Khan Khattak

      /root/.acme.sh/acme.sh –issue -d -d ‘*.‘ –dns dns_cf –cert-file /etc/letsencrypt/live//cert.pem –key-file /etc/letsencrypt/live//privkey.pem –fullchain-file /etc/letsencrypt/live//fullchain.pem

      This is the command for the wild card SSL. “*.” show the SSL for all sub-domains.

      • Diego

        /root/.acme.sh/acme.sh: line 7451: –issue: command not found
        I’m new to all this stuff. I’m trying to configure a wordpress multisite on alibaba ECS for learning purpose, everything is working ok but I don’t understand how to generate the wilcard certificate. Im using cyberpanel with openlitespeed.

  • Diego

    I have solved som issues, now I’m getting “Error add txt for domain:_acme-challenge.mydomain.com”

  • Diego

    I’ve done it, thanks to your guide. Edited dns_ali with the key from alibaba cloud and it worked. Now I have another problem… How do i point other domains to the multisite? for example, i have the subsite example.mainpage.com but i wish it to be example.com, how do i point that domain to the multisite? Domain Alias ?

  • Diego

    What about ssl certificate for that A record?

  • Diego

    Replying myself…. to add tld domains to subsites in a wordpress multisite with cyberpanel and openlitespeed you need to add the domain s a child domain of the main site, then edit vhost to point the root of that subsite tld domain to the root of the main site /home/mainsitedomain.com/public_html. At last you need to issue the ssl certificate. Reboot OLS.

  • Diego

    I’m having one last problem 😛 . The ssl of the main site is not working, but subsites ssl is working perfect. I don’t know what is happening.

  • Diego

    http://www.sslshopper.com is showing everything fine. I have looked the error with the brownser inspector and it is showing the favicon as mixed content. Could it be something related to litespeed wordpress plugin caching the favicon?

  • Diego

    Should i add the http://www.mydomain.com and www.*.mydomain.com variations to the ssl cert? the https://subdomain.mainsite.com works good but if i add www. to the subdomain then the ssl is broken.

    • Shoaib Khan Khattak

      Issue SSL for www or redirect www to without www.

      • Diego

        I’ve used the redirect method and it is working fine, thanks for your help. Now I’m having another problem, everything is working fine with subsite.mainsite.com ssl certificates but… I’m adding top level domains blahblah.com to the substites using the child domains way and then changing the child domain docRoot path to the main site root. It is working fine, i can access the subsites using the top level domain assigned to it, the problem is that cyberpanel is unable to autorenew ssl certificates of this kind of subsites, if i change the child domain docRoot back to normal “docRoot /home/mainsite.com/childdomain.com.” path the ssl certification renovation is issued with no problems. What should i do?

Leave a Reply

Your email address will not be published.