• Compute
    Compute

    Configure a popular Linux OS or use popular developer Tools

  • Cloud hosting
    Cloud hosting

    Host a VPS in the Cloud in seconds

  • Collaborate, CMS, CRM`s
    Collaborate, CMS, CRM`s

    Collaborate with these popular CMS, CRM & collaboration tools

  • Database & E-Commerce
    Database & E-Commerce

    Create a database or an E-Commerce environment in seconds

Hosting Multiple Wordpress Sites on Ubuntu 18.04+ Linux

To begin with, let's identify the two common methods of hosting multiple Wordpress installs. The first one is individual installs using Apache virtual-hosts or Nginx server blocks. This set-up allows you to install as many Wordpress websites as your server has resources for. Each vhost (virtual-host) or server block can be assigned its own domain and contain a separate working directory from other installs. 


The second method is using what is known as a Wordpress Multisite Network. This allows you to host and maintain multiple Wordpress websites from a single dashboard. This is especially handy if you want to contain multiple Wordpress installations for an organization under one umbrella.


In this guide, we are going to work with individual Apache2 virtual-hosts

Please note - This guide assumes that you already have a functional LAMP stack. If you are not already at this point, please see follow this guide until the 'Download Wordpress' section, continue with this current guide when you reach that point -> https://help.skysilk.com/support/solutions/articles/9000173246-how-to-install-wordpress-with-lamp-on-ubuntu 


Once you have a LAMP stack up and running, we're going to set up our hosting environment. Navigate to your www folder.


cd /var/www/


Now we are going to be creating some folders, the number of folders is based on how many websites you're trying to host. We will be doing three in this example.


mkdir example.com secondsite.net thirdsite.org


Then enter each directory and install the basic default Wordpress files whichever way you find most comfortable. The following command will download the latest Wordpress installation and unpack the files for you.


wget https://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz


For simplicity's sake, we are going to repeat the above two more times in the other directories we created. Once it's done, we can navigate back to /var/www/ and set the proper settings for security.


sudo chown www-data:www-data example.com secondsite.net thirdsite.org

sudo chmod 755 example.com secondsite.net thirdsite.org

ls -ln



(Note, we are using root in this example. If you are logged in with a user other than root, you will need to ensure that you use sudo with some of the commands)


Next, we are going to create a MySQL Database as well as a corresponding database user for each site. 


mysql -u root -p


CREATE DATABASE wordpress_db;
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wordpress_user'@'localhost' IDENTIFIED BY 'wordpress_pw';
FLUSH PRIVILEGES;

CREATE DATABASE wordpress2_db;
GRANT ALL PRIVILEGES ON wordpress2_db.* TO 'wordpress2_user'@'localhost' IDENTIFIED BY 'wordpress2_pw';
FLUSH PRIVILEGES;

CREATE DATABASE wordpress3_db;
GRANT ALL PRIVILEGES ON wordpress3_db.* TO 'wordpress3_user'@'localhost' IDENTIFIED BY 'wordpress3_pw';
FLUSH PRIVILEGES;

EXIT;

Once that's finished, we will move on to setting up the Apache Virtual-Hosts files. Begin by copying the default site configuration and naming to match our first Wordpress site.


sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf


We're going to modify this file to look something like below:


<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


Then we're going to copy it over to the second domain's configuration file:


sudo cp /etc/apache2/sites-available/example.com.conf /etc/apache2/sites-available/secondsite.net.conf


Inside this file, we are going to modify it to look something like below:


<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName secondsite.net
    ServerAlias www.secondsite.net
    DocumentRoot /var/www/secondsite.net/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Lastly, we will do it one last time:


sudo cp /etc/apache2/sites-available/example.com.conf /etc/apache2/sites-available/thirdsite.org.conf
<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName thirdsite.org
    ServerAlias www.thirdsite.org
    DocumentRoot /var/www/thirdsite.org
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


Finally, we are about finished with the basic vhosts setup. As long as each domain has an A Record pointing to this server, they should be able to resolve. We're going to enable these vhosts, disable the default site, and after we will restart Apache2 followed by testing.


sudo a2ensite example.com.conf
sudo a2ensite secondsite.net.conf
sudo a2ensite thirdsite.org.conf


sudo a2dissite 000-default.conf


sudo systemctl restart apache2


Now we should be able to navigate to each different URL. If all went as expected, then you should be brought to the install page for each Wordpress site.



Congratulations! You have now successfully configured Apache2 Virtual-Hosts to allow your Ubuntu VPS to host more than one website or Wordpress site.



Join our Private Discord Chat to chat with, as well as find community assistance from other Verified SkySilk Users:
https://invite.gg/SkySilk  


CLICK TO DEPLOY AN UBUNTU LINUX VPS

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.