This WordPress tutorial will assist you through WordPress multisite deployment. That means you will learn to set up multiple separate root domains(as much as you want!) in a single WordPress installation and utilize a single MySQL database. You can administer and use both sites in completely separate ways.
So you don’t get confused, I would like to clarify that if you are looking for a solution to manage multiple sites under subdomains or subfolders, you should start with the WordPress network creation page, which WordPress has been providing support for a while.
Why Choose WordPress Multisite?
Well, there are several reasons which might convince you to set up multiple sites on a single WordPress installation. Some of the reasons are as follows:
Maintenance: This is the most important part of why I would like to have a single WordPress installation for my multiple websites. It would be easier for me to maintain the plugins/themes, etc., for all of my sites in one place. There would be no extra effort to update WordPress and/or its plugins/themes separately for each site.
Hosting Limitations: Sometimes, various hosting providers don’t completely support setting up multiple domains in a separate directory on your hosting server for lower packages. In such cases, modifying your only WordPress installation to support multiple sites could be very handy.
Database Limitations: Sometimes, it may be possible that you can’t afford multiple databases for costing. Utilizing a single database for multiple websites will help you balance your spending.
Install Your First WordPress Site:
There are no additional steps involved in installing your first WordPress site, which may be required or helpful for your subsequent sites on that same installation. Just one thing to remember for a WordPress site setup. By default, database table prefixes are set to “wp_.” But you should change it to something more suitable to your domain name. For my site, “codesamplez.com,” I would like to use the “cs_” prefix very much.
Perform Second And Consecutive Installs:
Now, we are in the main stage of setting up another site with our same WordPress installation. Follow the steps below carefully:
Setup Your Domain: First, we will need to host our new domain on the same directory as our previous installation.
Back up Your wp-config.php and remove it from the server: While starting the installation, first keep a copy of your wp-config.php file and then remove it from the server to let WordPress know that we want a new site installed. Be careful that your previous domain will also become unavailable at this moment. So, consider doing it in off-pick hours when your live site gets the least traffic.
Begin Installation: now navigate to your new domain on browser and you should see the new WordPress installation page. Start your installation as you did for your first site. Just be careful about the database prefix field and give it a unique prefix which previous site doesn’t have.
Finally Edit wp-config.php:
if($_SERVER['HTTP_HOST'] == "www.yourfirstdomain.info" || $_SERVER['HTTP_HOST'] == "yourfirstdomain.info"){
$table_prefix = 'cp_';
}
elseif($_SERVER['HTTP_HOST'] == "yourseconddomain.me" || $_SERVER['HTTP_HOST'] == "www.yourseconddomain.me"){
$table_prefix = 'cn_';
}
//and so on for all consecutive sitesCode language:PHP(php)
So, this is it. We should be fine now with both sites working together inside the single database and single WordPress installation. Isn’t it simple? Let me know if you are facing any issues while trying the above instructions. Happy coding 🙂
Rana Md Ali Ahsan is a seasoned software engineer and technology leader known for his distributed systems and software architecture expertise. With a Master’s in Software Engineering from Concordia University, his experience spans leading scalable architecture at Coursera and TopHat, contributing to open-source projects, and developing cutting-edge API platforms. This blog, CodeSamplez.com, showcases his passion for sharing practical insights on software development. Github | X | LinkedIn
Leave a Reply